From a4ec1a581f27c2bdeed19d4468f33c040ef9951b Mon Sep 17 00:00:00 2001
From: Felix Reichenbach <felix.reichenbach@mgm-tp.com>
Date: Mon, 24 Mar 2025 09:00:57 +0100
Subject: [PATCH] OZG-7573 set grpc port conditional

---
 src/main/helm/templates/service.yaml |  2 ++
 src/test/helm/service_test.yaml      | 18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/main/helm/templates/service.yaml b/src/main/helm/templates/service.yaml
index 80b44f3d..a85dbf18 100644
--- a/src/main/helm/templates/service.yaml
+++ b/src/main/helm/templates/service.yaml
@@ -32,9 +32,11 @@ metadata:
     component: eingang-adapter-service
 spec:
   ports:
+  {{- if (.Values.forwarding).enabled }}
     - name: grpc-9090
       port: 9090
       protocol: TCP
+  {{- end }}
     - name: http
       port: 8080
       protocol: TCP
diff --git a/src/test/helm/service_test.yaml b/src/test/helm/service_test.yaml
index 0f7db44d..41a970a9 100644
--- a/src/test/helm/service_test.yaml
+++ b/src/test/helm/service_test.yaml
@@ -49,7 +49,10 @@ tests:
       - equal:
           path: spec.type
           value: ClusterIP
-  - it: ports should contain the grpc port
+  - it: should contain the grpc port in the ports list if forwarding enabled
+    set:
+      forwarding:
+        enabled: true
     asserts:
       - contains:
           path: spec.ports
@@ -59,6 +62,19 @@ tests:
             protocol: TCP
           count: 1
           any: true
+  - it: should not contain the grpc port in the ports list if forwarding disabled
+    set:
+      forwarding:
+        enabled: false
+    asserts:
+      - notContains:
+          path: spec.ports
+          content:
+            name: grpc-9090
+            port: 9090
+            protocol: TCP
+          count: 1
+          any: true
   - it: ports should contain the 8080 default http port
     asserts:
       - contains:
-- 
GitLab