Helmfile: Cannot exec command without arguments

Created on 14 Aug 2019  路  2Comments  路  Source: roboll/helmfile

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?

question

All 2 comments

@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 :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

machine424 picture machine424  路  3Comments

klebediev picture klebediev  路  3Comments

mojochao picture mojochao  路  4Comments

madAndroid picture madAndroid  路  3Comments

willejs picture willejs  路  4Comments