Escaping space character in yaml sequence of strings in helm

9/18/2019

I'm using helm template command to template a file but cannot escape a space character in yaml sequence. I have tried with "" and '' but the result remains the same.

template.yaml:

scriptsApproval:
{{ toYaml .Values.scriptApproval }}

values.yaml:

scriptsApproval:
- string1 abc ijk lmn
- string2 abc ijk lmn
- string3 abc ijk lmn

Getting Results after running helm template

result.yaml:

scriptsApproval:
- string1 abc ijk 
  lmn
- string2 abc ijk 
  lmn
- string3 abc ijk 
  lmn
-- U. Ahmad
kubernetes
kubernetes-helm
yaml

1 Answer

9/18/2019

You can use Helm's |quote function described here and here

{{ toYaml .Values.scriptApproval }}

Would be something like

{{ range .Values.scriptApproval }}
{{ . | quote }}
{{ end }}

*Untested

-- Christiaan Vermeulen
Source: StackOverflow