summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChengen Du <chengen.du@canonical.com>2022-12-20 18:00:00 +0800
committerTakashi Kajinami <tkajinam@redhat.com>2023-03-29 20:07:35 +0900
commit5b858505baeea40cc24ff7609e8af2ceff1fac7e (patch)
tree2558492bf80d1ed034e79f92701aff60e50bfe13
parent23a6768ab11ec04e698b4e0cc7ab8c094f4616e8 (diff)
downloadheat-5b858505baeea40cc24ff7609e8af2ceff1fac7e.tar.gz
Honor 'hidden' parameter in 'stack environment show' command
Backport note: This includes change I0abbd535aacc03446ada0fa806dfdfdaa4522afe which fixed the wrong explanation in the release note file. Related-Bug: #1999665 Story: 2010484 Task: 47052 Change-Id: Ifc51ff6a4deab05002ccded59383416f9a586aa0 (cherry picked from commit c1b5fcfbe37d3f94d5b73ae36e071d1aa8c4e0f5) (cherry picked from commit 436ecad6511b30683f6b9af4e484ed64c3bcaab9) (cherry picked from commit c50d720aa36fd7553b133a5a2f4fefdb3040211f) (cherry picked from commit 1a49525c547a607743160a33b6a23041378ff177)
-rw-r--r--heat/engine/service.py12
-rw-r--r--heat/tests/test_engine_service.py3
-rw-r--r--releasenotes/notes/honor-hidden-parameter-in-stack-env-show-cmd-062065545dfef82a.yaml6
3 files changed, 19 insertions, 2 deletions
diff --git a/heat/engine/service.py b/heat/engine/service.py
index 00c7f2c61..ddd412a22 100644
--- a/heat/engine/service.py
+++ b/heat/engine/service.py
@@ -12,6 +12,7 @@
# under the License.
import collections
+import copy
import datetime
import functools
import itertools
@@ -1350,7 +1351,16 @@ class EngineService(service.ServiceBase):
:rtype: dict
"""
s = self._get_stack(cnxt, stack_identity, show_deleted=True)
- return s.raw_template.environment
+ tmpl = templatem.Template.load(cnxt, s.raw_template_id, s.raw_template)
+ param_schemata = tmpl.all_param_schemata(tmpl.files)
+ env = copy.deepcopy(s.raw_template.environment)
+ for section in [env_fmt.PARAMETERS, env_fmt.PARAMETER_DEFAULTS]:
+ for param_name in env.get(section, {}).keys():
+ if (param_name not in param_schemata
+ or not param_schemata[param_name].hidden):
+ continue
+ env[section][param_name] = str('******')
+ return env
@context.request_context
def get_files(self, cnxt, stack_identity):
diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py
index 875d44dcd..9ce13e308 100644
--- a/heat/tests/test_engine_service.py
+++ b/heat/tests/test_engine_service.py
@@ -978,11 +978,12 @@ class StackServiceTest(common.HeatTestCase):
env = {'parameters': {'KeyName': 'EnvKey'}}
tmpl = templatem.Template(t)
stack = parser.Stack(self.ctx, 'get_env_stack', tmpl)
+ stack.store()
mock_get_stack = self.patchobject(self.eng, '_get_stack')
mock_get_stack.return_value = mock.MagicMock()
mock_get_stack.return_value.raw_template.environment = env
- self.patchobject(parser.Stack, 'load', return_value=stack)
+ self.patchobject(templatem.Template, 'load', return_value=tmpl)
# Test
found = self.eng.get_environment(self.ctx, stack.identifier())
diff --git a/releasenotes/notes/honor-hidden-parameter-in-stack-env-show-cmd-062065545dfef82a.yaml b/releasenotes/notes/honor-hidden-parameter-in-stack-env-show-cmd-062065545dfef82a.yaml
new file mode 100644
index 000000000..8a3a366ee
--- /dev/null
+++ b/releasenotes/notes/honor-hidden-parameter-in-stack-env-show-cmd-062065545dfef82a.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+ - |
+ Honor ``hidden`` parameter in get stack environment API. Now values passed
+ to hidden parameters are replaced by '******', similarly to the other
+ APIs such as show stack details API.