【发布时间】:2022-11-24 07:23:16
【问题描述】:
我想知道是否有更有效的方法来排除任何没有设置值的 yaml 键。 我目前的方法是将每个键包装在一个 if 语句中......
container:
spec:
{{- if values.spec.x }}
x: {{ values.spec.x }}
{{- end}}
{{- if values.spec.y }}
y: {{ values.spec.y }}
{{- end}}
{{- if values.spec.z }}
z: {{ values.spec.z }}
{{- end}}
例如
for each child of container.spec:
if the value != null:
include as child of spec
else:
exclude from spec
我考虑过将上面的内容包装在 _helper.tpl 函数中以尝试保持主模板整洁,但它仍然包括编写多个 if 语句。
有没有更好的方法来做上面的事情? 谢谢!
【问题讨论】:
标签: kubernetes-helm go-templates