I'm looking for a solution to transform a list in my values.yaml in a comma separated list.
values.yaml
app:
logfiletoexclude:
- "/var/log/containers/kube*"
- "/var/log/containers/tiller*"
_helpers.tpl:
{{- define "pathtoexclude" -}}
{{- join "," .Values.app.logfiletoexclude }}
{{- end -}}
configmap:
<source>
@type tail
path /var/log/containers/*.log
exclude_path [{{ template "pathtoexclude" . }}]
...
...
</source>
The problem is there is missing quotes in my result
exclude_path [/var/log/containers/kube*,/var/log/containers/tiller*]
How can I fix it to be able to have:
exclude_path ["/var/log/containers/kube*","/var/log/containers/tiller*"]
I've try with:
{{- join "," .Values.app.logfiletoexclude | quote}}
but this give me:
exclude_path ["/var/log/containers/kube*,/var/log/containers/tiller*"]
Thanks
Double quotes should be escaped in .Values.app.logfiletoexclude
values.
values.yaml
is:
app:
logfiletoexclude:
- '"/var/log/containers/kube*"'
- '"/var/log/containers/tiller*"'
_helpers.tpl
is:
{{- define "pathtoexclude" -}}
{{- join "," .Values.app.logfiletoexclude }}
{{- end -}}
And finally we have:
exclude_path ["/var/log/containers/kube*","/var/log/containers/tiller*"]
Alternatively, the following also worked for me without having to extra-quote the input values:
"{{- join "\",\"" .Values.myArrayField }}"
Of course, this only works for non-empty arrays and produces a single empty quoted value for an empty array. Someone knows a simple guard one could integrate here?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With