refactor(ops/terraform/deploy-nixos): argstr -> argstr_json
At least terraform wants all parameters passed via JSON to be strings. It can't accept maps. This means, allowing to pass a `argstr` JSON dict isn't really possible. However, terraform is perfectly able to JSON-encode a map. So accept a `argstr_json` argument instead, which `jq` will JSON-decode before further processing it. I dropped `argstr` support again so the jq expression still fits on my screen, if anyone else (started) using this, I'm happy to review a CL adding this. We should probably move the jq expression to some multiline format then, though. Change-Id: I5ab7a1169ab7305d3ab02db31c27732d9d1ab4e8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11228 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
f055c75bc0
commit
508d67ad49
1 changed files with 3 additions and 3 deletions
|
@ -15,14 +15,14 @@ set -ueo pipefail
|
||||||
# - `entrypoint`: the path to the Nix file to invoke.
|
# - `entrypoint`: the path to the Nix file to invoke.
|
||||||
# Optional. If omitted, will shell out to git to determine the repo root,
|
# Optional. If omitted, will shell out to git to determine the repo root,
|
||||||
# and Nix will use `default.nix` in there.
|
# and Nix will use `default.nix` in there.
|
||||||
# - `argstr`: A map containing string keys and values
|
# - `argstr_json`: A string JSON-encoding a map containing string keys and
|
||||||
# which are passed to Nix as `--argstr $key $value`
|
# values which should be passed to Nix as `--argstr $key $value`.
|
||||||
# command line args. Optional.
|
# command line args. Optional.
|
||||||
# - `build`: A boolean (or string being "true" or "false") stating whether the
|
# - `build`: A boolean (or string being "true" or "false") stating whether the
|
||||||
# expression should also be built/substituted on the machine executing this script.
|
# expression should also be built/substituted on the machine executing this script.
|
||||||
#
|
#
|
||||||
# jq's @sh format takes care of escaping.
|
# jq's @sh format takes care of escaping.
|
||||||
eval "$(jq -r '@sh "attrpath=\(.attrpath) && entrypoint=\(.entrypoint) && argstr=\((.argstr // {}) | to_entries | map ("--argstr", .key, .value) | join(" ")) build=\(.build)"')"
|
eval "$(jq -r '@sh "attrpath=\(.attrpath) && entrypoint=\(.entrypoint) && argstr=\((.argstr_json // "{}"|fromjson) | to_entries | map ("--argstr", .key, .value) | join(" ")) build=\(.build)"')"
|
||||||
|
|
||||||
# Evaluate the expression.
|
# Evaluate the expression.
|
||||||
[[ -z "$entrypoint" ]] && entrypoint=$(git rev-parse --show-toplevel)
|
[[ -z "$entrypoint" ]] && entrypoint=$(git rev-parse --show-toplevel)
|
||||||
|
|
Loading…
Reference in a new issue