From 1c4120f9b27d0bd53e77bf0bac6b42908d4dbf7f Mon Sep 17 00:00:00 2001
From: Timo Furrer <tfurrer@gitlab.com>
Date: Wed, 13 Nov 2024 14:55:39 +0100
Subject: [PATCH] Rename `TF_APPLY_NO_PLAN` to `GITLAB_TOFU_APPLY_NO_PLAN`

Changelog: changed
---
 src/gitlab-tofu.sh    | 7 ++++---
 templates/apply.yml   | 2 +-
 templates/destroy.yml | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh
index b5759c6..53795c5 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 a4b88ff..11d0060 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 b9a8a68..4a2c46e 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:
-- 
GitLab