我正在使用helmfile进行 helm 发布。
我有一个 yaml 文件projects.yaml
# projects.yaml
- yako
- pera
- okta
在values.yaml.gotmpl中,我想遍历projects.yaml的内容:
# values.yaml.gotmpl
{{ $projects := readFile 'projects.yaml' }}
{{ range $_, $project := $projects }}
# do something with $project . e.g: tpl (readFile 'proj-config.yaml') (dict $name $project)
{{ end}}
不幸的是,我收到了这个错误:
failed to render [values.yaml.gotmpl], because of template: stringTemplate:60:41:
executing "stringTemplate" at <$projects>: range can't iterate over projects:
- yako
- pera
- okta
我做了很多盲目的尝试来让它发挥作用:
{{ range $_, $project := $projects | fromYaml }}
{{ range $_, $project := $projects | toYaml }}
{{ range $_, $project := $projects | list }}
没门