From c506e1d2b62a31437cdb5fd7cb1cf63a932bf1a2 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Tue, 7 May 2024 14:33:39 +0200 Subject: [PATCH] ozg-5100 fix dict to list function --- src/main/helm/templates/_helpers.tpl | 5 +++-- src/test/helm/deployment_env_test.yaml | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/helm/templates/_helpers.tpl b/src/main/helm/templates/_helpers.tpl index 6effa40e9..ab423e16f 100644 --- a/src/main/helm/templates/_helpers.tpl +++ b/src/main/helm/templates/_helpers.tpl @@ -104,8 +104,9 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} {{- end -}} {{- define "app.dictToList" -}} +{{- $customList := list -}} {{- range $key, $value := . -}} -- name: {{ $key }} - value: {{ $value }} +{{- $customList = append $customList (dict "name" $key "value" $value) }} {{- end -}} +{{- $customList | toYaml -}} {{- end -}} \ No newline at end of file diff --git a/src/test/helm/deployment_env_test.yaml b/src/test/helm/deployment_env_test.yaml index 6ba187adc..573afcbdd 100644 --- a/src/test/helm/deployment_env_test.yaml +++ b/src/test/helm/deployment_env_test.yaml @@ -35,22 +35,35 @@ tests: env.customList: - name: my_test_environment_name value: "A test value" + - name: test_environment + value: "B test value" asserts: - contains: path: spec.template.spec.containers[0].env content: name: my_test_environment_name value: "A test value" + - contains: + path: spec.template.spec.containers[0].env + content: + name: test_environment + value: "B test value" - it: check customList as dict set: env.customList: my_test_environment_name: "A test value" + test_environment: "B test value" asserts: - contains: path: spec.template.spec.containers[0].env content: name: my_test_environment_name value: "A test value" + - contains: + path: spec.template.spec.containers[0].env + content: + name: test_environment + value: "B test value" - it: check customList test value is not set by default asserts: -- GitLab