Using an include statement as the default value

3/21/2019

I am creating a helm chart in which I want to specify a default for a value using a template function. Specifically I want to either use the override value image.name, or default to the template function chart.name:

{{ .Values.image.name | default include chart.name . }}

But when linting the chart I have the following error:

[ERROR] templates/: render error in "chart/templates/deployment.yaml": template: chart/templates/deployment.yaml:22:81: executing "chart/templates/deployment.yaml" at <include>: wrong number of args for include: want 2 got 0

Is it possible to use an included template function as the default value? Or can I only use literals?

-- Blokje5
kubernetes-helm

1 Answer

3/22/2019

You can. Just enclose your include statement in parentheses:

{{ .Values.image.name | default (include "chart.name" .)}}

Please see using the default function

-- edbighead
Source: StackOverflow