diff --git a/charts/common/templates/_envFromRef.yaml b/charts/common/templates/_envFromRef.yaml index 57eb3c9..d7cc7cf 100644 --- a/charts/common/templates/_envFromRef.yaml +++ b/charts/common/templates/_envFromRef.yaml @@ -1,21 +1,40 @@ {{- define "common.envFromRef.tpl" -}} -{{- if or (or (or (.Values.vars) (.Values.secretEnabled)) .Values.sealedSecrets) .Values.secretName -}} +{{- if or (or (or (.Values.vars) (.Values.secretEnabled) (.Values.envFrom)) .Values.sealedSecrets) .Values.secretName -}} envFrom: &envFrom {{- if .Values.vars }} - configMapRef: name: {{ template "common.robustName" .Release.Name }} {{- end }} +{{- if .Values.envFrom }} + +{{- range .Values.envFrom.existingSecrets }} + - secretRef: + name: {{ .name }} + optional: {{ .optional }} +{{- end }} + +{{- range .Values.envFrom.existingConfigMaps }} + - configMapRef: + name: {{ .name }} + optional: {{ .optional }} +{{- end }} +{{- end }} + {{- if .Values.secretEnabled }} - secretRef: name: {{ include "common.robustName" $.Release.Name }} {{- end }} + + {{- if .Values.secretName }} - secretRef: name: {{ .Values.secretName }} {{- end }} + {{- if .Values.sealedSecrets }} - secretRef: name: {{ template "common.robustName" .Release.Name }} {{- end }} + {{- end }} {{- end }} \ No newline at end of file diff --git a/charts/cron-job/charts/common-0.3.1.tgz b/charts/cron-job/charts/common-0.3.1.tgz index 5fb517d..854f9c0 100644 Binary files a/charts/cron-job/charts/common-0.3.1.tgz and b/charts/cron-job/charts/common-0.3.1.tgz differ diff --git a/charts/onechart/charts/common-0.3.1.tgz b/charts/onechart/charts/common-0.3.1.tgz index 5fb517d..264c4c0 100644 Binary files a/charts/onechart/charts/common-0.3.1.tgz and b/charts/onechart/charts/common-0.3.1.tgz differ diff --git a/charts/onechart/templates/deployment.yaml b/charts/onechart/templates/deployment.yaml index 6a73480..a733250 100644 --- a/charts/onechart/templates/deployment.yaml +++ b/charts/onechart/templates/deployment.yaml @@ -138,7 +138,7 @@ spec: - -c - {{ .Values.sidecar.command | quote }} {{- end }} - {{- if or (or (.Values.vars) (.Values.secretEnabled)) .Values.sealedSecrets }} + {{- if or (or (.Values.vars) (.Values.secretEnabled) (.Values.envFrom)) .Values.sealedSecrets }} envFrom: *envFrom {{- end }} {{- if or (or (.Values.volumes) (.Values.sealedFileSecrets)) .Values.fileSecrets }} diff --git a/charts/onechart/tests/deployment_configmap_test.yaml b/charts/onechart/tests/deployment_configmap_test.yaml index 0869615..8c29ccc 100644 --- a/charts/onechart/tests/deployment_configmap_test.yaml +++ b/charts/onechart/tests/deployment_configmap_test.yaml @@ -14,7 +14,21 @@ tests: content: configMapRef: name: release-name - - it: Should not reference configmap if vars are not set + - it: Should reference to existing configmaps + set: + envFrom: + existingConfigMaps: + - name: firstcm + optional: true + - name: secondcm + optional: true asserts: - - isNull: + - contains: path: spec.template.spec.containers[0].envFrom + content: + configMapRef: + name: firstcm + optional: true + configMapRef: + name: secondcm + optional: true diff --git a/charts/onechart/tests/deployment_secret_test.yaml b/charts/onechart/tests/deployment_secret_test.yaml index 5dfc580..4414e3a 100644 --- a/charts/onechart/tests/deployment_secret_test.yaml +++ b/charts/onechart/tests/deployment_secret_test.yaml @@ -31,3 +31,21 @@ tests: content: secretRef: name: release-name + - it: Should reference to existing secrets + set: + envFrom: + existingSecrets: + - name: firstsecret + optional: true + - name: secondsecret + optional: true + asserts: + - contains: + path: spec.template.spec.containers[0].envFrom + content: + secretRef: + name: firstsecret + optional: true + secretRef: + name: secondsecret + optional: true