使用include语句作为默认值

问题描述 投票:0回答:1

我正在创建一个头盔图表,我想在其中使用模板函数指定值的默认值。具体来说,我想要使用覆盖值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

是否可以使用包含的模板函数作为默认值?或者我可以只使用文字?

kubernetes-helm
1个回答
1
投票

您可以。只需将include语句括在括号中:

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

请参阅using the default function

© www.soinside.com 2019 - 2024. All rights reserved.