diff --git a/xta-adapter/src/main/helm/templates/_helpers.tpl b/xta-adapter/src/main/helm/templates/_helpers.tpl index 5d09c85640bf9ac9943624f3f038687a2bdeec88..dbcecb22abdf9f28ee8e7171811ea6924e0c006c 100644 --- a/xta-adapter/src/main/helm/templates/_helpers.tpl +++ b/xta-adapter/src/main/helm/templates/_helpers.tpl @@ -58,4 +58,21 @@ helm.sh/chart: {{ include "app.chart" . }} {{- define "app.serviceAccountName" -}} {{ printf "%s" ( (.Values.serviceAccount).name | default "xta-adapter-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/xta-adapter/src/main/helm/templates/network_policy.yaml b/xta-adapter/src/main/helm/templates/network_policy.yaml index b65e30f07ac0bc4277370f0879bc71c2c9c8adb5..9e04cc733f33663ffdc7f7c11f55f6f4908df8a0 100644 --- a/xta-adapter/src/main/helm/templates/network_policy.yaml +++ b/xta-adapter/src/main/helm/templates/network_policy.yaml @@ -34,6 +34,13 @@ spec: ozg-component: xta-adapter policyTypes: - Egress + ingress: +{{- with (.Values.networkPolicy).additionalIngressConfigLocal }} +{{ toYaml . | indent 2 }} +{{- end }} +{{- with (.Values.networkPolicy).additionalIngressConfigGlobal }} +{{ toYaml . | indent 2 }} +{{- end }} egress: - to: - podSelector: diff --git a/xta-adapter/src/main/helm/templates/xta_adapter_cronjob.yaml b/xta-adapter/src/main/helm/templates/xta_adapter_cronjob.yaml index 1159ff69ea4971ed41c08d8ba5d36090550ffa5e..b8d0d2b9870587f17f992129bf23928c2bcb48a0 100644 --- a/xta-adapter/src/main/helm/templates/xta_adapter_cronjob.yaml +++ b/xta-adapter/src/main/helm/templates/xta_adapter_cronjob.yaml @@ -85,6 +85,9 @@ spec: - name: grpc_client_vorgang-manager-{{ (.Values.routing).targetVorgangManagerName }}_negotiationType value: {{ (.Values.routing).negotiationType | default "PLAINTEXT" }} {{- end }} + {{- with include "app.getCustomList" . }} +{{ . | indent 16 }} + {{- end }} volumeMounts: - name: bindings mountPath: "/bindings/ca-certificates/type" diff --git a/xta-adapter/src/test/helm/network_policy_test.yaml b/xta-adapter/src/test/helm/network_policy_test.yaml index 7e725ee8a94e63b8a7156aa15cfad027b7d45575..e6f423c443563a94a0bf12e24362bc4e61a975ac 100644 --- a/xta-adapter/src/test/helm/network_policy_test.yaml +++ b/xta-adapter/src/test/helm/network_policy_test.yaml @@ -56,6 +56,7 @@ tests: ozg-component: xta-adapter policyTypes: - Egress + ingress: egress: - to: - podSelector: @@ -122,6 +123,40 @@ tests: - ipBlock: cidr: 1.2.3.4/32 + - it: add ingress rule by values local + set: + networkPolicy: + dnsServerNamespace: test-namespace-dns + additionalIngressConfigLocal: + - from: + - podSelector: + matchLabels: + component: client2 + asserts: + - contains: + path: spec.ingress + content: + from: + - podSelector: + matchLabels: + component: client2 + - it: add ingress rule by values global + set: + networkPolicy: + dnsServerNamespace: test-namespace-dns + additionalIngressConfigGlobal: + - from: + - podSelector: + matchLabels: + component: client2 + asserts: + - contains: + path: spec.ingress + content: + from: + - podSelector: + matchLabels: + component: client2 - it: test network policy disabled set: diff --git a/xta-adapter/src/test/helm/xta_adapter_cronjob_env_test.yaml b/xta-adapter/src/test/helm/xta_adapter_cronjob_env_test.yaml index 4e84137ff94e27f91f7786522f65e9ff5b52d380..0a5f6345d2672cc6f7fb2c667d939d059999d2a6 100644 --- a/xta-adapter/src/test/helm/xta_adapter_cronjob_env_test.yaml +++ b/xta-adapter/src/test/helm/xta_adapter_cronjob_env_test.yaml @@ -154,4 +154,33 @@ tests: path: spec.jobTemplate.spec.template.spec.containers[0].env content: name: grpc_client_vorgang-manager-vorgang-manager_negotiationType - value: "TLS" \ No newline at end of file + value: "TLS" + - it: check customList as list + set: + env.customList: + - name: my_test_environment_name + value: "A test value" + asserts: + - contains: + path: spec.jobTemplate.spec.template.spec.containers[0].env + 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.jobTemplate.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: + path: spec.jobTemplate.spec.template.spec.containers[0].env + content: + name: my_test_environment_name + value: "A test value" \ No newline at end of file