From 9d8f995778136d88ebc7dfd2b0803d852df04b93 Mon Sep 17 00:00:00 2001
From: Arie Peterson <arie@greenhost.nl>
Date: Tue, 30 Jan 2024 16:03:46 +0100
Subject: [PATCH] Fix deployment helm/yaml indentation

---
 deployment/helmchart/CHANGELOG.md             |  6 ++
 .../templates/backend-deployment.yaml         | 70 ++++++++++---------
 .../templates/frontend-deployment.yaml        | 52 +++++++-------
 3 files changed, 69 insertions(+), 59 deletions(-)

diff --git a/deployment/helmchart/CHANGELOG.md b/deployment/helmchart/CHANGELOG.md
index 2bc52034..e08e22e2 100644
--- a/deployment/helmchart/CHANGELOG.md
+++ b/deployment/helmchart/CHANGELOG.md
@@ -1,5 +1,11 @@
 # Changelog
 
+## Unreleased
+
+* Fix indentation of helm/yaml syntax in the split deployments, specifically in
+  the case of non-empty extraEnvVars.
+* Update dashboard to version 0.9.1.
+
 ## [1.9.0]
 
 * Update dashboard to version 0.9.0.
diff --git a/deployment/helmchart/templates/backend-deployment.yaml b/deployment/helmchart/templates/backend-deployment.yaml
index 1f76d33b..fef36b1f 100644
--- a/deployment/helmchart/templates/backend-deployment.yaml
+++ b/deployment/helmchart/templates/backend-deployment.yaml
@@ -13,15 +13,17 @@ metadata:
 spec:
   replicas: {{ .Values.replicaCount }}
   selector:
-    matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
+    matchLabels:
       component: dashboard-backend
+      {{- include "common.labels.matchLabels" . | nindent 6 }}
   {{- if .Values.updateStrategy }}
   strategy: {{- toYaml .Values.updateStrategy | nindent 4 }}
   {{- end }}
   template:
     metadata:
-      labels: {{- include "common.labels.standard" . | nindent 8 }}
+      labels:
         component: dashboard-backend
+        {{- include "common.labels.standard" . | nindent 8 }}
         {{- if .Values.podLabels }}
         {{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
         {{- end }}
@@ -55,38 +57,38 @@ spec:
         {{- end }}
       containers:
       - name: backend
-        securityContext: {{- toYaml .Values.backend.containerSecurityContext | nindent 12 }}
+        securityContext: {{- toYaml .Values.backend.containerSecurityContext | nindent 10 }}
         image: {{ template "backend.image" . }}
         imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
         {{- if .Values.backend.command }}
-        command: {{- include "common.tplvalues.render" (dict "value" .Values.backend.command "context" $) | nindent 12 }}
+        command: {{- include "common.tplvalues.render" (dict "value" .Values.backend.command "context" $) | nindent 10 }}
         {{- end }}
         {{- if .Values.backend.args }}
-        args: {{- include "common.tplvalues.render" (dict "value" .Values.backend.args "context" $) | nindent 12 }}
+        args: {{- include "common.tplvalues.render" (dict "value" .Values.backend.args "context" $) | nindent 10 }}
         {{- end }}
         env:
-          - name: DASHBOARD_PASSWORD
-            valueFrom:
-              secretKeyRef:
-                name: {{ include "backend.secretName" . }}
-                key: backend-password
-          - name: HYDRA_CLIENT_SECRET
-            valueFrom:
-              secretKeyRef:
-                name: {{ include "backend.secretName" . }}
-                key: oidc-client-secret
-          - name: KRATOS_URL
-            value: {{ .Values.backend.kratos.adminUrl }}
-          {{- if (include "backend.smtp.password.enabled" .) }}
-          - name: DASHBOARD_SMTP_PASSWORD
-            valueFrom:
-              secretKeyRef:
-                name: {{ include "backend.smtp.secretName" . }}
-                key: smtp-password
-          {{- end }}
-          {{- if .Values.backend.extraEnvVars }}
-          {{- include "common.tplvalues.render" (dict "value" .Values.backend.extraEnvVars "context" $) | nindent 12 }}
-          {{- end }}
+        - name: DASHBOARD_PASSWORD
+          valueFrom:
+            secretKeyRef:
+              name: {{ include "backend.secretName" . }}
+              key: backend-password
+        - name: HYDRA_CLIENT_SECRET
+          valueFrom:
+            secretKeyRef:
+              name: {{ include "backend.secretName" . }}
+              key: oidc-client-secret
+        - name: KRATOS_URL
+          value: {{ .Values.backend.kratos.adminUrl }}
+        {{- if (include "backend.smtp.password.enabled" .) }}
+        - name: DASHBOARD_SMTP_PASSWORD
+          valueFrom:
+            secretKeyRef:
+              name: {{ include "backend.smtp.secretName" . }}
+              key: smtp-password
+        {{- end }}
+        {{- if .Values.backend.extraEnvVars }}
+        {{- include "common.tplvalues.render" (dict "value" .Values.backend.extraEnvVars "context" $) | nindent 8 }}
+        {{- end }}
         envFrom:
           - configMapRef:
               name: {{ include "common.names.fullname" . }}
@@ -113,7 +115,7 @@ spec:
           successThreshold: {{ .Values.backend.livenessProbe.successThreshold }}
           failureThreshold: {{ .Values.backend.livenessProbe.failureThreshold }}
         {{- else if .Values.backend.customLivenessProbe }}
-        livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.backend.customLivenessProbe "context" $) | nindent 12 }}
+        livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.backend.customLivenessProbe "context" $) | nindent 10 }}
         {{- end }}
         {{- if .Values.backend.readinessProbe.enabled }}
         readinessProbe:
