我想在读取值文件时传递默认键值。
{{- range $key, $val := .Values.nodeLabel | default map[string]string{"a":"b"}}}
Values.yaml nodeLabel-a:b
但是我也试图通过默认值。
{{- range $key, $val := .Values.nodeLabel | default "b:c"
错误-
range cannot iterate over b:c
最佳答案
请尝试以下方法:
{{- if .Values.nodeLabel -}}
{{- range $key, $val := .Values.nodeLabel }}
{{ $key }}: {{ $val }}
# {{- end }}
{{ else }}
{{ default "b: c" }}
{{- end -}}
附加资源:The Chart Best Practices Guide
希望这个帮助
关于go - 从 Helm 表中的值文件读取值时的默认键值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56933053/