Thanks for developing this tool, we have found it quite useful 馃憤
I'm trying to include content from a file within a helmfile template, replace variables within that file using envsubst via exec and use the resulting text in the template but have trouble getting it to work.
Below are some examples of what I have tried:
Read template file from stdin using shell redirection:
something:
json: |
{{ exec "envsubst" (list "<" "template-file" | indent 4 }}
This fails as the shell redirection shouldn't/couldn't be passed as an argument this way.
Read template file using cat and pipe to envsubst:
something:
json: |
{{ exec "cat" (list "template-file") | exec "envsubst" (list) | indent 4}}
This construction does not generate any output. I think it has to do with the way the arguments is sent to envsubst. Is there perhaps another way to execute a command with no arguments?
@algestam Hey! Try {{ exec "sh" (list "-c" "envsubst < template-file") | indent 4}}. You need to differentiate | in the go template vs in shell, and understand who evaluates < in "envsubst" (list "<" "template-file"(=your shell, not os, hence you need sh in order to evaluate <)
Thanks for the help and explanation @mumoshu! I didn't think of using sh to evaluate <.
Your suggestion works great, thanks again :)