kubernetes-helmgo-templates

How to concat string to result of .AsConfig in 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 ?


Solution

  • 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 }}