本文整理汇总了Python中spinnaker.yaml_util.YamlBindings.update_yml_source方法的典型用法代码示例。如果您正苦于以下问题:Python YamlBindings.update_yml_source方法的具体用法?Python YamlBindings.update_yml_source怎么用?Python YamlBindings.update_yml_source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spinnaker.yaml_util.YamlBindings
的用法示例。
在下文中一共展示了YamlBindings.update_yml_source方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_yml_source
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import update_yml_source [as 别名]
def test_update_yml_source(self):
yaml = """
a: A
b: 0
c:
- A
- B
d:
child:
grandchild: x
e:
"""
fd, temp_path = tempfile.mkstemp()
os.write(fd, yaml)
os.close(fd)
update_dict = {
'b': 'Z',
'd': {
'child': {
'grandchild': 'xy',
'new_grandchild': {
'new_node': 'inserted'
}
}
},
'e': 'AA'
}
expect = {'a': 'A',
'b': 'Z',
'c': ['A','B'],
'd': {
'child': {
'grandchild': 'xy',
'new_grandchild': {
'new_node': 'inserted'
}
}
},
'e': 'AA'}
with self.assertRaises(KeyError):
YamlBindings.update_yml_source(
temp_path, update_dict, add_new_nodes=False)
# Reset the file
with open(temp_path, 'w') as fd:
fd.write(yaml)
YamlBindings.update_yml_source(temp_path, update_dict)
comparison_bindings = YamlBindings()
comparison_bindings.import_path(temp_path)
self.assertEqual(expect, comparison_bindings.map)
os.remove(temp_path)
示例2: disable_destructive_action_challenge
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import update_yml_source [as 别名]
def disable_destructive_action_challenge():
"""Disables destructive action challenge for codelab.
"""
YamlBindings.update_yml_source(
'/opt/spinnaker/config/clouddriver.yml',
{
'credentials': {
'challengeDestructiveActionsEnvironments': ''
}
}
)
示例3: test_create_yml_source
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import update_yml_source [as 别名]
def test_create_yml_source(self):
expect = {
'first': { 'child': 'FirstValue' },
'second': { 'child': True }
}
fd, temp_path = tempfile.mkstemp()
os.write(fd, "")
os.close(fd)
YamlBindings.update_yml_source(temp_path, expect)
comparison_bindings = YamlBindings()
comparison_bindings.import_path(temp_path)
self.assertEqual(expect, comparison_bindings.map)
os.remove(temp_path)
示例4: test_write_bool
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import update_yml_source [as 别名]
def test_write_bool(self):
yaml = 'a: false'
update_dict = {
'a': True
}
expected = 'a: true'
fd, temp_path = tempfile.mkstemp()
os.write(fd, yaml)
os.close(fd)
YamlBindings.update_yml_source(temp_path, update_dict)
with open(temp_path, 'r') as f:
self.assertEqual(expected, f.read())
os.remove(temp_path)
示例5: test_update_yml_source
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import update_yml_source [as 别名]
def test_update_yml_source(self):
yaml = """
a: A
b: 0
c:
- A
- B
d:
child:
grandchild: x
e:
"""
fd, temp_path = tempfile.mkstemp()
os.write(fd, yaml)
os.close(fd)
update_dict = {
'b': 'Z',
'd': {
'child': {
'grandchild': 'xy'
}
},
'e': 'AA'
}
expect = {'a': 'A',
'b': 'Z',
'c': ['A','B'],
'd': {
'child': {
'grandchild': 'xy'
}
},
'e': 'AA'}
YamlBindings.update_yml_source(temp_path, update_dict)
comparison_bindings = YamlBindings()
comparison_bindings.import_path(temp_path)
self.assertEqual(expect, comparison_bindings.map)
os.remove(temp_path)
示例6: configure_codelab_igor_jenkins
# 需要导入模块: from spinnaker.yaml_util import YamlBindings [as 别名]
# 或者: from spinnaker.yaml_util.YamlBindings import update_yml_source [as 别名]
def configure_codelab_igor_jenkins():
"""Configures Igor to be enabled and to point to the codelab jenkins instance.
"""
YamlBindings.update_yml_source(
'/opt/spinnaker/config/spinnaker-local.yml',
{
'jenkins': {
'defaultMaster': {
'name': 'CodelabJenkins',
'baseUrl': 'http://localhost:9090',
'name': 'admin',
'password': 'admin'
}
},
'igor': {
'enabled': 'true'
}
}
)