diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh index c13e6c0d79061d2254e9bdaf306e40ac4017e758..47e4c3ba13efd3726778af33f8b7ee655f80b7a0 100644 --- a/src/gitlab-tofu.sh +++ b/src/gitlab-tofu.sh @@ -125,7 +125,7 @@ if [ -n "$TF_ADDRESS" ]; then fi fi -JQ_PLAN=' +jq_plan=' ( [.resource_changes[]?.change.actions?] | flatten ) | { @@ -300,7 +300,7 @@ if [ $sourced -eq 0 ]; then if [ "${GITLAB_TOFU_PLAN_WITH_JSON}" = 'true' ]; then if [ "$ret" -eq 0 ] || [ "$ret" -eq 2 ]; then - if ! tofu "${tf_chdir_opt}" show -json "${GITLAB_TOFU_PLAN_CACHE}" | jq -r "${JQ_PLAN}" > "${GITLAB_TOFU_PLAN_JSON}"; then + if ! tofu "${tf_chdir_opt}" show -json "${GITLAB_TOFU_PLAN_CACHE}" | jq -r "${jq_plan}" > "${GITLAB_TOFU_PLAN_JSON}"; then exit $? fi @@ -312,7 +312,7 @@ if [ $sourced -eq 0 ]; then exit "$ret" ;; "plan-json") - tofu "${tf_chdir_opt}" show -json "${GITLAB_TOFU_PLAN_CACHE}" | jq -r "${JQ_PLAN}" > "${GITLAB_TOFU_PLAN_JSON}" + tofu "${tf_chdir_opt}" show -json "${GITLAB_TOFU_PLAN_CACHE}" | jq -r "${jq_plan}" > "${GITLAB_TOFU_PLAN_JSON}" ;; "validate") $GITLAB_TOFU_IMPLICIT_INIT && terraform_init -backend=false