@@ -126,18 +128,18 @@ spec:
           successThreshold: {{ .Values.backend.readinessProbe.successThreshold }}
           failureThreshold: {{ .Values.backend.readinessProbe.failureThreshold }}
         {{- else if .Values.backend.customReadinessProbe }}
-        readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.backend.customReadinessProbe "context" $) | nindent 12 }}
+        readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.backend.customReadinessProbe "context" $) | nindent 10 }}
         {{- end }}
         volumeMounts:
           {{- if .Values.backend.extraVolumeMounts }}
-          {{- include "common.tplvalues.render" (dict "value" .Values.backend.extraVolumeMounts "context" $) | nindent 12 }}
+          {{- include "common.tplvalues.render" (dict "value" .Values.backend.extraVolumeMounts "context" $) | nindent 10 }}
           {{- end }}
         {{- if .Values.backend.resources }}
-        resources: {{- toYaml .Values.backend.resources | nindent 12 }}
-        {{- end }}
-        {{- if .Values.sidecars }}
-        {{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }}
+        resources: {{- toYaml .Values.backend.resources | nindent 10 }}
         {{- end }}
+      {{- if .Values.sidecars }}
+      {{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 6 }}
+      {{- end }}
       volumes:
         {{- if .Values.extraVolumes }}
         {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
diff --git a/deployment/helmchart/templates/frontend-deployment.yaml b/deployment/helmchart/templates/frontend-deployment.yaml
index 41cc3603..da066b7e 100644
--- a/deployment/helmchart/templates/frontend-deployment.yaml
+++ b/deployment/helmchart/templates/frontend-deployment.yaml
@@ -2,8 +2,9 @@ apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
 kind: Deployment
 metadata:
   name: {{ template "common.names.fullname" . }}-frontend
-  labels: {{- include "common.labels.standard" . | nindent 4 }}
+  labels:
     component: dashboard-frontend
+    {{- include "common.labels.standard" . | nindent 4 }}
     {{- if .Values.commonLabels }}
     {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
     {{- end }}
@@ -20,8 +21,9 @@ spec:
   {{- end }}
   template:
     metadata:
-      labels: {{- include "common.labels.standard" . | nindent 8 }}
+      labels:
         component: dashboard-frontend
+        {{- include "common.labels.standard" . | nindent 8 }}
         {{- if .Values.podLabels }}
         {{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
         {{- end }}
@@ -55,30 +57,30 @@ spec:
         {{- end }}
       containers:
       - name: dashboard-frontend
-        securityContext: {{- toYaml .Values.dashboard.containerSecurityContext | nindent 12 }}
+        securityContext: {{- toYaml .Values.dashboard.containerSecurityContext | nindent 10 }}
         image: {{ template "dashboard.image" . }}
         imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
         {{- if .Values.dashboard.command }}
-        command: {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.command "context" $) | nindent 12 }}
+        command: {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.command "context" $) | nindent 10 }}
         {{- end }}
         {{- if .Values.dashboard.args }}
