I would like to overwrite the user template with .Values.userTemplate
if it exist. But I always get $user
as undefined
when the .Vaues.userTemplate
exist. If i remove if
condition and use {{- $user := tpl .Values.userTemplate . -}}
, it gives right value. But inside if
codition it is not setting the value for $user
.
Is there anything was doing wrong? Was the scope of $user
will be only retained inside the if
condition? Was there a way to overwrite the $user
if .Values.userTemplate
exist.
# values
user: "default"
# somewhere in other chart we define the template
userTemplate: {{ include "username" . }}
# template
{{- define "user" -}}
{{- if .Values.userTemplate -}}
{{- $user := tpl .Values.userTemplate . -}}
{{- else -}}
{{- $user := .Values.user -}}
{{- end -}}
{{- $user -}}
# output of `{{ template "user" . }}` should be the value set in `{{ template "username" . }} in different chart.
Tom