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)
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)
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)
def disable_destructive_action_challenge(): """Disables destructive action challenge for codelab. """ YamlBindings.update_yml_source( '/opt/spinnaker/config/clouddriver.yml', { 'credentials': { 'challengeDestructiveActionsEnvironments': '' } } )
def disable_destructive_action_challenge(): """Disables destructive action challenge for codelab. """ YamlBindings.update_yml_source( '/opt/spinnaker/config/clouddriver.yml', { 'credentials': { 'challengeDestructiveActionsEnvironments': '' } } )
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)
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)
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)
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)
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)
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': '******' } }, 'igor': { 'enabled': 'true' } } )
def configure_codelab_igor_jenkins(password): """Configures Igor to be enabled and to point to the codelab jenkins instance. """ YamlBindings.update_yml_source( '/opt/spinnaker/config/spinnaker-local.yml', { 'services': { 'jenkins': { 'defaultMaster': { 'name': 'CodelabJenkins', 'baseUrl': 'http://localhost:5656', 'username': '******', 'password': password } }, 'igor': { 'enabled': 'true' } } })