Add new environment section for merge strategies

This adds a new evironment section 'parameter_merge_strategies'.
These strategies would subsequently be used to merge parameters
and parameter_defaults from environment files.

Change-Id: Ib2b84ecdb2a1516ea0c5ced25a1fed408b954694
Blueprint: environment-merging
This commit is contained in:
rabi 2016-08-04 09:23:03 +05:30
parent 0a8d40d909
commit b65b38db5c
2 changed files with 20 additions and 3 deletions

View File

@ -17,10 +17,12 @@ from heat.common import template_format
SECTIONS = ( SECTIONS = (
PARAMETERS, RESOURCE_REGISTRY, PARAMETER_DEFAULTS, PARAMETERS, RESOURCE_REGISTRY, PARAMETER_DEFAULTS,
ENCRYPTED_PARAM_NAMES, EVENT_SINKS ENCRYPTED_PARAM_NAMES, EVENT_SINKS,
PARAMETER_MERGE_STRATEGIES,
) = ( ) = (
'parameters', 'resource_registry', 'parameter_defaults', '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): def default_for_missing(env):
"""Checks a parsed environment for missing sections.""" """Checks a parsed environment for missing sections."""
for param in 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): if param in (ENCRYPTED_PARAM_NAMES, EVENT_SINKS):
env[param] = [] env[param] = []
else: else:

View File

@ -34,6 +34,21 @@ resource_registry: {}
tpl2 = environment_format.parse(yaml2) tpl2 = environment_format.parse(yaml2)
self.assertEqual(tpl1, tpl2) 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): def test_wrong_sections(self):
env = ''' env = '''
parameters: {} parameters: {}