I have top level chart and one of the subcharts. In subchart I want to use variables that defined in level chart, and if it is not found - use default value.
I have code like this in one of deployment definitions in my subchart
name: {{tpl .Values.global.my.GlobalValue .}}
where Values.global.my.GlobalValue - is parameter from top level chart.
Problem is when I try to install only subchart - I am failing, I need some defaults.
I tried to puth like below and it is not working
name: {{default defaultName tpl .Values.global.my.GlobalValue .}}
name: {{tpl .Values.global.my.GlobalValue . | defaultName}}
Could you please advise the correct way to do that.
As per Using the default function:
One function frequently used in templates is the
default
function:default DEFAULT_VALUE GIVEN_VALUE
. This function allows you to specify a default value inside of the template, in case the value is omitted.
You should use:
name: {{ .Values.global.my.GlobalValue | default "defaultName" | quote }}