Browse Source

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
changes/64/390064/3
rabi 5 years ago
parent
commit
2407c86436
  1. 4
      heat/api/openstack/v1/stacks.py
  2. 11
      heat/tests/api/openstack_v1/test_stacks.py

4
heat/api/openstack/v1/stacks.py

@ -137,7 +137,9 @@ class InstantiationData(object):
environment global options.
"""
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]
with self.parse_error_check('Environment'):
if isinstance(env_data, dict):

11
heat/tests/api/openstack_v1/test_stacks.py

@ -167,6 +167,17 @@ blarg: wibble
data = stacks.InstantiationData(body)
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):
body = {'parameters': {'foo': 'bar'},
'environment': {'parameters': {'blarg': 'wibble'}}}

Loading…
Cancel
Save