Skip to content

Commit

Permalink
The helm chart says it evaluates extraEnvVars but it was not actually…
Browse files Browse the repository at this point in the history
… doing so (#6718)

* The helm chart says it evaluates extraEnvVars (similar to how bitnami charts do), but it was not actually doing so
  • Loading branch information
orangewolf authored Feb 29, 2024
1 parent e9141b8 commit 8c47b1e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
38 changes: 38 additions & 0 deletions chart/hyrax/templates/_tmplvalues.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{/*
Copyright VMware, Inc.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{/* vim: set filetype=mustache: */}}
{{/*
Renders a value that contains template perhaps with scope if the scope is present.
Usage:
{{ include "hyrax.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ ) }}
{{ include "hyrax.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }}
*/}}
{{- define "hyrax.tplvalues.render" -}}
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
{{- if contains "{{" (toJson .value) }}
{{- if .scope }}
{{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
{{- else }}
{{- tpl $value .context }}
{{- end }}
{{- else }}
{{- $value }}
{{- end }}
{{- end -}}

{{/*
Merge a list of values that contains template after rendering them.
Merge precedence is consistent with http://masterminds.github.io/sprig/dicts.html#merge-mustmerge
Usage:
{{ include "hyrax.tplvalues.merge" ( dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $ ) }}
*/}}
{{- define "hyrax.tplvalues.merge" -}}
{{- $dst := dict -}}
{{- range .values -}}
{{- $dst = include "hyrax.tplvalues.render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml | merge $dst -}}
{{- end -}}
{{ $dst | toYaml }}
{{- end -}}
8 changes: 6 additions & 2 deletions chart/hyrax/templates/deployment-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ spec:
- secretRef:
name: {{ template "hyrax.fullname" . }}
env:
{{- toYaml .Values.worker.extraEnvVars | nindent 12 }}
{{- if .Values.extraEnvVars }}
{{- include "hyrax.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
command:
- sh
- -c
Expand Down Expand Up @@ -63,7 +65,9 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
env:
{{- toYaml .Values.worker.extraEnvVars | nindent 12 }}
{{- if .Values.extraEnvVars }}
{{- include "hyrax.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.worker.readinessProbe.enabled }}
readinessProbe:
exec:
Expand Down
12 changes: 9 additions & 3 deletions chart/hyrax/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ spec:
name: {{ .Values.solrExistingSecret }}
{{- end }}
env:
{{- toYaml .Values.extraEnvVars | nindent 12 }}
{{- if .Values.extraEnvVars }}
{{- include "hyrax.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
command:
- sh
- -c
Expand Down Expand Up @@ -66,7 +68,9 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
env:
{{- toYaml .Values.extraEnvVars | nindent 12 }}
{{- if .Values.extraEnvVars }}
{{- include "hyrax.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
command:
- sh
- -c
Expand Down Expand Up @@ -101,7 +105,9 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
env:
{{- toYaml .Values.extraEnvVars | nindent 12 }}
{{- if .Values.extraEnvVars }}
{{- include "hyrax.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 3000
Expand Down

0 comments on commit 8c47b1e

Please sign in to comment.