From 6a9f43e0752dfd61841b5d2e25b6135dc25135ac Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Thu, 1 Apr 2021 09:33:42 +0200 Subject: [PATCH] Flattening secret.enabled to secretEnabled to follow Helm best practices; Also supporting custom names --- charts/onechart/templates/deployment.yaml | 4 ++-- charts/onechart/tests/deployment_secret_test.yaml | 14 ++++++++++++-- charts/onechart/values.yaml | 3 +-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/charts/onechart/templates/deployment.yaml b/charts/onechart/templates/deployment.yaml index 445bd0e..e9e7591 100644 --- a/charts/onechart/templates/deployment.yaml +++ b/charts/onechart/templates/deployment.yaml @@ -43,9 +43,9 @@ spec: - configMapRef: name: {{ template "robustName" .Release.Name }} {{- end }} - {{- if .Values.secret.enabled }} + {{- if .Values.secretEnabled }} - secretRef: - name: {{ template "robustName" .Release.Name }} + name: {{ .Values.secretName | default (include "robustName" $.Release.Name) }} {{- end }} {{- if .Values.sealedSecrets }} - secretRef: diff --git a/charts/onechart/tests/deployment_secret_test.yaml b/charts/onechart/tests/deployment_secret_test.yaml index a65324f..b4256fe 100644 --- a/charts/onechart/tests/deployment_secret_test.yaml +++ b/charts/onechart/tests/deployment_secret_test.yaml @@ -5,7 +5,7 @@ templates: tests: - it: Should reference secret if secret is enabled set: - secret.enabled: true + secretEnabled: true asserts: - contains: path: spec.template.spec.containers[0].envFrom @@ -14,10 +14,20 @@ tests: name: release-name - it: Should not reference secret if secret is disabled set: - secret.enabled: false + secretEnabled: false asserts: - isNull: path: spec.template.spec.containers[0].envFrom + - it: Should not reference secret if secret is disabled + set: + secretEnabled: true + secretName: my-custom-secret + asserts: + - contains: + path: spec.template.spec.containers[0].envFrom + content: + secretRef: + name: my-custom-secret - it: Should reference secret if sealedSecrets is set set: sealedSecrets: diff --git a/charts/onechart/values.yaml b/charts/onechart/values.yaml index 06e1759..da8b4b6 100644 --- a/charts/onechart/values.yaml +++ b/charts/onechart/values.yaml @@ -40,8 +40,7 @@ probe: timeoutSeconds: 3 failureThreshold: 3 -secret: - enabled: false +secretEnabled: false shell: "/bin/sh"