From 3ce2b6436f4288220f2e98b5e6c5ed8d92209a2e Mon Sep 17 00:00:00 2001 From: Timo Furrer <tfurrer@gitlab.com> Date: Wed, 13 Nov 2024 15:09:12 +0100 Subject: [PATCH] Rename `TF_PLAN_JSON` to `GITLAB_TOFU_PLAN_JSON` Changelog: changed --- src/gitlab-tofu.sh | 11 ++++++----- templates/apply.yml | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh index 9790356..7c7826e 100644 --- a/src/gitlab-tofu.sh +++ b/src/gitlab-tofu.sh @@ -15,6 +15,7 @@ # 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`. # GITLAB_TOFU_PLAN_CACHE: if set is the full path of the plan cache file. Defaults to `<root>/$GITLAB_TOFU_PLAN_NAME.cache` +# GITLAB_TOFU_PLAN_JSON: if set is the full path of the plan json file. Defaults to `<root>/$GITLAB_TOFU_PLAN_NAME.json` # # Respected OpenTofu Environment Variables: # > these are variables that are @@ -134,9 +135,9 @@ if [ -z "${GITLAB_TOFU_PLAN_CACHE}" ]; then GITLAB_TOFU_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:-${GITLAB_TOFU_PLAN_NAME}.json}" +# If GITLAB_TOFU_PLAN_JSON is not set then use either the plan.json file within TF_ROOT if set, or plan.json in CWD +if [ -z "${GITLAB_TOFU_PLAN_JSON}" ]; then + GITLAB_TOFU_PLAN_JSON="${default_tf_plan_json:-${GITLAB_TOFU_PLAN_NAME}.json}" fi # Set variables for the HTTP backend to default to TF_* values @@ -265,7 +266,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}" > "${TF_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 @@ -277,7 +278,7 @@ if [ $sourced -eq 0 ]; then exit "$ret" ;; "plan-json") - tofu "${TF_CHDIR_OPT}" show -json "${GITLAB_TOFU_PLAN_CACHE}" | jq -r "${JQ_PLAN}" > "${TF_PLAN_JSON}" + tofu "${TF_CHDIR_OPT}" show -json "${GITLAB_TOFU_PLAN_CACHE}" | jq -r "${JQ_PLAN}" > "${GITLAB_TOFU_PLAN_JSON}" ;; "validate") $TF_IMPLICIT_INIT && terraform_init -backend=false diff --git a/templates/apply.yml b/templates/apply.yml index c1daee3..4178f01 100644 --- a/templates/apply.yml +++ b/templates/apply.yml @@ -75,7 +75,7 @@ spec: description: 'Whether a plan file should be used.' plan_name: default: 'plan' - description: 'The name of the plan file to use. Will be used for TF_PLAN_CACHE and TF_PLAN_JSON.' + description: 'The name of the plan file to use. Will be used for plan cache and json files.' var_file: default: '' type: string -- GitLab