From 9ffd57b5105d5aa3fc8750c8a5100eb31c0dd948 Mon Sep 17 00:00:00 2001 From: Hayden Spitzley <105455169+hspitzley-czi@users.noreply.github.com> Date: Wed, 22 May 2024 13:49:10 -0600 Subject: [PATCH] fix: make nonsensitive env var injection work (#22) --- stack/templates/_helpers.tpl | 21 ++++++++++++--------- stack/templates/deployment.yaml | 5 +++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/stack/templates/_helpers.tpl b/stack/templates/_helpers.tpl index 5828b3e..c2c186a 100644 --- a/stack/templates/_helpers.tpl +++ b/stack/templates/_helpers.tpl @@ -84,15 +84,6 @@ Create the name of the service account to use {{- end }} {{- define "service.configuration" -}} - -{{- if .Values.env }} -env: -{{- range $i, $value := .Values.env }} -- name: {{ $value.name }} - value: {{ $value.value }} -{{- end }} -{{- end }} - {{- if or (or (or (ne (trim .Values.appSecrets.envSecret.secretName) "") (ne (trim .Values.appSecrets.envSecret.secretName) "")) (ne (trim .Values.appContext.envContextConfigMapName) "")) (ne (trim .Values.appContext.stackContextConfigMapName) "") -}} envFrom: {{- if ne (trim .Values.appSecrets.envSecret.secretName) "" }} @@ -116,4 +107,16 @@ envFrom: optional: true {{- end }} {{- end }} +{{- end }} + +{{- define "service.nonsensitiveEnvVars" -}} +{{- if .Values.env }} +env: +{{- range $i, $value := .Values.env }} +- name: {{ $value.name }} + value: {{ $value.value }} +{{- end }} +{{- else }} +env: [] +{{- end }} {{- end }} \ No newline at end of file diff --git a/stack/templates/deployment.yaml b/stack/templates/deployment.yaml index 6c21c94..12f0bb4 100644 --- a/stack/templates/deployment.yaml +++ b/stack/templates/deployment.yaml @@ -75,6 +75,11 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} {{- include "service.configuration" . | nindent 10}} + {{- $env := concat $global.Values.global.env (fromYaml (include "service.nonsensitiveEnvVars" .)).env }} + {{- if $env }} + env: + {{- toYaml (uniq $env) | nindent 12}} + {{- end }} {{- range $i, $container := .Values.sidecars }} {{- with omit $container "envFrom" }} - {{- toYaml . | nindent 10 }}