From c4113f493094aad732e55a494c95b03ce27fa9cb Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Fri, 17 Dec 2021 13:59:21 +0100
Subject: [PATCH] OZG-1863: add env.customList for the other apps

---
 README.md                           | 18 ++++++++++++++++++
 templates/deployment.yaml           |  3 +++
 unit-tests/deployment_env_test.yaml | 24 ++++++++++++++++++++++++
 values.yaml                         |  3 +++
 4 files changed, 48 insertions(+)
 create mode 100644 README.md
 create mode 100644 unit-tests/deployment_env_test.yaml

diff --git a/README.md b/README.md
new file mode 100644
index 0000000000..94f5d3343f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,18 @@
+# pluto
+
+Das helm chart zur Installation des allgemeinen Fachverfahrens - goofy.
+
+## FAQ
+
+### 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:
+
+```yaml
+env:
+  customList:
+    - name: Dinge
+      value: true
+    - name: ...
+      value: ...
+```
diff --git a/templates/deployment.yaml b/templates/deployment.yaml
index 57a5bc1041..901208252f 100644
--- a/templates/deployment.yaml
+++ b/templates/deployment.yaml
@@ -53,6 +53,9 @@ spec:
           value: {{ include "app.ssoServerUrl" . }}
         - name: goofy_keycloak_api_password
           value: {{ required "A sso apiPassword is required!" (.Values.sso).apiPassword }}
+        {{- with (.Values.env).customList }}
+{{ toYaml . | indent 8 }}
+        {{- end }}
         image: "docker.ozg-sh.de/goofy:{{ coalesce (.Values.image).tag "latest" }}"
         imagePullPolicy: Always
         name: goofy
diff --git a/unit-tests/deployment_env_test.yaml b/unit-tests/deployment_env_test.yaml
new file mode 100644
index 0000000000..d12a6bd409
--- /dev/null
+++ b/unit-tests/deployment_env_test.yaml
@@ -0,0 +1,24 @@
+suite: test environments
+templates:
+  - templates/deployment.yaml
+tests:
+  - it: check customList
+    template: deployment.yaml
+    set:
+      env.customList:
+        - 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 customList test value is not set by default
+    template: deployment.yaml
+    asserts:
+      - notContains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: my_test_environment_name
+            value: "A test value"
diff --git a/values.yaml b/values.yaml
index 8cb8ed249b..965507f5c5 100644
--- a/values.yaml
+++ b/values.yaml
@@ -13,6 +13,9 @@ imageCredentials:
 
 # env:
 #   springProfiles: "oc,prod" # [default: oc,prod]
+#   customList: # add name value pair for additional environments
+#     - name: Dinge
+#       value: true
 
 # host: # [default: https://<name>.<level>.ozg-sh.de, if level == "prod" https://<name>.ozg-sh.de] optional, host override value. Be aware that XXX.dev.ozg-sh.de can be used in the dev cluster only.
 
-- 
GitLab