-        args: {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.args "context" $) | nindent 12 }}
+        args: {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.args "context" $) | nindent 10 }}
         {{- end }}
         env:
-          {{- if .Values.dashboard.extraEnvVars }}
-          {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.extraEnvVars "context" $) | nindent 12 }}
-          {{- end }}
+        {{- if .Values.dashboard.extraEnvVars }}
+        {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.extraEnvVars "context" $) | nindent 10 }}
+        {{- end }}
         envFrom:
-          - configMapRef:
-              name: {{ include "common.names.fullname" . }}
-          {{- if .Values.dashboard.extraEnvVarsCM }}
-          - configMapRef:
-              name: {{ .Values.dashboard.extraEnvVarsCM }}
-          {{- end }}
-          {{- if .Values.dashboard.extraEnvVarsSecret }}
-          - secretRef:
-              name: {{ .Values.dashboard.extraEnvVarsSecret }}
-          {{- end }}
+        - configMapRef:
+            name: {{ include "common.names.fullname" . }}
+        {{- if .Values.dashboard.extraEnvVarsCM }}
+        - configMapRef:
+            name: {{ .Values.dashboard.extraEnvVarsCM }}
+        {{- end }}
+        {{- if .Values.dashboard.extraEnvVarsSecret }}
+        - secretRef:
+            name: {{ .Values.dashboard.extraEnvVarsSecret }}
+        {{- end }}
         ports:
           - name: dashboard-http
             containerPort: 80
@@ -94,7 +96,7 @@ spec:
           successThreshold: {{ .Values.dashboard.livenessProbe.successThreshold }}
           failureThreshold: {{ .Values.dashboard.livenessProbe.failureThreshold }}
         {{- else if .Values.dashboard.customLivenessProbe }}
-        livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.customLivenessProbe "context" $) | nindent 12 }}
+        livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.customLivenessProbe "context" $) | nindent 10 }}
         {{- end }}
         {{- if .Values.dashboard.readinessProbe.enabled }}
         readinessProbe:
@@ -107,18 +109,18 @@ spec:
           successThreshold: {{ .Values.dashboard.readinessProbe.successThreshold }}
           failureThreshold: {{ .Values.dashboard.readinessProbe.failureThreshold }}
         {{- else if .Values.dashboard.customReadinessProbe }}
-        readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.customReadinessProbe "context" $) | nindent 12 }}
+        readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.customReadinessProbe "context" $) | nindent 10 }}
         {{- end }}
         volumeMounts:
           {{- if .Values.dashboard.extraVolumeMounts }}
-          {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.extraVolumeMounts "context" $) | nindent 12 }}
+          {{- include "common.tplvalues.render" (dict "value" .Values.dashboard.extraVolumeMounts "context" $) | nindent 10 }}
           {{- end }}
         {{- if .Values.dashboard.resources }}
-        resources: {{- toYaml .Values.dashboard.resources | nindent 12 }}
-        {{- end }}
-        {{- if .Values.sidecars }}
-        {{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }}
+        resources: {{- toYaml .Values.dashboard.resources | nindent 10 }}
         {{- end }}
+      {{- if .Values.sidecars }}
+      {{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 6 }}
+      {{- end }}
       volumes:
         {{- if .Values.extraVolumes }}
         {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
-- 
GitLab