我正在创建一个头盔图表,我想在其中使用模板函数指定值的默认值。具体来说,我想要使用覆盖值image.name,或者默认使用模板函数chart.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
是否可以使用包含的模板函数作为默认值?或者我可以只使用文字?
您可以。只需将include语句括在括号中:
{{ .Values.image.name | default (include "chart.name" .)}}