From db3d3e55c29e413465ec11ae03a6fd1cd7bcff29 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Wed, 6 Nov 2024 12:07:57 +0100
Subject: [PATCH] OZG-6162 OZG-7060 Set values for file-manager in helm

(cherry picked from commit cba636fa1545f7052140caa1b3cdcdd32bb2ffe3)
---
 src/main/helm/templates/_helpers.tpl          |  4 ++
 src/main/helm/templates/deployment.yaml       |  4 ++
 .../helm/deployment_defaults_env_test.yaml    | 23 +++++++++
 ...loyment_file_manager_address_env_test.yaml | 49 +++++++++++++++++++
 4 files changed, 80 insertions(+)
 create mode 100644 src/test/helm/deployment_file_manager_address_env_test.yaml

diff --git a/src/main/helm/templates/_helpers.tpl b/src/main/helm/templates/_helpers.tpl
index 35797e5181..52c43468ed 100644
--- a/src/main/helm/templates/_helpers.tpl
+++ b/src/main/helm/templates/_helpers.tpl
@@ -53,6 +53,10 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }}
 {{ printf "dns:///%s.%s:9090" ( coalesce .Values.vorgangManagerName "vorgang-manager" ) .Release.Namespace | replace "+" "_" | trunc 63 | trimSuffix "-" }}
 {{- end -}}
 
+{{- define "app.grpc_client_file_manager_address" -}}
+{{ printf "dns:///%s.%s:9090" ( coalesce .Values.fileManagerName "vorgang-manager" ) .Release.Namespace | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end -}}
+
 {{- define "app.grpc_client_user-manager_address" -}}
 {{ printf "dns:///%s.%s:9000" ( coalesce .Values.usermanagerName "user-manager" ) .Release.Namespace }}
 {{- end -}}
diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml
index 585408d9e5..345ed3285d 100644
--- a/src/main/helm/templates/deployment.yaml
+++ b/src/main/helm/templates/deployment.yaml
@@ -78,6 +78,10 @@ spec:
           value: {{ include "app.grpc_client_user-manager_address" . }}
         - name: grpc_client_user-manager_negotiationType
           value: {{ (.Values.userManager).grpcClientNegotiationType | default "TLS" }}
+        - name: grpc_client_file-manager_address
+          value: {{ include "app.grpc_client_file_manager_address" . }}
+        - name: grpc_client_file-manager_negotiationType
+          value: {{ (.Values.fileManager).grpcClientNegotiationType | default "TLS" }}
         - name: spring_profiles_active
           value: {{ include "app.envSpringProfiles" . }}
         - name: keycloak_realm
diff --git a/src/test/helm/deployment_defaults_env_test.yaml b/src/test/helm/deployment_defaults_env_test.yaml
index 9bdb30b9dc..fc77a2e11d 100644
--- a/src/test/helm/deployment_defaults_env_test.yaml
+++ b/src/test/helm/deployment_defaults_env_test.yaml
@@ -54,6 +54,11 @@ tests:
           content:
             name: grpc_client_user-manager_address
             value: dns:///user-manager.sh-helm-test:9000
+      - contains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: grpc_client_file-manager_address
+            value: dns:///vorgang-manager.sh-helm-test:9090
 
   - it: should have service binding root
     set:
@@ -150,3 +155,21 @@ tests:
           content:
             name: grpc_client_vorgang-manager_negotiationType
             value: TLS
+
+  - it: should set file-manager negotiationType plaintext
+    set:
+      fileManager.grpcClientNegotiationType: PLAINTEXT
+    asserts:
+      - contains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: grpc_client_file-manager_negotiationType
+            value: PLAINTEXT
+
+  - it: should contain default file-manager negotiationType tls
+    asserts:
+      - contains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: grpc_client_file-manager_negotiationType
+            value: TLS
diff --git a/src/test/helm/deployment_file_manager_address_env_test.yaml b/src/test/helm/deployment_file_manager_address_env_test.yaml
new file mode 100644
index 0000000000..727d639069
--- /dev/null
+++ b/src/test/helm/deployment_file_manager_address_env_test.yaml
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2024 Das Land Schleswig-Holstein vertreten durch den
+# Ministerpräsidenten des Landes Schleswig-Holstein
+# Staatskanzlei
+# Abteilung Digitalisierung und zentrales IT-Management der Landesregierung
+#
+# Lizenziert unter der EUPL, Version 1.2 oder - sobald
+# diese von der Europäischen Kommission genehmigt wurden -
+# Folgeversionen der EUPL ("Lizenz");
+# Sie dürfen dieses Werk ausschließlich gemäß
+# dieser Lizenz nutzen.
+# Eine Kopie der Lizenz finden Sie hier:
+#
+# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
+#
+# Sofern nicht durch anwendbare Rechtsvorschriften
+# gefordert oder in schriftlicher Form vereinbart, wird
+# die unter der Lizenz verbreitete Software "so wie sie
+# ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
+# ausdrücklich oder stillschweigend - verbreitet.
+# Die sprachspezifischen Genehmigungen und Beschränkungen
+# unter der Lizenz sind dem Lizenztext zu entnehmen.
+#
+
+suite: test deployment file-manager address
+release:
+  name: alfa
+  namespace: sh-helm-test
+templates:
+  - templates/deployment.yaml
+set:
+  baseUrl: test.company.local
+  ozgcloud:
+    environment: test
+    bundesland: sh
+    bezeichner: helm
+  sso:
+    serverUrl: https://sso.company.local
+  imagePullSecret: image-pull-secret
+tests:
+  - it: should set the file-manager name
+    set:
+      fileManagerName: my-test-file-manager-name
+    asserts:
+      - contains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: grpc_client_file-manager_address
+            value: dns:///my-test-file-manager-name.sh-helm-test:9090
-- 
GitLab