зеркало из https://github.com/microsoft/spinnaker.git
Fixed yaml_util writing captalized booleans to config. (#959)
This commit is contained in:
Родитель
ee244e8abd
Коммит
dd5fa48c81
|
@ -24,7 +24,7 @@ class Processor(object):
|
|||
return {match.group(1): match.group(2).strip()
|
||||
for match in re.finditer('^([^\s#]+)=([^\n#]*)',
|
||||
content, re.MULTILINE)}
|
||||
|
||||
|
||||
def __init__(self, config, environ_path, yml_path, aws_path):
|
||||
with open(environ_path, 'r') as f:
|
||||
self.__environ_content = f.read()
|
||||
|
@ -47,6 +47,10 @@ class Processor(object):
|
|||
if value is None:
|
||||
return
|
||||
|
||||
# yaml doesn't understand capital letter boolean values.
|
||||
if isinstance(value, bool):
|
||||
value = str(value).lower()
|
||||
|
||||
self.__environ_keys.add(key)
|
||||
assignment = '{name}={value}'.format(name=name, value=value)
|
||||
match = re.search('^{name}=.*'.format(name=name),
|
||||
|
|
|
@ -227,6 +227,10 @@ class YamlBindings(object):
|
|||
# Quote strings with nested {} yaml flows
|
||||
value = '"{0}"'.format(value)
|
||||
|
||||
# yaml doesn't understand capital letter boolean values.
|
||||
if isinstance(value, bool):
|
||||
value = str(value).lower()
|
||||
|
||||
return ''.join([
|
||||
source[0:value_start],
|
||||
' {value}'.format(value=value),
|
||||
|
|
|
@ -315,6 +315,24 @@ a:
|
|||
bindings.get('root'))
|
||||
self.assertEqual(bindings.get('root'), bindings.get('copy'))
|
||||
|
||||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче