Here is my values.yaml file:
options:
collection: "myCollection"
ttl: 100800
autoReconnect: true
reconnectTries: 3
reconnectInterval: 5
Now I'm trying to convert it into JSON in my configMap like this:
options: {
{{- range $key, $val := .Values.options }}
{{ $key }}: {{ $val | quote }},
{{- end }}
}
But I need to eliminate last comma in JSON so I'm trying to add a counter:
options: {
{{ $c := 0 | int }}
{{- range $key, $val := .Values.options }}
{{ if ne $c 0 }},{{ end }}
{{- $key }}: {{ $val | quote }}
{{ $c := $c add 1 }}
{{- end }}
}
But I'm getting following error for helm template ... command:
at <$c>: can't give argument to non-function $c
So what am I doing wrong?