helmify
helmify copied to clipboard
Names that are too long generate invalid multi-line strings
The following snippet of YAML results in an invalid credentials.yaml file:
apiVersion: v1
kind: Secret
metadata:
name: spellbook-credentials
type: Opaque
data:
MQTT_HOST: "Zm9vYmFy"
MQTT_PORT: "Zm9vYmFy"
ELASTIC_HOST: "Zm9vYmFy"
ELASTIC_PORT: "Zm9vYmFy"
ELASTIC_PROTOCOL: "Zm9vYmFy"
ELASTIC_PASSWORD: "Zm9vYmFy"
ELASTIC_FOOBAR_HUNTER123_MEOWTOWN_VERIFY: "Zm9vYmFy"
The resulting output:
apiVersion: v1
kind: Secret
metadata:
name: {{ include "spellbook.fullname" . }}-credentials
labels:
{{- include "spellbook.labels" . | nindent 4 }}
data:
ELASTIC_FOOBAR_HUNTER123_MEOWTOWN_VERIFY: {{ required "credentials.elasticFoobarHunter123MeowtownVerify
is required" .Values.credentials.elasticFoobarHunter123MeowtownVerify | b64enc
| quote }}
ELASTIC_HOST: {{ required "credentials.elasticHost is required" .Values.credentials.elasticHost
| b64enc | quote }}
ELASTIC_PASSWORD: {{ required "credentials.elasticPassword is required" .Values.credentials.elasticPassword
| b64enc | quote }}
ELASTIC_PORT: {{ required "credentials.elasticPort is required" .Values.credentials.elasticPort
| b64enc | quote }}
ELASTIC_PROTOCOL: {{ required "credentials.elasticProtocol is required" .Values.credentials.elasticProtocol
| b64enc | quote }}
MQTT_HOST: {{ required "credentials.mqttHost is required" .Values.credentials.mqttHost
| b64enc | quote }}
MQTT_PORT: {{ required "credentials.mqttPort is required" .Values.credentials.mqttPort
| b64enc | quote }}
Running helm install will error out because of the invalid YAML generated for key names past a certain length:
$ helm install -f ./contrib/k8s/examples/spellbook/values.yaml webrtc-dev-telemetry ./contrib/k8s/charts/spellbook
Error: INSTALLATION FAILED: parse error at (spellbook/templates/credentials.yaml:8): unterminated quoted string
Thanks for your work on this, by the way.
This one is quite tricky to fix. Used YAML encoder sigs.k8s.io/yaml v1.2.0 creates line breaks for all lines longer than 80 symbols. Which is fine, because such quotes in the middle of the string are not expected for YAML value (but ok for a helm template). I will try to find another encoder allowing to disable such line breaks but not sure that it is possible.
For instance, go-yaml also not allowing to disable line breaks
I wrote a tool to sanitize templates generated by helmify. It just works for now without handling complicated cases.
https://github.com/yxd-ym/go-template-sanitizer
Just
cat your-template.yaml | go-template-sanitizer
@danielxvu is your required error {{ required "credentials.elasticHost is required" .Values.credentials.elasticHost | b64enc | quote }} due to the same error? Or does this error has a different source issue?
@vicentefb No. This issue is caused by an overly long key like ELASTIC_FOOBAR_HUNTER123_MEOWTOWN_VERIFY.
I'm having the same issue on a secret object. @arttor are you still working on this?
Fixed in 0.3.22 release.
Thank you!