From 70a67d253df6ceed8fd19f067c98bf5da34abbce Mon Sep 17 00:00:00 2001 From: Timo Furrer <tfurrer@gitlab.com> Date: Wed, 13 Nov 2024 10:06:43 +0100 Subject: [PATCH] Rename internal `OPENTOFU_COMPONENT_` variables to `GITLAB_TOFU_` Changelog: development --- src/gitlab-tofu.sh | 10 +++++----- templates/apply.yml | 2 +- templates/destroy.yml | 2 +- templates/graph.yml | 2 +- templates/plan.yml | 6 +++--- templates/test.yml | 2 +- templates/validate.yml | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh index 5ffb0a1..52f6d0f 100644 --- a/src/gitlab-tofu.sh +++ b/src/gitlab-tofu.sh @@ -2,7 +2,7 @@ # set some shell options set -o errexit - + if [ "${DEBUG_OUTPUT}" = "true" ]; then set -o xtrace fi @@ -205,8 +205,8 @@ if [ $sourced -eq 0 ]; then terraform_authenticate_private_registry var_file_args="" - if [ -n "${OPENTOFU_COMPONENT_VAR_FILE}" ]; then - var_file_args="--var-file=${OPENTOFU_COMPONENT_VAR_FILE}" + if [ -n "${GITLAB_TOFU_VAR_FILE}" ]; then + var_file_args="--var-file=${GITLAB_TOFU_VAR_FILE}" fi case "${1}" in @@ -238,7 +238,7 @@ if [ $sourced -eq 0 ]; then ;; "plan") plan_args='' - if [ "${OPENTOFU_COMPONENT_USE_DETAILED_EXITCODE}" = 'true' ]; then + if [ "${GITLAB_TOFU_USE_DETAILED_EXITCODE}" = 'true' ]; then plan_args='-detailed-exitcode' fi @@ -246,7 +246,7 @@ if [ $sourced -eq 0 ]; then # shellcheck disable=SC2086 tofu "${TF_CHDIR_OPT}" "${@}" -input=false -out="${TF_PLAN_CACHE}" ${var_file_args} ${plan_args} && ret=$? || ret=$? - if [ "${OPENTOFU_COMPONENT_PLAN_WITH_JSON}" = 'true' ]; then + if [ "${GITLAB_TOFU_PLAN_WITH_JSON}" = 'true' ]; then if [ "$ret" -eq 0 ] || [ "$ret" -eq 2 ]; then if ! tofu "${TF_CHDIR_OPT}" show -json "${TF_PLAN_CACHE}" | jq -r "${JQ_PLAN}" > "${TF_PLAN_JSON}"; then exit $? diff --git a/templates/apply.yml b/templates/apply.yml index ff700da..a4b88ff 100644 --- a/templates/apply.yml +++ b/templates/apply.yml @@ -113,7 +113,7 @@ spec: TF_STATE_NAME: $[[ inputs.state_name ]] TF_APPLY_NO_PLAN: $[[ inputs.no_plan ]] TF_PLAN_NAME: $[[ inputs.plan_name ]] - OPENTOFU_COMPONENT_VAR_FILE: '$[[ inputs.var_file ]]' + 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 ]]' script: diff --git a/templates/destroy.yml b/templates/destroy.yml index a1695f3..b9a8a68 100644 --- a/templates/destroy.yml +++ b/templates/destroy.yml @@ -113,7 +113,7 @@ spec: TF_STATE_NAME: $[[ inputs.state_name ]] TF_APPLY_NO_PLAN: $[[ inputs.no_plan ]] TF_PLAN_NAME: $[[ inputs.plan_name ]] - OPENTOFU_COMPONENT_VAR_FILE: '$[[ inputs.var_file ]]' + 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 ]]' script: diff --git a/templates/graph.yml b/templates/graph.yml index 641c4be..885252d 100644 --- a/templates/graph.yml +++ b/templates/graph.yml @@ -105,7 +105,7 @@ spec: __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] - OPENTOFU_COMPONENT_VAR_FILE: '$[[ inputs.var_file ]]' + 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 ]]' script: diff --git a/templates/plan.yml b/templates/plan.yml index a5e7b7b..9c6371a 100644 --- a/templates/plan.yml +++ b/templates/plan.yml @@ -112,7 +112,7 @@ spec: '.$[[ inputs.as ]]:detailed_exitcode:warning:true': variables: - OPENTOFU_COMPONENT_USE_DETAILED_EXITCODE: '$[[ inputs.warning_on_non_empty_plan ]]' + GITLAB_TOFU_USE_DETAILED_EXITCODE: '$[[ inputs.warning_on_non_empty_plan ]]' # NOTE: we rely on correct exitcode reporting behavior for the `warning_on_non_empty_plan` input # behavior. However, when using bash the runner does not work properly without setting # the feature flag below to `true`. @@ -158,8 +158,8 @@ spec: TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] TF_PLAN_NAME: $[[ inputs.plan_name ]] - OPENTOFU_COMPONENT_PLAN_WITH_JSON: true - OPENTOFU_COMPONENT_VAR_FILE: '$[[ inputs.var_file ]]' + GITLAB_TOFU_PLAN_WITH_JSON: true + 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 ]]' script: diff --git a/templates/test.yml b/templates/test.yml index 0a090bf..c8cc5da 100644 --- a/templates/test.yml +++ b/templates/test.yml @@ -108,7 +108,7 @@ spec: __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] - OPENTOFU_COMPONENT_VAR_FILE: '$[[ inputs.var_file ]]' + 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 ]]' script: diff --git a/templates/validate.yml b/templates/validate.yml index e328631..61e5ac2 100644 --- a/templates/validate.yml +++ b/templates/validate.yml @@ -105,7 +105,7 @@ spec: TF_ROOT: $[[ inputs.root_dir ]] TF_STATE_NAME: $[[ inputs.state_name ]] TF_IGNORE_INIT_ERRORS: 'true' # Tofu can report errors which might be the reason init failed. - OPENTOFU_COMPONENT_VAR_FILE: '$[[ inputs.var_file ]]' + 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 ]]' script: -- GitLab