Ignore merged env if environment files are specified

Ignore merged environment from the client, if there are
'environment_files' in the request for merging in the server.
This would avoid the duplicates when 'parameter_merge_strategies'
are specified in the first env file.

Change-Id: I4ee274d69e42a47c4b8fd5a25567fb2eb144a8cc
Related-Bug: #1635409
This commit is contained in:
rabi 2016-11-02 08:41:54 +05:30
parent 8bb04edee8
commit 2407c86436
2 changed files with 14 additions and 1 deletions

View File

@ -137,7 +137,9 @@ class InstantiationData(object):
environment global options. environment global options.
""" """
env = {} env = {}
if self.PARAM_ENVIRONMENT in self.data: # Don't use merged environment, if environment_files are supplied.
if (self.PARAM_ENVIRONMENT in self.data and
not self.data.get(self.PARAM_ENVIRONMENT_FILES)):
env_data = self.data[self.PARAM_ENVIRONMENT] env_data = self.data[self.PARAM_ENVIRONMENT]
with self.parse_error_check('Environment'): with self.parse_error_check('Environment'):
if isinstance(env_data, dict): if isinstance(env_data, dict):

View File

@ -167,6 +167,17 @@ blarg: wibble
data = stacks.InstantiationData(body) data = stacks.InstantiationData(body)
self.assertEqual(env, data.environment()) self.assertEqual(env, data.environment())
def test_environment_with_env_files(self):
env = {'parameters': {'foo': 'bar', 'blarg': 'wibble'}}
body = {'environment': env, 'environment_files': ['env.yaml']}
expect = {'parameters': {},
'encrypted_param_names': [],
'parameter_defaults': {},
'event_sinks': [],
'resource_registry': {}}
data = stacks.InstantiationData(body)
self.assertEqual(expect, data.environment())
def test_environment_and_parameters(self): def test_environment_and_parameters(self):
body = {'parameters': {'foo': 'bar'}, body = {'parameters': {'foo': 'bar'},
'environment': {'parameters': {'blarg': 'wibble'}}} 'environment': {'parameters': {'blarg': 'wibble'}}}