diff --git a/ozgcloud-elasticsearch-operator/src/main/helm/templates/_helpers.tpl b/ozgcloud-elasticsearch-operator/src/main/helm/templates/_helpers.tpl index 5b08fa932ccbeb01edc1aea23eb199f904d2c8c9..f3d0b8ee331da471944aa4657df601ce88a13e40 100644 --- a/ozgcloud-elasticsearch-operator/src/main/helm/templates/_helpers.tpl +++ b/ozgcloud-elasticsearch-operator/src/main/helm/templates/_helpers.tpl @@ -4,4 +4,22 @@ {{- define "app.matchLabels" }} app.kubernetes.io/name: {{ .Release.Name }} app.kubernetes.io/namespace: {{ .Release.Namespace }} +{{- 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" -}} +{{- $customList := list -}} +{{- range $key, $value := . -}} +{{- $customList = append $customList (dict "name" $key "value" $value) }} +{{- end -}} +{{- $customList | toYaml -}} {{- end -}} \ No newline at end of file diff --git a/ozgcloud-elasticsearch-operator/src/main/helm/templates/deployment.yaml b/ozgcloud-elasticsearch-operator/src/main/helm/templates/deployment.yaml index 549b8979f9eb3d62c6008b29c468926edd1b2cad..b3139b3c31da2a85f69755d46a39522c35e5d393 100644 --- a/ozgcloud-elasticsearch-operator/src/main/helm/templates/deployment.yaml +++ b/ozgcloud-elasticsearch-operator/src/main/helm/templates/deployment.yaml @@ -49,8 +49,8 @@ spec: - name: ozgcloud-elasticsearch-operator image: "{{ required "image.repo must be set" (.Values.image).repo }}/{{ required "image.name must be set" (.Values.image).name }}:{{ required "image.tag must be set" (.Values.image).tag }}" env: - {{- with (.Values.env).customList }} -{{ toYaml . | indent 8 }} + {{- with include "app.getCustomList" . }} +{{ . | indent 8 }} {{- end }} - name: SERVICE_BINDING_ROOT value: "/bindings" diff --git a/ozgcloud-elasticsearch-operator/src/test/helm/deployment_env_customList_test.yaml b/ozgcloud-elasticsearch-operator/src/test/helm/deployment_env_customList_test.yaml index 49a663bb9a2b058aba7e0f920c5b49bc708e0196..0ba2af654f3a00ea8cd15805d600790228e2effc 100644 --- a/ozgcloud-elasticsearch-operator/src/test/helm/deployment_env_customList_test.yaml +++ b/ozgcloud-elasticsearch-operator/src/test/helm/deployment_env_customList_test.yaml @@ -30,12 +30,34 @@ set: namespace: elastic-system adminSecretName: ozg-search-cluster-es-elastic-user certificateSecretName: ozg-search-cluster-es-http-ca-internal + image: + name: hase + tag: latest + imagePullSecret: imagePullSecret tests: - - it: check customList + - it: check customList as list set: 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" image: name: hase tag: latest @@ -46,4 +68,8 @@ tests: 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" diff --git a/ozgcloud-keycloak-operator/src/main/helm/templates/_helpers.tpl b/ozgcloud-keycloak-operator/src/main/helm/templates/_helpers.tpl index 26abf5bda1bc75d8f2e62322f075cf0654cc6264..88374fcb35d5ea70818014c06368bb823aec3cbc 100644 --- a/ozgcloud-keycloak-operator/src/main/helm/templates/_helpers.tpl +++ b/ozgcloud-keycloak-operator/src/main/helm/templates/_helpers.tpl @@ -3,4 +3,22 @@ {{- define "app.matchLabels" }} app.kubernetes.io/name: {{ .Release.Name }} app.kubernetes.io/namespace: {{ .Release.Namespace }} +{{- 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" -}} +{{- $customList := list -}} +{{- range $key, $value := . -}} +{{- $customList = append $customList (dict "name" $key "value" $value) }} +{{- end -}} +{{- $customList | toYaml -}} {{- end -}} \ No newline at end of file diff --git a/ozgcloud-keycloak-operator/src/main/helm/templates/deployment.yaml b/ozgcloud-keycloak-operator/src/main/helm/templates/deployment.yaml index 648ac58411329ed13f72073b0fd1280eca93435c..5691861bda18398935621337c324dcc5f3820589 100644 --- a/ozgcloud-keycloak-operator/src/main/helm/templates/deployment.yaml +++ b/ozgcloud-keycloak-operator/src/main/helm/templates/deployment.yaml @@ -49,8 +49,8 @@ spec: - name: ozgcloud-keycloak-operator image: "{{ required "image.repo must be set" (.Values.image).repo }}/{{ required "image.name must be set" (.Values.image).name }}:{{ required "image.tag must be set" (.Values.image).tag }}" env: - {{- with (.Values.env).customList }} -{{ toYaml . | indent 8 }} + {{- with include "app.getCustomList" . }} +{{ . | indent 8 }} {{- end }} imagePullPolicy: Always # readinessProbe: diff --git a/ozgcloud-keycloak-operator/src/test/helm/deployment_env_test.yaml b/ozgcloud-keycloak-operator/src/test/helm/deployment_env_test.yaml index 55882a09d7a3da3ee0a9ce963dc9d3f47b2613b0..1e21edeb4ef394e09b28bd587f640db86fd05a7e 100644 --- a/ozgcloud-keycloak-operator/src/test/helm/deployment_env_test.yaml +++ b/ozgcloud-keycloak-operator/src/test/helm/deployment_env_test.yaml @@ -31,16 +31,42 @@ set: name: hase tag: latest tests: - - it: check customList - template: deployment.yaml + - it: check customList as list set: 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" + image: + name: hase + tag: latest + imagePullSecret: imagePullSecret + 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"