Given the following values.yaml
elements:
first:
enabled: true
url: first.url
second:
enabled: flase
url: second.url
third:
enabled: true
url: third.url
What would be a good way to obtain the following result:
list_of_elements=first,third
Where the resulting list needs to contain only the elements that have been enabled. The list needs to be a single line of comma separated items.
A little bit lengthy but does its job:
{{ $result := list }}
{{ range $k, $v := .Values.elements }}
{{ if eq (toString $v.enabled) "true" }}
{{ $result = append $result $k }}
{{ end }}
{{ end }}
list_of_elements: {{ join "," $result }}