Skip to content
Snippets Groups Projects
Unverified Commit 3ce2b643 authored by Timo Furrer's avatar Timo Furrer
Browse files

Rename `TF_PLAN_JSON` to `GITLAB_TOFU_PLAN_JSON`

Changelog: changed
parent fe5fea97
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ ...@@ -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_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_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_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: # Respected OpenTofu Environment Variables:
# > these are variables that are # > these are variables that are
...@@ -134,9 +135,9 @@ if [ -z "${GITLAB_TOFU_PLAN_CACHE}" ]; then ...@@ -134,9 +135,9 @@ if [ -z "${GITLAB_TOFU_PLAN_CACHE}" ]; then
GITLAB_TOFU_PLAN_CACHE="${default_tf_plan_cache:-${GITLAB_TOFU_PLAN_NAME}.cache}" GITLAB_TOFU_PLAN_CACHE="${default_tf_plan_cache:-${GITLAB_TOFU_PLAN_NAME}.cache}"
fi 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 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 "${TF_PLAN_JSON}" ]; then if [ -z "${GITLAB_TOFU_PLAN_JSON}" ]; then
TF_PLAN_JSON="${default_tf_plan_json:-${GITLAB_TOFU_PLAN_NAME}.json}" GITLAB_TOFU_PLAN_JSON="${default_tf_plan_json:-${GITLAB_TOFU_PLAN_NAME}.json}"
fi fi
# Set variables for the HTTP backend to default to TF_* values # Set variables for the HTTP backend to default to TF_* values
...@@ -265,7 +266,7 @@ if [ $sourced -eq 0 ]; then ...@@ -265,7 +266,7 @@ if [ $sourced -eq 0 ]; then
if [ "${GITLAB_TOFU_PLAN_WITH_JSON}" = 'true' ]; then if [ "${GITLAB_TOFU_PLAN_WITH_JSON}" = 'true' ]; then
if [ "$ret" -eq 0 ] || [ "$ret" -eq 2 ]; 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 $? exit $?
fi fi
...@@ -277,7 +278,7 @@ if [ $sourced -eq 0 ]; then ...@@ -277,7 +278,7 @@ if [ $sourced -eq 0 ]; then
exit "$ret" exit "$ret"
;; ;;
"plan-json") "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") "validate")
$TF_IMPLICIT_INIT && terraform_init -backend=false $TF_IMPLICIT_INIT && terraform_init -backend=false
......
...@@ -75,7 +75,7 @@ spec: ...@@ -75,7 +75,7 @@ spec:
description: 'Whether a plan file should be used.' description: 'Whether a plan file should be used.'
plan_name: plan_name:
default: 'plan' 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: var_file:
default: '' default: ''
type: string type: string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment