diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh index 5ffb0a14e3e6d46d37418b870f5d4ee05af55497..52f6d0f2e44d7eb235da89d887634a66f6dafb9d 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 ff700daf54a404e839bd2adb2561b515a4d36281..a4b88ff94cb1d1966573ad631024a8c5a9e81d41 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 a1695f334b4e2548039355cd928674c00f8612f2..b9a8a68b9d1cfa0117bc8ff082b8e5762930a4b4 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 641c4be7f41de148c6e2a5fc59deb8062808d6ab..885252d9784b88198f46484b0e3ee423028af961 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 a5e7b7b178cdb3057cbef5818ac3923d02d8dbf2..9c6371ac1697b317d63de6e6524c4cdf9f861873 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 0a090bf7bca82373e5b026d21d5d1140e65c02df..c8cc5da1c6824986464751a12536271761b38597 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 e328631fff8fc93133a859282aa9864b987551ca..61e5ac2e434f4d4d4d53d919fc03ca4748a3db62 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: