使用Include语句作为默认值



我正在创建一个掌舵图表,其中我想使用模板函数为值指定值。具体来说,我想使用覆盖值image.name或默认为模板函数图表。名称:

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

但是,当勾勒图表时,我有以下错误:

[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

是否可以将随附的模板函数用作默认值?还是我只能使用文字?

您可以。只需将您的包含在括号中的语句包装:

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

请参阅使用默认函数

最新更新