I am currently trying to get all the charts I included in my Chart.yaml
file where am using a common chart multiple times with different aliases so I can reuse it.
the problem is I couldn't find deep documentation about getting some of the Chart values as following the helm Built-In Objects documentation
apiVersion: v2
name: example
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"
dependencies:
- name: common
version: x.x.x
alias: app1
- name: common
version: x.x.x
alias: app2
In NOTES.txt
I managed to get interesting information about the dependencies by using this code example:
{{ range .Chart.Dependencies }}
{{ . }}
{{- end }}
and this is what I am getting as an output:
{app1 x.x.x [] true [] app1}
{app2 x.x.x [] true [] app2}
I tried accessing the dependency name using {{ .alias }}, instead am getting this error:
Error: INSTALLATION FAILED: template: example/templates/NOTES.txt:2:3: executing "example/templates/NOTES.txt" at <.alias>: can't evaluate field alias in type *chart.Dependency
How can I extract the aliases/names from that output string?
Am using helm v3.8.0 and debugging with
helm install project . --dry-run
I managed to run this by using this code:
{{ range .Chart.Dependencies }}
{{ with fromJson (toJson .) }}
{{ .alias }}
{{- end }}
{{- end }}
this basically formats the strings to json as string object using toJson
then read them using fromJson
which in fact allowed me to read key/value objects.
Without fromJson you will get this error
at <.alias>: can't evaluate field alias in type string