Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Replicate Helm functionality allowing access to .Files #107

Open
sheisnicola opened this issue Aug 20, 2021 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@sheisnicola
Copy link

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 }}
@norwoodj
Copy link
Owner

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

@norwoodj norwoodj added the enhancement New feature or request label Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

2 participants