コード例 #1
0
    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
0
ファイル: yaml_util_test.py プロジェクト: PioTi/spinnaker
  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)
コード例 #3
0
    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
0
def disable_destructive_action_challenge():
  """Disables destructive action challenge for codelab.

  """
  YamlBindings.update_yml_source(
    '/opt/spinnaker/config/clouddriver.yml',
    {
      'credentials': {
        'challengeDestructiveActionsEnvironments': ''
      }
    }
  )
コード例 #5
0
ファイル: codelab_config.py プロジェクト: ajordens/spinnaker
def disable_destructive_action_challenge():
  """Disables destructive action challenge for codelab.

  """
  YamlBindings.update_yml_source(
    '/opt/spinnaker/config/clouddriver.yml',
    {
      'credentials': {
        'challengeDestructiveActionsEnvironments': ''
      }
    }
  )
コード例 #6
0
ファイル: yaml_util_test.py プロジェクト: PioTi/spinnaker
  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)
コード例 #7
0
    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)
コード例 #8
0
ファイル: yaml_util_test.py プロジェクト: PioTi/spinnaker
  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)
コード例 #9
0
    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)
コード例 #10
0
ファイル: yaml_util_test.py プロジェクト: sstrato/spinnaker
  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)
コード例 #11
0
ファイル: codelab_config.py プロジェクト: sstrato/spinnaker
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'
      }
    }
  )
コード例 #12
0
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'
                }
            }
        })