diff --git a/src/main/helm/README.md b/src/main/helm/README.md index 343f5028d591329a068cf876ba38de3dd9b642a5..67032f5378d94bdfc436404c1845a0c1cac57833 100644 --- a/src/main/helm/README.md +++ b/src/main/helm/README.md @@ -91,3 +91,10 @@ env: - 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 89c0a9277df86d7042b64ea75e4c2213e8a21331..c7e9bcd8833a52f0e9f1bd7d747ccaadcaf971f3 100644 --- a/src/main/helm/templates/deployment.yaml +++ b/src/main/helm/templates/deployment.yaml @@ -81,8 +81,8 @@ spec: - name: grpc_client_vorgang-manager-{{ (.Values.routing).targetVorgangManagerName}}_negotiationType value: {{ (.Values.routing).negotiationType | default "PLAINTEXT" }} {{- end }} - {{- with (.Values.env).customList }} -{{ 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/main/helm/values.yaml b/src/main/helm/values.yaml index 11fdeb4ae386e81f51da0db2f35833333c0079f8..118009532b1262af86efb421e2108e41dae7775c 100644 --- a/src/main/helm/values.yaml +++ b/src/main/helm/values.yaml @@ -29,18 +29,6 @@ image: name: intelliform-adapter # [default: intelliform-adapter] tag: latest # [default: latest] -# env: -# overrideSpringProfiles: "oc,prod" - # customList: # add name value pair for additional environments - # - name: Dinge - # value: true -#resources: -# limits: -# cpu: 1 # [default: 1] -# memory: 1200Mi # [default: 1200Mi] -# requests: -# cpu: 100m # [default: 100m] -# memory: 250Mi # [default: 250Mi] ingress: enabled: true diff --git a/src/test/helm/deployment_env_customList_test.yaml b/src/test/helm/deployment_env_customList_test.yaml index 16022898f61af3474411ceff275c470d1feed81a..8770315d50e1118478b9bf810bc158c1e03664a1 100644 --- a/src/test/helm/deployment_env_customList_test.yaml +++ b/src/test/helm/deployment_env_customList_test.yaml @@ -29,7 +29,7 @@ set: ozgcloud.environment: test imagePullSecret: image-pull-secret tests: - - it: check customList + - it: check customList as list set: env.customList: - name: my_test_environment_name @@ -40,6 +40,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: diff --git a/xta-adapter/src/main/helm/templates/network_policy.yaml b/xta-adapter/src/main/helm/templates/network_policy.yaml index f8261b0885fd73688689a3f6fb873025e1ba0bde..b65e30f07ac0bc4277370f0879bc71c2c9c8adb5 100644 --- a/xta-adapter/src/main/helm/templates/network_policy.yaml +++ b/xta-adapter/src/main/helm/templates/network_policy.yaml @@ -66,7 +66,10 @@ spec: protocol: TCP - port: 9000 protocol: TCP -{{- with (.Values.networkPolicy).additionalEgressConfig }} +{{- with (.Values.networkPolicy).additionalEgressConfigLocal }} +{{ toYaml . | indent 2 }} +{{- end }} +{{- with (.Values.networkPolicy).additionalEgressConfigGlobal }} {{ toYaml . | indent 2 }} {{- end }} diff --git a/xta-adapter/src/test/helm/network_policy_test.yaml b/xta-adapter/src/test/helm/network_policy_test.yaml index 62eac6b1ad08aca179db7207cfd4071d92bc219e..7e725ee8a94e63b8a7156aa15cfad027b7d45575 100644 --- a/xta-adapter/src/test/helm/network_policy_test.yaml +++ b/xta-adapter/src/test/helm/network_policy_test.yaml @@ -89,12 +89,28 @@ tests: - port: 9000 protocol: TCP - - it: add egress rules by values + - it: add egress rules by values local set: networkPolicy: ssoPublicIp: 51.89.117.53/32 dnsServerNamespace: test-dns-namespace - additionalEgressConfig: + additionalEgressConfigLocal: + - to: + - ipBlock: + cidr: 1.2.3.4/32 + asserts: + - contains: + path: spec.egress + content: + to: + - ipBlock: + cidr: 1.2.3.4/32 + - it: add egress rules by values global + set: + networkPolicy: + ssoPublicIp: 51.89.117.53/32 + dnsServerNamespace: test-dns-namespace + additionalEgressConfigGlobal: - to: - ipBlock: cidr: 1.2.3.4/32