Skip to content

Commit

Permalink
fix: make nonsensitive env var injection work (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
hspitzley-czi authored May 22, 2024
1 parent 197edd7 commit 9ffd57b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
21 changes: 12 additions & 9 deletions stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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) "" }}
Expand All @@ -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 }}
5 changes: 5 additions & 0 deletions stack/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 9ffd57b

Please sign in to comment.