From 4d055513313d3246d4eba62f303f610d20adcc0d Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Tue, 16 Apr 2024 11:28:42 +0200
Subject: [PATCH] OZG-5100 separate customList and additional networkpolicy
 config into local and global

---
 src/main/helm/README.md                       |  4 ++--
 src/main/helm/templates/deployment.yaml       |  5 ++++-
 src/main/helm/values.yaml                     | 12 -----------
 .../helm/deployment_env_customList_test.yaml  | 15 ++++++++++++--
 .../main/helm/templates/network_policy.yaml   |  5 ++++-
 .../src/test/helm/network_policy_test.yaml    | 20 +++++++++++++++++--
 6 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/src/main/helm/README.md b/src/main/helm/README.md
index 343f5028d..888df3bd6 100644
--- a/src/main/helm/README.md
+++ b/src/main/helm/README.md
@@ -81,11 +81,11 @@ 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.customList 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.customVarsLocal ein name value Paar setzen:
 
 ```yaml
 env:
-  customList:
+  customVarsLocal:
     - name: Dinge
       value: true
     - name: ...
diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml
index 89c0a9277..207444ad5 100644
--- a/src/main/helm/templates/deployment.yaml
+++ b/src/main/helm/templates/deployment.yaml
@@ -81,7 +81,10 @@ spec:
         - name: grpc_client_vorgang-manager-{{ (.Values.routing).targetVorgangManagerName}}_negotiationType
           value: {{ (.Values.routing).negotiationType | default "PLAINTEXT" }}
         {{- end }}
-        {{- with (.Values.env).customList }}
+        {{- with (.Values.env).customVarsLocal }}
+{{ toYaml . | indent 8 }}
+        {{- end }}
+        {{- with (.Values.env).customVarsGlobal }}
 {{ toYaml . | indent 8 }}
         {{- end }}
         image: "{{ .Values.image.repo }}/{{ .Values.image.name }}:{{ coalesce (.Values.image).tag "latest" }}"
diff --git a/src/main/helm/values.yaml b/src/main/helm/values.yaml
index 11fdeb4ae..118009532 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 16022898f..8fe0b2bef 100644
--- a/src/test/helm/deployment_env_customList_test.yaml
+++ b/src/test/helm/deployment_env_customList_test.yaml
@@ -29,9 +29,20 @@ set:
   ozgcloud.environment: test
   imagePullSecret: image-pull-secret
 tests:
-  - it: check customList
+  - it: check customVarsLocal
     set:
-      env.customList:
+      env.customVarsLocal:
+        - name: my_test_environment_name
+          value: "A test value"
+    asserts:
+      - contains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: my_test_environment_name
+            value: "A test value"
+  - it: check customVarsGlobal
+    set:
+      env.customVarsGlobal:
         - name: my_test_environment_name
           value: "A test value"
     asserts:
diff --git a/xta-adapter/src/main/helm/templates/network_policy.yaml b/xta-adapter/src/main/helm/templates/network_policy.yaml
index f8261b088..b65e30f07 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 62eac6b1a..7e725ee8a 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
-- 
GitLab