You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2 potential ideas for a backwards compatible way to address this:
Add a new provider called "mustenvsubst" eg: ref+mustenvsubst://$VARIABLE which would fail if the variable is not set
Add a query string like other providers, eg: ref+envsubst://$VARIABLE?must_exist=true
Happy to take a stab at the PR once given guidance on the preferred direction to address this :)
I am performing a vals eval on a JSON source file, so using this script as a workaround:
#!/bin/bashset -eo pipefail
IFS=$'\n\t'# This script will parse the JSON file and fail if the requested vals environment variables don't exist.if [ $#-ne 1 ];then
cat <<<"Usage: check_vals_envsubst_exist.sh <json-file-to-be-evaled-by-vals>"1>&2;exit 1
fi
missing_vars=false
whileread -r var;doif [ -z"${!var}" ];thenecho"[MISSING] Environment Variable '$var'"
missing_vars=true
elseecho"[FOUND] Environment Variable '$var'"fidone<<(jq -r '.. | select(type == "string" and test("^ref\\+envsubst://\\$\\w+")) | sub("^ref\\+envsubst://\\$"; "")'$1)if [ "$missing_vars"=true ];thenecho"The [MISSING] environment variables are missing. Make sure they are set so vals can use them. Exiting."exit 1
fi
The text was updated successfully, but these errors were encountered:
When using the EnvSubst provider, if an environment variable doesn't exist, it will just pass a blank string to the evaluated file and not error.
To replicate the issue:
Result:
foo: ""
Result:
foo: bar
2 potential ideas for a backwards compatible way to address this:
ref+mustenvsubst://$VARIABLE
which would fail if the variable is not setref+envsubst://$VARIABLE?must_exist=true
Happy to take a stab at the PR once given guidance on the preferred direction to address this :)
I am performing a
vals eval
on a JSON source file, so using this script as a workaround:The text was updated successfully, but these errors were encountered: