diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh index b5759c68285b1b3f31e6ea8ec4e038fb713444ae..53795c580976790540cb5dc529d1b6fbd2f6f5a4 100644 --- a/src/gitlab-tofu.sh +++ b/src/gitlab-tofu.sh @@ -12,6 +12,7 @@ # Respected Environment Variables: # -------------------------------- # GITLAB_TOFU_SOURCE: forces this script in source-mode. Required when source auto-detection fails. +# GITLAB_TOFU_APPLY_NO_PLAN: if set to true, the apply command does not use a plan cache file. # # OpenTofu Environment Variables: # > these are variables that are @@ -111,8 +112,8 @@ if [ -z "${TF_PLAN_NAME}" ]; then TF_PLAN_NAME=plan fi -if [ -z "${TF_APPLY_NO_PLAN}" ]; then - TF_APPLY_NO_PLAN=false +if [ -z "${GITLAB_TOFU_APPLY_NO_PLAN}" ]; then + GITLAB_TOFU_APPLY_NO_PLAN=false fi # If TF_ROOT is set then use the -chdir option @@ -231,7 +232,7 @@ if [ $sourced -eq 0 ]; then case "${1}" in "apply") $TF_IMPLICIT_INIT && terraform_init - if [ "$TF_APPLY_NO_PLAN" = false ]; then + if [ "$GITLAB_TOFU_APPLY_NO_PLAN" = false ]; then tofu "${TF_CHDIR_OPT}" "${@}" -input=false -auto-approve "${TF_PLAN_CACHE}" else # shellcheck disable=SC2086 diff --git a/templates/apply.yml b/templates/apply.yml index a4b88ff94cb1d1966573ad631024a8c5a9e81d41..11d00600320aa63ce230896817b6fa373846660a 100644 --- a/templates/apply.yml +++ b/templates/apply.yml @@ -111,7 +111,7 @@ spec: __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] - TF_APPLY_NO_PLAN: $[[ inputs.no_plan ]] + GITLAB_TOFU_APPLY_NO_PLAN: $[[ inputs.no_plan ]] TF_PLAN_NAME: $[[ inputs.plan_name ]] GITLAB_TOFU_VAR_FILE: '$[[ inputs.var_file ]]' image: diff --git a/templates/destroy.yml b/templates/destroy.yml index b9a8a68b9d1cfa0117bc8ff082b8e5762930a4b4..4a2c46e6a200186ed38d80116fca31173165299d 100644 --- a/templates/destroy.yml +++ b/templates/destroy.yml @@ -111,7 +111,7 @@ spec: __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] - TF_APPLY_NO_PLAN: $[[ inputs.no_plan ]] + GITLAB_TOFU_APPLY_NO_PLAN: $[[ inputs.no_plan ]] TF_PLAN_NAME: $[[ inputs.plan_name ]] GITLAB_TOFU_VAR_FILE: '$[[ inputs.var_file ]]' image: