I have a values file like:
secrets:
file.tst |
{
content ....
}
And I would like to get file.tst name in the yaml template. I already tried with:
{{ .Values.secrets.secrets |trimSuffix "-" }}
But it doesn't work.
With that values.yaml
layout, .Values.secrets
is itself a dictionary, with string keys and string values. Helm includes many functions that can operate on details of these. In particular, you can call keys
to get the keys of a dictionary as a list, and first
to get the first item out of a list.
firstFilename: "{{ .Values.secrets | keys | first }}"
You can also use the built-in range
function to iterate over either the map itself or the list of keys.
hashes:
{{- $filename, $contents := range .Values.secrets }}
{{ $filename }}: "{{ sha256sum $contents }}"
{{- end }}