Open
Description
First, https://helm.sh/docs/chart_template_guide/builtin_objects/ says:
Files.Glob is a function that returns a list of files whose names match the given shell glob pattern
Second, https://helm.sh/docs/chart_template_guide/accessing_files/#glob-patterns says:
.Glob returns a Files type, so you may call any of the Files methods on the returned object.
Also, some examples are given, one of them:
{{ range $path, $_ := .Files.Glob "**.yaml" }}
{{ $.Files.Get $path }}
{{ end }}
Third, looking at the source code https://github.com/helm/helm/blob/main/pkg/engine/files.go#L71-L88 in the Glob function doc, a similar example is given:
// {{ range $name, $content := .Files.Glob("foo/**") }}
// {{ $name }}: |
// {{ .Files.Get($name) | indent 4 }}{{ end }}
My comments are:
- It should be clear what Files.Glob is returning: list, map, object, etc. Each documentation page is inconsistent with the others, so much so that I had to look into the source code to determine what Files.Glob actually returns
- If Files.Glob returns a name:content map, why not use content directly, instead of using .Files.Get($name) like:
// {{ range $name, $content := .Files.Glob("foo/**") }}
// {{ $name }}: |
// {{ $content | toString | indent 4 }}{{ end }}