Description
Inside our CI piepline, I try to pass a google service account key (JSON format, contained in an environment variable) to the helm chart. It should end up as base64 encoded string within a secret:
# secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: secret
labels:
app: application
chart: {{ .Chart.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
credentials.json: {{ .Values.googleServiceAccount.credentials | b64enc | quote }}
However, passing it via --set/--set-string I get
$ helm template ./chart --set-string googleServiceAccount.credentials='{"foo": "bar", "baroo": "baz"}'
Error: render error in "chart/templates/secret.yaml": template: chart/templates/secret.yaml:11:66: executing "chart/templates/secret.yaml" at <b64enc>: wrong type for value; expected string; got []interface {}
It only works if I escape everything like this:
$ helm template ./chart --set-string googleServiceAccount.credentials='\{\"foo\": \"bar\"\, \"baroo\": \"baz\"\}'
---
# Source: chart/templates/secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: secret
labels:
app: applicatoin
chart: chart
heritage: Tiller
type: Opaque
data:
credentials.json: "eyJmb28iOiAiYmFyIiwgImJhcm9vIjogImJheiJ9"
$echo eyJmb28iOiAiYmFyIiwgImJhcm9vIjogImJheiJ9 | base64 -d
{"foo": "bar", "baroo": "baz"}
But inside our CI pipeline I do not want to have some magical escaping on environment variables.
Other solutions would be to manually base64 encoded credentials and pass them as a environment variable. But since we're using b64enc for everything else, I'd like to stick to that habit.
Is there any way to achieve what I want, i.e. passing strings containing json to helm without helm performing some type conversion on them? Or is the "aggressively-escape-everything" solution the only one?
Thanks for your help and input on this! :)
Somewhat related issues: #1556 #3155
Output of helm version:
Client: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}
I looked into issues and changelogs and it seems to me that there are no relevant changes made in higher versions.