T
Task2w ago
sedyh

No direct alternative to VAR ?= VALUE from make

Hello, I just discovered that task can't leave a variable if it's already declared in the system. There's vars, which always prioritizes internal variables, and there's env, which always prioritizes external ones, and there's dotenv, which can only pull variables from a file, but not from the environment. The only option is to write if-else-end on go templates for each such variable. Is it possible to make something like ?VAR to get similar behavior? Or is there another option that I don't know about? Please help.
2 Replies
tboerger
tboerger2w ago
I'm using variables like this: env: GEXEC_LOG_LEVEL: "{{ .GEXEC_LOG_LEVEL | default "debug" }}"
andreynering
andreynering2w ago
@sedyh You can try to use default for that:
VARIABLE: '{{.VARIABLE | default "foobar"}}'
VARIABLE: '{{.VARIABLE | default "foobar"}}'

Did you find this page helpful?