helm join list from values file
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?
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*"]
Fluentd allows what they call "shorthand syntax" for arrays in their configs https://docs.fluentd.org/configuration/config-file#supported-data-types-for-values, which is a string with commas in it to separate values, like "value1,value2,value3".
So if you can assume there will be no commas in your values, you could save yourself the headache of double quoting with '"..."'
and just do:
In your values.yaml
:
app:
logfiletoexclude:
- /var/log/containers/kube*
- /var/log/containers/tiller*
In your _helpers.tpl
:
{{- define "pathtoexclude" -}}
{{- join "," .Values.app.logfiletoexclude }}
{{- end -}}
In your configmap:
<source>
@type tail
path /var/log/containers/*.log
exclude_path {{ template "pathtoexclude" . }}
...
</source>