From b65b38db5cfc5dae169918b5c798228b420c264f Mon Sep 17 00:00:00 2001 From: rabi Date: Thu, 4 Aug 2016 09:23:03 +0530 Subject: [PATCH] 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 --- heat/common/environment_format.py | 8 +++++--- heat/tests/test_environment_format.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/heat/common/environment_format.py b/heat/common/environment_format.py index 2b11638343..1c4b968de0 100644 --- a/heat/common/environment_format.py +++ b/heat/common/environment_format.py @@ -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: diff --git a/heat/tests/test_environment_format.py b/heat/tests/test_environment_format.py index 1af3cd8fcf..facc5d3a3e 100644 --- a/heat/tests/test_environment_format.py +++ b/heat/tests/test_environment_format.py @@ -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: {}