diff --git a/src/main/helm/README.md b/src/main/helm/README.md index 464d5334986131fe8bed4825744bac397bb9c2e3..2de2b441e29ccb265bc1114b5e12dfcc4efa825f 100644 --- a/src/main/helm/README.md +++ b/src/main/helm/README.md @@ -81,13 +81,20 @@ routing: ### Benutzung beliebiger environment Werte -In jedem der Projekte kann man beliebige weitere environments setzen. Dazu muss man in der jeweiligen values.yaml unter env.customVarsLocal ein name value Paar setzen: +In jedem der Projekte kann man beliebige weitere environments setzen. Dazu muss man in der jeweiligen values.yaml unter env.customList ein name value Paar setzen: ```yaml env: - customVarsLocal: + customList: - name: Dinge value: true - name: ... value: ... ``` + +```yaml +env: + customList: + key_1: value_1 + key_2: value_2 +``` \ No newline at end of file diff --git a/src/main/helm/templates/_helpers.tpl b/src/main/helm/templates/_helpers.tpl index e0ff7ea44b451f802f623ad7b1f1e3cd47f829ce..4b1132949310d919a2338612c868c02ad7177325 100644 --- a/src/main/helm/templates/_helpers.tpl +++ b/src/main/helm/templates/_helpers.tpl @@ -88,4 +88,21 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} {{- else if eq (.Values.image).name "enterprise-adapter" }} {{- printf "enterprise-adapter-service-account" }} {{- end }} +{{- 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 207444ad5a8cae49c1afc9211ca274c7274e27d7..c7e9bcd8833a52f0e9f1bd7d747ccaadcaf971f3 100644 --- a/src/main/helm/templates/deployment.yaml +++ b/src/main/helm/templates/deployment.yaml @@ -81,11 +81,8 @@ spec: - name: grpc_client_vorgang-manager-{{ (.Values.routing).targetVorgangManagerName}}_negotiationType value: {{ (.Values.routing).negotiationType | default "PLAINTEXT" }} {{- end }} - {{- with (.Values.env).customVarsLocal }} -{{ toYaml . | indent 8 }} - {{- end }} - {{- with (.Values.env).customVarsGlobal }} -{{ toYaml . | indent 8 }} + {{- with include "app.getCustomList" . }} +{{ . | indent 8 }} {{- end }} image: "{{ .Values.image.repo }}/{{ .Values.image.name }}:{{ coalesce (.Values.image).tag "latest" }}" imagePullPolicy: Always diff --git a/src/test/helm/deployment_env_customList_test.yaml b/src/test/helm/deployment_env_customList_test.yaml index 8fe0b2beff4d6ae6245b08b2c36efeec432e4c57..8770315d50e1118478b9bf810bc158c1e03664a1 100644 --- a/src/test/helm/deployment_env_customList_test.yaml +++ b/src/test/helm/deployment_env_customList_test.yaml @@ -29,9 +29,9 @@ set: ozgcloud.environment: test imagePullSecret: image-pull-secret tests: - - it: check customVarsLocal + - it: check customList as list set: - env.customVarsLocal: + env.customList: - name: my_test_environment_name value: "A test value" asserts: @@ -40,11 +40,10 @@ tests: content: name: my_test_environment_name value: "A test value" - - it: check customVarsGlobal + - it: check customList as dict set: - env.customVarsGlobal: - - name: my_test_environment_name - value: "A test value" + env.customList: + my_test_environment_name: "A test value" asserts: - contains: path: spec.template.spec.containers[0].env