From ea18736dd580111659f7c2b4d2e1de9479021145 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Wed, 28 Aug 2024 22:05:53 +0200
Subject: [PATCH] OZG-6254 OZG-6484 pvog routing set default neogitationType

---
 src/main/helm/templates/deployment.yaml             |  4 ++--
 src/test/helm/deployment_routing_zufi_test.yaml     | 13 ++++++++-----
 .../main/helm/templates/xta_adapter_cronjob.yaml    |  4 ++--
 .../helm/xta_adapter_cronjob_routing_zufi_test.yaml | 13 ++++++++-----
 4 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml
index 067388e46..c68b9d69b 100644
--- a/src/main/helm/templates/deployment.yaml
+++ b/src/main/helm/templates/deployment.yaml
@@ -85,9 +85,9 @@ spec:
         {{- end }}
         {{- if eq (.Values.routing).routingStrategy "ZUFI" }}
         - name: grpc_client_zufi-manager_address
-          value: {{ required "routing.zufiManager.address must be set when routingStrategy=ZUFI" .Values.routing.zufiManager.address | quote }}
+          value: {{ required "routing.zufiManager.address must be set when routingStrategy=ZUFI" ((.Values.routing).zufiManager).address | quote }}
         - name: grpc_client_zufi-manager_negotiationType
-          value: {{ required "routing.zufiManager.negotiationType must be set when routingStrategy=ZUFI" .Values.routing.zufiManager.negotiationType | quote }}
+          value: {{ ((.Values.routing).zufiManager).negotiationType | default "PLAINTEXT" }}
         {{- end }}
 
         {{- with include "app.getCustomList" . }}
diff --git a/src/test/helm/deployment_routing_zufi_test.yaml b/src/test/helm/deployment_routing_zufi_test.yaml
index 843fbb23e..85c3e1b73 100644
--- a/src/test/helm/deployment_routing_zufi_test.yaml
+++ b/src/test/helm/deployment_routing_zufi_test.yaml
@@ -39,7 +39,7 @@ tests:
         routingStrategy: "ZUFI"
         zufiManager:
           address: "127.0.0.1"
-          negotiationType: "PLAINTEXT"
+          negotiationType: "TLS"
     asserts:
       - contains:
           path: spec.template.spec.containers[0].env
@@ -50,7 +50,7 @@ tests:
           path: spec.template.spec.containers[0].env
           content:
             name: grpc_client_zufi-manager_negotiationType
-            value: "PLAINTEXT"
+            value: "TLS"
   
   - it: should not set zufi routing values when zufi is disabled
     asserts:
@@ -75,12 +75,15 @@ tests:
       - failedTemplate:
           errorMessage: "routing.zufiManager.address must be set when routingStrategy=ZUFI"
 
-  - it: should throw error if zufi manager negotiationType is not set
+  - it: should set default value for zufi negotiationType
     set:
       routing:
         routingStrategy: "ZUFI"
         zufiManager:
           address: "127.0.0.1"
     asserts:
-      - failedTemplate:
-          errorMessage: "routing.zufiManager.negotiationType must be set when routingStrategy=ZUFI"
\ No newline at end of file
+      - contains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: grpc_client_zufi-manager_negotiationType
+            value: "PLAINTEXT"
\ No newline at end of file
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 89a7a16d2..3835e3ec4 100644
--- a/xta-adapter/src/main/helm/templates/xta_adapter_cronjob.yaml
+++ b/xta-adapter/src/main/helm/templates/xta_adapter_cronjob.yaml
@@ -87,9 +87,9 @@ spec:
                 {{- end }}
                 {{- if eq (.Values.routing).routingStrategy "ZUFI" }}
                 - name: grpc_client_zufi-manager_address
-                  value: {{ required "routing.zufiManager.address must be set when routingStrategy=ZUFI" .Values.routing.zufiManager.address | quote }}
+                  value: {{ required "routing.zufiManager.address must be set when routingStrategy=ZUFI" ((.Values.routing).zufiManager).address | quote }}
                 - name: grpc_client_zufi-manager_negotiationType
-                  value: {{ required "routing.zufiManager.negotiationType must be set when routingStrategy=ZUFI" .Values.routing.zufiManager.negotiationType | quote }}
+                  value: {{ ((.Values.routing).zufiManager).negotiationType | default "PLAINTEXT" }}
                 {{- end }}
                 {{- with include "app.getCustomList" . }}
 {{ . | indent 16 }}
diff --git a/xta-adapter/src/test/helm/xta_adapter_cronjob_routing_zufi_test.yaml b/xta-adapter/src/test/helm/xta_adapter_cronjob_routing_zufi_test.yaml
index 80042aafb..1414a4e82 100644
--- a/xta-adapter/src/test/helm/xta_adapter_cronjob_routing_zufi_test.yaml
+++ b/xta-adapter/src/test/helm/xta_adapter_cronjob_routing_zufi_test.yaml
@@ -38,7 +38,7 @@ tests:
         routingStrategy: "ZUFI"
         zufiManager:
           address: "127.0.0.1"
-          negotiationType: "PLAINTEXT"
+          negotiationType: "TLS"
     asserts:
       - contains:
           path: spec.jobTemplate.spec.template.spec.containers[0].env
@@ -49,7 +49,7 @@ tests:
           path: spec.jobTemplate.spec.template.spec.containers[0].env
           content:
             name: grpc_client_zufi-manager_negotiationType
-            value: "PLAINTEXT"
+            value: "TLS"
   
   - it: should not set zufi routing values when zufi is disabled
     asserts:
@@ -74,12 +74,15 @@ tests:
       - failedTemplate:
           errorMessage: "routing.zufiManager.address must be set when routingStrategy=ZUFI"
 
-  - it: should throw error if zufi manager negotiationType is not set
+  - it: should set default value for zufi negotiationType
     set:
       routing:
         routingStrategy: "ZUFI"
         zufiManager:
           address: "127.0.0.1"
     asserts:
-      - failedTemplate:
-          errorMessage: "routing.zufiManager.negotiationType must be set when routingStrategy=ZUFI"
\ No newline at end of file
+      - contains:
+          path: spec.jobTemplate.spec.template.spec.containers[0].env
+          content:
+            name: grpc_client_zufi-manager_negotiationType
+            value: "PLAINTEXT"
\ No newline at end of file
-- 
GitLab