diff --git a/src/main/helm/templates/_helpers.tpl b/src/main/helm/templates/_helpers.tpl index bbb798821b2f9441f61c4143d24586a0f91cd100..1c10dc5578d8e4827a948a055089fe3064045f4c 100644 --- a/src/main/helm/templates/_helpers.tpl +++ b/src/main/helm/templates/_helpers.tpl @@ -137,4 +137,21 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} {{- define "app.serviceAccountName" -}} {{ printf "%s" ( (.Values.serviceAccount).name | default "user-manager-service-account" ) }} +{{- end -}} + +{{- define "app.getCustomList" -}} +{{- with (.Values.env).customList -}} +{{- if kindIs "map" . -}} +{{ include "app.dictToList" . }} +{{- else if kindIs "slice" . -}} +{{ . | toYaml }} +{{- end -}} +{{- end -}} +{{- end -}} + +{{- define "app.dictToList" -}} +{{- range $key, $value := . -}} +- name: {{ $key }} + value: {{ $value }} +{{- end -}} {{- end -}} \ No newline at end of file diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml index 84ba4da2956ca78801be41f403e61882ce3dfea9..8eb7dae2026666151832f4b3f27ea993d258da0a 100644 --- a/src/main/helm/templates/deployment.yaml +++ b/src/main/helm/templates/deployment.yaml @@ -113,8 +113,8 @@ spec: - name: QUARKUS_GRPC_SERVER_SSL_KEY value: "" {{- end }} - {{- with (.Values.env).customList }} -{{ toYaml . | indent 8 }} + {{- with include "app.getCustomList" . }} +{{ . | indent 8 }} {{- end }} {{- if .Values.optionalTrustStoreSecretName }} - name: TRUST_STORE_PASSWORD diff --git a/src/test/helm/deployment_env_test.yaml b/src/test/helm/deployment_env_test.yaml index c0acc80b8d90dd1c36534024f7fa19a1277d40a8..cb37ebc09607640a09ad1df61d45ac38e132a3bb 100644 --- a/src/test/helm/deployment_env_test.yaml +++ b/src/test/helm/deployment_env_test.yaml @@ -35,7 +35,7 @@ set: baseUrl: test.sh.ozg-cloud.de imagePullSecret: image-pull-secret tests: - - it: check customList + - it: check customList as list set: env.customList: - name: my_test_environment_name @@ -46,6 +46,16 @@ tests: content: name: my_test_environment_name value: "A test value" + - it: check customList as dict + set: + env.customList: + my_test_environment_name: "A test value" + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: my_test_environment_name + value: "A test value" - it: check customList test value is not set by default asserts: - notContains: