From 999bff8851d4e13a35b302895321beba0302e765 Mon Sep 17 00:00:00 2001 From: Timo Furrer <tfurrer@gitlab.com> Date: Wed, 13 Nov 2024 15:03:26 +0100 Subject: [PATCH] Rename `TF_PLAN_NAME` to `GITLAB_TOFU_PLAN_NAME` Changelog: changed --- src/gitlab-tofu.sh | 13 +++++++------ templates/apply.yml | 2 +- templates/destroy.yml | 2 +- templates/plan.yml | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh index 36ddd26..c553ecc 100644 --- a/src/gitlab-tofu.sh +++ b/src/gitlab-tofu.sh @@ -13,6 +13,7 @@ # -------------------------------- # 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. +# GITLAB_TOFU_PLAN_NAME: the name of the plan cache and json files. Defaults to `plan`. # # Respected OpenTofu Environment Variables: # > these are variables that are @@ -108,8 +109,8 @@ if [ -n "${TF_STATE_NAME}" ] && [ -z "${TF_ADDRESS}" ]; then TF_ADDRESS="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/${TF_STATE_NAME}" fi -if [ -z "${TF_PLAN_NAME}" ]; then - TF_PLAN_NAME=plan +if [ -z "${GITLAB_TOFU_PLAN_NAME}" ]; then + GITLAB_TOFU_PLAN_NAME=plan fi if [ -z "${GITLAB_TOFU_APPLY_NO_PLAN}" ]; then @@ -122,19 +123,19 @@ if [ -n "${TF_ROOT}" ]; then TF_CHDIR_OPT="-chdir=${abs_tf_root}" - default_tf_plan_cache="${abs_tf_root}/${TF_PLAN_NAME}.cache" - default_tf_plan_json="${abs_tf_root}/${TF_PLAN_NAME}.json" + default_tf_plan_cache="${abs_tf_root}/${GITLAB_TOFU_PLAN_NAME}.cache" + default_tf_plan_json="${abs_tf_root}/${GITLAB_TOFU_PLAN_NAME}.json" fi # If TF_PLAN_CACHE is not set then use either the plan.cache file within TF_ROOT if set, or plan.cache in CWD if [ -z "${TF_PLAN_CACHE}" ]; then - TF_PLAN_CACHE="${default_tf_plan_cache:-${TF_PLAN_NAME}.cache}" + TF_PLAN_CACHE="${default_tf_plan_cache:-${GITLAB_TOFU_PLAN_NAME}.cache}" fi # If TF_PLAN_JSON is not set then use either the plan.json file within TF_ROOT if set, or plan.json in CWD if [ -z "${TF_PLAN_JSON}" ]; then - TF_PLAN_JSON="${default_tf_plan_json:-${TF_PLAN_NAME}.json}" + TF_PLAN_JSON="${default_tf_plan_json:-${GITLAB_TOFU_PLAN_NAME}.json}" fi # Set variables for the HTTP backend to default to TF_* values diff --git a/templates/apply.yml b/templates/apply.yml index 11d0060..c1daee3 100644 --- a/templates/apply.yml +++ b/templates/apply.yml @@ -112,7 +112,7 @@ spec: TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] GITLAB_TOFU_APPLY_NO_PLAN: $[[ inputs.no_plan ]] - TF_PLAN_NAME: $[[ inputs.plan_name ]] + GITLAB_TOFU_PLAN_NAME: $[[ inputs.plan_name ]] GITLAB_TOFU_VAR_FILE: '$[[ inputs.var_file ]]' image: name: '$[[ inputs.image_registry_base ]]/$[[ inputs.image_name ]]:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]-$[[ inputs.base_os ]]$[[ inputs.image_digest ]]' diff --git a/templates/destroy.yml b/templates/destroy.yml index 4a2c46e..e69b2d4 100644 --- a/templates/destroy.yml +++ b/templates/destroy.yml @@ -112,7 +112,7 @@ spec: TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] GITLAB_TOFU_APPLY_NO_PLAN: $[[ inputs.no_plan ]] - TF_PLAN_NAME: $[[ inputs.plan_name ]] + GITLAB_TOFU_PLAN_NAME: $[[ inputs.plan_name ]] GITLAB_TOFU_VAR_FILE: '$[[ inputs.var_file ]]' image: name: '$[[ inputs.image_registry_base ]]/$[[ inputs.image_name ]]:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]-$[[ inputs.base_os ]]$[[ inputs.image_digest ]]' diff --git a/templates/plan.yml b/templates/plan.yml index 9c6371a..2c1412c 100644 --- a/templates/plan.yml +++ b/templates/plan.yml @@ -157,7 +157,7 @@ spec: __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] - TF_PLAN_NAME: $[[ inputs.plan_name ]] + GITLAB_TOFU_PLAN_NAME: $[[ inputs.plan_name ]] GITLAB_TOFU_PLAN_WITH_JSON: true GITLAB_TOFU_VAR_FILE: '$[[ inputs.var_file ]]' image: -- GitLab