Merge "Add new environment section for merge strategies"

This commit is contained in:
Jenkins 2016-08-21 16:56:50 +00:00 committed by Gerrit Code Review
commit d02c77ce40
2 changed files with 20 additions and 3 deletions

View File

@ -17,10 +17,12 @@ from heat.common import template_format
SECTIONS = (
PARAMETERS, RESOURCE_REGISTRY, PARAMETER_DEFAULTS,
ENCRYPTED_PARAM_NAMES, EVENT_SINKS
ENCRYPTED_PARAM_NAMES, EVENT_SINKS,
PARAMETER_MERGE_STRATEGIES,
) = (
'parameters', 'resource_registry', 'parameter_defaults',
'encrypted_param_names', 'event_sinks'
'encrypted_param_names', 'event_sinks',
'parameter_merge_strategies',
)
@ -63,7 +65,7 @@ def validate(env):
def default_for_missing(env):
"""Checks a parsed environment for missing sections."""
for param in SECTIONS:
if param not in env:
if param not in env and param != PARAMETER_MERGE_STRATEGIES:
if param in (ENCRYPTED_PARAM_NAMES, EVENT_SINKS):
env[param] = []
else:

View File

@ -34,6 +34,21 @@ resource_registry: {}
tpl2 = environment_format.parse(yaml2)
self.assertEqual(tpl1, tpl2)
def test_param_valid_strategy_section(self):
yaml1 = ''
yaml2 = '''
parameters: {}
encrypted_param_names: []
parameter_defaults: {}
parameter_merge_strategies: {}
event_sinks: []
resource_registry: {}
'''
tpl1 = environment_format.parse(yaml1)
environment_format.default_for_missing(tpl1)
tpl2 = environment_format.parse(yaml2)
self.assertNotEqual(tpl1, tpl2)
def test_wrong_sections(self):
env = '''
parameters: {}