From b66c7ca01ac56f39efd0547c017b056531ec71ec Mon Sep 17 00:00:00 2001
From: Timo Furrer <tfurrer@gitlab.com>
Date: Wed, 13 Nov 2024 15:52:15 +0100
Subject: [PATCH] Rename `TF_INIT_FLAGS` to `GITLAB_TOFU_INIT_FLAGS`

Changelog: changed
---
 .gitlab/README.md.template  | 2 +-
 README.md                   | 2 +-
 src/gitlab-tofu.sh          | 4 ++--
 tests/unit/gitlab-tofu.bats | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/.gitlab/README.md.template b/.gitlab/README.md.template
index fa5d0ff..6bec4e7 100644
--- a/.gitlab/README.md.template
+++ b/.gitlab/README.md.template
@@ -328,7 +328,7 @@ we may make it the default behavior if possible.
 #### Lockfile Handling
 
 If you commit the Lockfile (`.terraform.lock.hcl`) to your repository
-we recommend setting either the `TF_INIT_FLAGS` (handled by this component)
+we recommend setting either the `GITLAB_TOFU_INIT_FLAGS` (handled by this component)
 or `TF_CLI_ARGS_init` (handled by OpenTofu directly) to `-lockfile=readonly`
 to prevent any changes to the lockfile during the pipeline job and with
 that ensuring that OpenTofu really uses the locked dependencies.
diff --git a/README.md b/README.md
index fd240c6..5e38a53 100644
--- a/README.md
+++ b/README.md
@@ -343,7 +343,7 @@ we may make it the default behavior if possible.
 #### Lockfile Handling
 
 If you commit the Lockfile (`.terraform.lock.hcl`) to your repository
-we recommend setting either the `TF_INIT_FLAGS` (handled by this component)
+we recommend setting either the `GITLAB_TOFU_INIT_FLAGS` (handled by this component)
 or `TF_CLI_ARGS_init` (handled by OpenTofu directly) to `-lockfile=readonly`
 to prevent any changes to the lockfile during the pipeline job and with
 that ensuring that OpenTofu really uses the locked dependencies.
diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh
index e05526e..947bac3 100644
--- a/src/gitlab-tofu.sh
+++ b/src/gitlab-tofu.sh
@@ -258,9 +258,9 @@ terraform_init() {
     tf_init_reconfigure_flag='-reconfigure'
   fi
 
-  # We want to allow word splitting here for TF_INIT_FLAGS
+  # We want to allow word splitting here for GITLAB_TOFU_INIT_FLAGS
   # shellcheck disable=SC2086
-  tofu "${tf_chdir_opt}" init "${@}" -input=false ${tf_init_reconfigure_flag} ${TF_INIT_FLAGS} \
+  tofu "${tf_chdir_opt}" init "${@}" -input=false ${tf_init_reconfigure_flag} ${GITLAB_TOFU_INIT_FLAGS} \
     1>&2 || $GITLAB_TOFU_IGNORE_INIT_ERRORS
 }
 
diff --git a/tests/unit/gitlab-tofu.bats b/tests/unit/gitlab-tofu.bats
index f254e5c..44890a0 100644
--- a/tests/unit/gitlab-tofu.bats
+++ b/tests/unit/gitlab-tofu.bats
@@ -35,12 +35,12 @@ teardown() {
 }
 
 @test "gitlab-tofu init with environment variable flags" {
-  export TF_INIT_FLAGS="-get=true -no-color"
+  export GITLAB_TOFU_INIT_FLAGS="-get=true -no-color"
   gitlab-tofu init
 }
 
 @test "gitlab-tofu init with args and environment variable flags" {
-  export TF_INIT_FLAGS="-get=true"
+  export GITLAB_TOFU_INIT_FLAGS="-get=true"
   gitlab-tofu init -no-color
 }
 
-- 
GitLab