diff --git a/example-charts/files-values/README.md b/example-charts/files-values/README.md index 30e4436..e095d84 100644 --- a/example-charts/files-values/README.md +++ b/example-charts/files-values/README.md @@ -47,6 +47,12 @@ dataSecret: resource2.yaml: c29tZToKICByZXNvdXJjZTogImJsYWgyIg== ``` +File: Chart.yaml +File: somefile.yaml +File: templates/resource1.yaml +File: templates/resource2.yaml +File: values.yaml + ## Values | Key | Type | Default | Description | @@ -61,5 +67,3 @@ dataSecret: | statefulset.livenessProbe | object | `{"enabled":false}` | Configure the healthcheck for the database | | statefulset.podLabels | object | `{}` | The labels to be applied to instances of the database | ----------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/example-charts/files-values/README.md.gotmpl b/example-charts/files-values/README.md.gotmpl index 4e4ef6c..54e7e64 100644 --- a/example-charts/files-values/README.md.gotmpl +++ b/example-charts/files-values/README.md.gotmpl @@ -39,6 +39,10 @@ dataSecret: {{ (.Files.Glob "templates/**.yaml").AsSecrets | indent 2 }} ``` +{{ range $path, $_ := (.Files.Glob "**.yaml").AsMap -}} +File: {{$path}} +{{ end }} + {{ template "chart.requirementsSection" . }} {{ template "chart.valuesSection" . }} diff --git a/pkg/document/files.go b/pkg/document/files.go index 8065e09..1a53c1e 100644 --- a/pkg/document/files.go +++ b/pkg/document/files.go @@ -122,6 +122,10 @@ func (f files) AsSecrets() string { return toYAML(m) } +func (f files) AsMap() map[string]*fileEntry { + return f.foundFiles +} + func (f files) Lines(path string) []string { if len(f.foundFiles) == 0 { return []string{} diff --git a/pkg/document/files_test.go b/pkg/document/files_test.go index 8303d23..f4489b8 100644 --- a/pkg/document/files_test.go +++ b/pkg/document/files_test.go @@ -83,6 +83,17 @@ func TestToSecret(t *testing.T) { as.Equal("captain.txt: VGhlIENhcHRhaW4=\nstowaway.txt: TGVnYXR0", out) } +func TestToMap(t *testing.T) { + as := assert.New(t) + + f := getTestFiles() + + out := f.Glob("ship/**").AsMap() + as.Contains(out, "ship/captain.txt") + as.Contains(out, "ship/stowaway.txt") + as.NotContains(out, "story/name.txt") +} + func TestLines(t *testing.T) { as := assert.New(t)