helm-docs
helm-docs copied to clipboard
[Enhancement] Replicate Helm functionality allowing access to .Files
For complex Helm charts where additional resource files and manifest templates are split into multiple files and directories, it can be useful to allow programatic enumeration of the files within the chart to help generate documentation.
For example I have a large chart that splits up many micro-service components into ./templates/components/COMPONENT.yaml
.
This is useful for splitting discrete tables of .Values
documentation out per component. At the moment I have to create a list with all the component names in manually so that it can be looped around.
Adding a .Files
interface in the same way that Helm does would be very helpful. Specifically being able to use .Files.Glob
would be fantastic.
https://helm.sh/docs/chart_template_guide/accessing_files/
I have included an example of the specific use-case. Just imagine it with dozens more components instead of 5. :-)
{{- $dependencies := list "dep1" "dep2" "dep3" "dep4" "dep4" }}
{{- $components := list }}
{{- $components := append $components "component1" }}
{{- $components := append $components "component2" }}
{{- $components := append $components "component3" }}
{{- $components := append $components "component4" }}
{{- $components := append $components "component5" }}
{{- $componentDefaults := list "replicaCount" }}
{{- $componentDefaults := append $componentDefaults "replicaCount" }}
{{- $componentDefaults := append $componentDefaults "image" }}
{{- $componentDefaults := append $componentDefaults "imagePullSecrets" }}
{{- $componentDefaults := append $componentDefaults "serviceAccount" }}
{{- $componentDefaults := append $componentDefaults "podAnnotations" }}
{{- $componentDefaults := append $componentDefaults "podSecurityContext" }}
{{- $componentDefaults := append $componentDefaults "securityContext" }}
{{- $componentDefaults := append $componentDefaults "ingress" }}
{{- $componentDefaults := append $componentDefaults "resources" }}
{{- $componentDefaults := append $componentDefaults "autoscaling" }}
{{- $componentDefaults := append $componentDefaults "nodeSelector" }}
{{- $componentDefaults := append $componentDefaults "tolerations" }}
{{- $componentDefaults := append $componentDefaults "affinity" }}
## Global Values
| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if has ((splitList "." .Key) | first) $dependencies | not }}
{{- if has ((splitList "." .Key) | first) $componentDefaults | not }}
{{- if has ((splitList "." .Key) | first) $components | not }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}
{{- end }}
{{- end }}
## Default Values
| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if has ((splitList "." .Key) | first) $componentDefaults }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}
## Component Values
| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- $firstPart := (splitList "." .Key) | first }}
{{- $secondPart := (splitList "." .Key) | rest | first }}
{{- if has $firstPart $components }}
{{- if has $secondPart $componentDefaults | not }}
{{- if has ((splitList "." .Key) | first) $componentDefaults | not }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}
{{- end }}
{{- end }}
## Sub-chart Dependency Values
| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if has ((splitList "." .Key) | first) $dependencies }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}
I think this is an interesting thought, I don't have time to implement it, however I'd be happy to look at a PR