From 7d46b5f5017bca0c7aa680fd35aa342f52c3090b Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Tue, 21 May 2024 10:35:38 +0200
Subject: [PATCH] ozg-3938 add bindings type

---
 .../templates/bindings_type_configmap.yaml    |  8 ++++
 src/main/helm/templates/deployment.yaml       |  2 +-
 src/test/helm/bindings_type_test.yaml         | 46 +++++++++++++++++++
 src/test/helm/deployment_bindings_test.yaml   | 28 +++++++++++
 4 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 src/main/helm/templates/bindings_type_configmap.yaml
 create mode 100644 src/test/helm/bindings_type_test.yaml

diff --git a/src/main/helm/templates/bindings_type_configmap.yaml b/src/main/helm/templates/bindings_type_configmap.yaml
new file mode 100644
index 000000000..8e4fbacef
--- /dev/null
+++ b/src/main/helm/templates/bindings_type_configmap.yaml
@@ -0,0 +1,8 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ .Release.Name }}-bindings-type
+  namespace: {{ include "app.namespace" . }}
+data:
+  type: |
+    ca-certificates
\ No newline at end of file
diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml
index f32fad253..b3bfd90e1 100644
--- a/src/main/helm/templates/deployment.yaml
+++ b/src/main/helm/templates/deployment.yaml
@@ -168,7 +168,7 @@ spec:
                   - key: ca.crt
                     path: ca.crt
             - configMap:
-                name: bindings-type
+                name: {{ .Release.Name }}-bindings-type
       dnsConfig: {}
       dnsPolicy: ClusterFirst
       imagePullSecrets:
diff --git a/src/test/helm/bindings_type_test.yaml b/src/test/helm/bindings_type_test.yaml
new file mode 100644
index 000000000..f0fa5ade3
--- /dev/null
+++ b/src/test/helm/bindings_type_test.yaml
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2022 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 bindings type configmap
+templates:
+  - templates/bindings_type_configmap.yaml
+release:
+  name: eingang-manager
+  namespace: sh-helm-test
+tests:
+  - it: xta bindings type
+    asserts:
+      - isKind:
+          of: ConfigMap
+      - isAPIVersion:
+          of: v1
+      - equal:
+          path: metadata.name
+          value: eingang-manager-bindings-type
+      - equal:
+          path: metadata.namespace
+          value: sh-helm-test
+      - equal:
+          path: data.type
+          value: ca-certificates
diff --git a/src/test/helm/deployment_bindings_test.yaml b/src/test/helm/deployment_bindings_test.yaml
index 6e48055b0..f4e0f24ea 100644
--- a/src/test/helm/deployment_bindings_test.yaml
+++ b/src/test/helm/deployment_bindings_test.yaml
@@ -25,6 +25,9 @@
 suite: deployment bindings
 templates:
   - templates/deployment.yaml
+release:
+  name: eingang-manager
+  namespace: sh-helm-test
 set:
   ozgcloud.environment: test
   imagePullSecret: image-pull-secret
@@ -45,3 +48,28 @@ tests:
             name: temp-dir
             emptyDir: {}
 
+  - it: should have projected namespace-ca-cert volume
+    asserts:
+      - contains:
+          path: spec.template.spec.volumes
+          content:
+            name: namespace-ca-cert
+            projected:
+              sources:
+              - secret:
+                  name: sh-helm-test-ca-cert
+                  optional: true
+                  items:
+                    - key: ca.crt
+                      path: ca.crt
+              - configMap:
+                  name: eingang-manager-bindings-type
+
+  - it: should have namespace-ca-cert volume mount
+    asserts:
+      - contains:
+          path: spec.template.spec.containers[0].volumeMounts
+          content:
+            name: namespace-ca-cert
+            mountPath: "/bindings/namespace-certificate"
+            readOnly: true
\ No newline at end of file
-- 
GitLab