Skip to content

Files.Glob documentation unclear  #1314

Open
@spiriad

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:

  1. 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
  2. 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 }}

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions