英文:
How to concat string to result of .AsConfig in helm?
问题
我有这样的配置:
{{- with .Files.Glob "files/my-files/*.json" }}
{{ .AsConfig | indent 2 }}
{{- end }}
我想在每个文件的末尾添加"FINISHED!",在Helm中该如何实现?
英文:
I have config like this:
{{- with .Files.Glob "files/my-files/*.json" }}
{{ .AsConfig | indent 2 }}
{{- end }}
In the end of each file I want to add "FIHISHED!"
How can I achieve it in helm ?
答案1
得分: 1
.AsConfig
方法将所有文件渲染并返回为单个 YAML 文本。因此,您无法格式化结果。
如果您想要列出所有文件(包括内容),并用任意文本分隔,我建议您自己来做。Files
是一个文件映射,将字符串名称映射到 []byte
内容。
{{- with .Files.Glob "files/my-files/*.json" }}
{{ range $name, $content := . -}}
{{ printf "-%s:\n%s\nFINISHED!" $name $content | indent 2 }}:
{{- end }}
{{- end }}
英文:
The .AsConfig
method renders and returns all files as a single YAML text. So you can't format the result.
If you want to list all files (with content), separated with an arbitrary text, I suggest to do this "yourself". Files
is a map of files, mapping from string name to []byte
content.
{{- with .Files.Glob "files/my-files/*.json" }}
{{ range $name, $content := . -}}
{{ printf "-%s:\n%s\nFINISHED!" $name $content | indent 2 }}:
{{- end }}
{{- end }}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论