diff --git a/examples/app/templates/cron-job.yaml b/examples/app/templates/cron-job.yaml index 453b05a..2e80bd2 100644 --- a/examples/app/templates/cron-job.yaml +++ b/examples/app/templates/cron-job.yaml @@ -23,4 +23,4 @@ spec: name: hello resources: {} restartPolicy: OnFailure - schedule: {{ .Values.cronJob.schedule | quote }} \ No newline at end of file + schedule: {{ tpl (.Values.cronJob.schedule) $ | quote }} \ No newline at end of file diff --git a/examples/app/templates/my-config-props.yaml b/examples/app/templates/my-config-props.yaml index 7ad1ed9..20832f5 100644 --- a/examples/app/templates/my-config-props.yaml +++ b/examples/app/templates/my-config-props.yaml @@ -5,7 +5,7 @@ metadata: labels: {{- include "app.labels" . | nindent 4 }} data: - my.prop1: {{ .Values.myConfigProps.myProp1 | quote }} - my.prop2: {{ .Values.myConfigProps.myProp2 | quote }} - my.prop3: {{ .Values.myConfigProps.myProp3 | quote }} + my.prop1: {{ tpl (.Values.myConfigProps.myProp1) $ | quote }} + my.prop2: {{ tpl (.Values.myConfigProps.myProp2) $ | quote }} + my.prop3: {{ tpl (.Values.myConfigProps.myProp3) $ | quote }} myval.yaml: {{ .Values.myConfigProps.myvalYaml | toYaml | indent 1 }} \ No newline at end of file diff --git a/examples/app/templates/my-config.yaml b/examples/app/templates/my-config.yaml index 47ddd6c..a46c521 100644 --- a/examples/app/templates/my-config.yaml +++ b/examples/app/templates/my-config.yaml @@ -6,7 +6,7 @@ metadata: {{- include "app.labels" . | nindent 4 }} immutable: true data: - dummyconfigmapkey: {{ .Values.myConfig.dummyconfigmapkey | quote }} + dummyconfigmapkey: {{ tpl (.Values.myConfig.dummyconfigmapkey) $ | quote }} my_config.properties: | - health.healthProbeBindAddress={{ .Values.myConfig.myConfigProperties.health.healthProbeBindAddress | quote }} - metrics.bindAddress={{ .Values.myConfig.myConfigProperties.metrics.bindAddress | quote }} \ No newline at end of file + health.healthProbeBindAddress={{ tpl (.Values.myConfig.myConfigProperties.health.healthProbeBindAddress) $ | quote }} + metrics.bindAddress={{ tpl (.Values.myConfig.myConfigProperties.metrics.bindAddress) $ | quote }} \ No newline at end of file diff --git a/examples/app/templates/my-sample-pv-claim.yaml b/examples/app/templates/my-sample-pv-claim.yaml index b48ddd7..976105b 100644 --- a/examples/app/templates/my-sample-pv-claim.yaml +++ b/examples/app/templates/my-sample-pv-claim.yaml @@ -9,7 +9,7 @@ spec: - ReadWriteOnce resources: limits: - storage: {{ .Values.pvc.mySamplePvClaim.storageLimit | quote }} + storage: {{ tpl (.Values.pvc.mySamplePvClaim.storageLimit) $ | quote }} requests: - storage: {{ .Values.pvc.mySamplePvClaim.storageRequest | quote }} - storageClassName: {{ .Values.pvc.mySamplePvClaim.storageClass | quote }} \ No newline at end of file + storage: {{ tpl (.Values.pvc.mySamplePvClaim.storageRequest) $ | quote }} + storageClassName: {{ tpl (.Values.pvc.mySamplePvClaim.storageClass) $ | quote }} \ No newline at end of file diff --git a/examples/app/templates/my-secret-ca.yaml b/examples/app/templates/my-secret-ca.yaml index 19ee3fb..a8949ca 100644 --- a/examples/app/templates/my-secret-ca.yaml +++ b/examples/app/templates/my-secret-ca.yaml @@ -5,6 +5,6 @@ metadata: labels: {{- include "app.labels" . | nindent 4 }} data: - ca.crt: {{ required "mySecretCa.caCrt is required" .Values.mySecretCa.caCrt | b64enc - | quote }} + ca.crt: {{ tpl (required "mySecretCa.caCrt is required" .Values.mySecretCa.caCrt) + $ | b64enc | quote }} type: opaque \ No newline at end of file diff --git a/examples/app/templates/my-secret-vars.yaml b/examples/app/templates/my-secret-vars.yaml index aec5b23..bf53990 100644 --- a/examples/app/templates/my-secret-vars.yaml +++ b/examples/app/templates/my-secret-vars.yaml @@ -5,13 +5,13 @@ metadata: labels: {{- include "app.labels" . | nindent 4 }} data: - ELASTIC_FOOBAR_HUNTER123_MEOWTOWN_VERIFY: {{ required "mySecretVars.elasticFoobarHunter123MeowtownVerify is required" .Values.mySecretVars.elasticFoobarHunter123MeowtownVerify | b64enc - | quote }} - VAR1: {{ required "mySecretVars.var1 is required" .Values.mySecretVars.var1 | b64enc - | quote }} - VAR2: {{ required "mySecretVars.var2 is required" .Values.mySecretVars.var2 | b64enc + ELASTIC_FOOBAR_HUNTER123_MEOWTOWN_VERIFY: {{ tpl (required "mySecretVars.elasticFoobarHunter123MeowtownVerify is required" .Values.mySecretVars.elasticFoobarHunter123MeowtownVerify) $ | b64enc | quote }} + VAR1: {{ tpl (required "mySecretVars.var1 is required" .Values.mySecretVars.var1) + $ | b64enc | quote }} + VAR2: {{ tpl (required "mySecretVars.var2 is required" .Values.mySecretVars.var2) + $ | b64enc | quote }} stringData: - str: {{ required "mySecretVars.str is required" .Values.mySecretVars.str | quote - }} + str: {{ tpl (required "mySecretVars.str is required" .Values.mySecretVars.str) + $ | quote }} type: opaque \ No newline at end of file diff --git a/examples/operator/templates/configmap-vars.yaml b/examples/operator/templates/configmap-vars.yaml index d6adbc5..76ef14a 100644 --- a/examples/operator/templates/configmap-vars.yaml +++ b/examples/operator/templates/configmap-vars.yaml @@ -5,4 +5,4 @@ metadata: labels: {{- include "operator.labels" . | nindent 4 }} data: - VAR4: {{ .Values.configmapVars.var4 | quote }} \ No newline at end of file + VAR4: {{ tpl (.Values.configmapVars.var4) $ | quote }} \ No newline at end of file diff --git a/examples/operator/templates/manager-config.yaml b/examples/operator/templates/manager-config.yaml index 6a6674c..752896f 100644 --- a/examples/operator/templates/manager-config.yaml +++ b/examples/operator/templates/manager-config.yaml @@ -7,4 +7,4 @@ metadata: data: controller_manager_config.yaml: {{ .Values.managerConfig.controllerManagerConfigYaml | toYaml | indent 1 }} - dummyconfigmapkey: {{ .Values.managerConfig.dummyconfigmapkey | quote }} \ No newline at end of file + dummyconfigmapkey: {{ tpl (.Values.managerConfig.dummyconfigmapkey) $ | quote }} \ No newline at end of file diff --git a/examples/operator/templates/pvc-lim.yaml b/examples/operator/templates/pvc-lim.yaml index c3f6340..ccaf79d 100644 --- a/examples/operator/templates/pvc-lim.yaml +++ b/examples/operator/templates/pvc-lim.yaml @@ -9,5 +9,5 @@ spec: - ReadWriteOnce resources: requests: - storage: {{ .Values.pvc.pvcLim.storageRequest | quote }} - storageClassName: {{ .Values.pvc.pvcLim.storageClass | quote }} \ No newline at end of file + storage: {{ tpl (.Values.pvc.pvcLim.storageRequest) $ | quote }} + storageClassName: {{ tpl (.Values.pvc.pvcLim.storageClass) $ | quote }} \ No newline at end of file diff --git a/examples/operator/templates/secret-ca.yaml b/examples/operator/templates/secret-ca.yaml index ddacf08..128cf8f 100644 --- a/examples/operator/templates/secret-ca.yaml +++ b/examples/operator/templates/secret-ca.yaml @@ -5,6 +5,6 @@ metadata: labels: {{- include "operator.labels" . | nindent 4 }} data: - ca.crt: {{ required "secretCa.caCrt is required" .Values.secretCa.caCrt | b64enc - | quote }} + ca.crt: {{ tpl (required "secretCa.caCrt is required" .Values.secretCa.caCrt) $ + | b64enc | quote }} type: opaque \ No newline at end of file diff --git a/examples/operator/templates/secret-registry-credentials.yaml b/examples/operator/templates/secret-registry-credentials.yaml index ef4fdad..4debe4e 100644 --- a/examples/operator/templates/secret-registry-credentials.yaml +++ b/examples/operator/templates/secret-registry-credentials.yaml @@ -5,6 +5,6 @@ metadata: labels: {{- include "operator.labels" . | nindent 4 }} data: - .dockerconfigjson: {{ required "secretRegistryCredentials.dockerconfigjson is required" - .Values.secretRegistryCredentials.dockerconfigjson | b64enc | quote }} + .dockerconfigjson: {{ tpl (required "secretRegistryCredentials.dockerconfigjson is required" .Values.secretRegistryCredentials.dockerconfigjson) $ | b64enc | + quote }} type: kubernetes.io/dockerconfigjson \ No newline at end of file diff --git a/examples/operator/templates/secret-vars.yaml b/examples/operator/templates/secret-vars.yaml index f77878a..1c2c4b3 100644 --- a/examples/operator/templates/secret-vars.yaml +++ b/examples/operator/templates/secret-vars.yaml @@ -5,8 +5,8 @@ metadata: labels: {{- include "operator.labels" . | nindent 4 }} data: - VAR1: {{ required "secretVars.var1 is required" .Values.secretVars.var1 | b64enc - | quote }} - VAR2: {{ required "secretVars.var2 is required" .Values.secretVars.var2 | b64enc - | quote }} + VAR1: {{ tpl (required "secretVars.var1 is required" .Values.secretVars.var1) $ + | b64enc | quote }} + VAR2: {{ tpl (required "secretVars.var2 is required" .Values.secretVars.var2) $ + | b64enc | quote }} type: opaque \ No newline at end of file diff --git a/pkg/helmify/values.go b/pkg/helmify/values.go index 4255522..ecd8098 100644 --- a/pkg/helmify/values.go +++ b/pkg/helmify/values.go @@ -42,7 +42,7 @@ func (v *Values) Add(value interface{}, name ...string) (string, error) { } _, isString := value.(string) if isString { - return "{{ .Values." + strings.Join(name, ".") + " | quote }}", nil + return "{{ tpl (.Values." + strings.Join(name, ".") + ") $ | quote }}", nil } _, isSlice := value.([]interface{}) if isSlice { @@ -78,7 +78,7 @@ func (v *Values) AddSecret(toBase64 bool, name ...string) (string, error) { if err != nil { return "", errors.Wrapf(err, "unable to set value: %v", nameStr) } - res := fmt.Sprintf(`{{ required "%[1]s is required" .Values.%[1]s`, nameStr) + res := fmt.Sprintf(`{{ tpl (required "%[1]s is required" .Values.%[1]s) $`, nameStr) if toBase64 { res += " | b64enc" }