diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh index 80a82db6caec13eee6ece2719dcde01048d88f14..d95f0fcb7bc0fbaf346a548e9faf30cfb341b688 100644 --- a/src/gitlab-tofu.sh +++ b/src/gitlab-tofu.sh @@ -16,7 +16,8 @@ # 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` -# GITLAB_TOFU_IMPLICIT_INIT: if set to true will perform an implicit tofu init before any command that require it. Defaults to `true`. +# GITLAB_TOFU_IMPLICIT_INIT: if set to true will perform an implicit `tofu init` before any command that require it. Defaults to `true`. +# GITLAB_TOFU_IGNORE_INIT_ERRORS: if set to true will ignore errors in the `tofu init` command. # # Respected OpenTofu Environment Variables: # > these are variables that are @@ -208,7 +209,7 @@ terraform_authenticate_private_registry() { GITLAB_TOFU_IMPLICIT_INIT=${GITLAB_TOFU_IMPLICIT_INIT:-true} # Allows users to continue the actual command in case init failed -TF_IGNORE_INIT_ERRORS=${TF_IGNORE_INIT_ERRORS:-false} +GITLAB_TOFU_IGNORE_INIT_ERRORS=${GITLAB_TOFU_IGNORE_INIT_ERRORS:-false} terraform_init() { # If TF_INIT_NO_RECONFIGURE is not set to 'true', @@ -220,7 +221,7 @@ terraform_init() { # We want to allow word splitting here for TF_INIT_FLAGS # shellcheck disable=SC2086 tofu "${tf_chdir_opt}" init "${@}" -input=false ${tf_init_reconfigure_flag} ${TF_INIT_FLAGS} \ - 1>&2 || $TF_IGNORE_INIT_ERRORS + 1>&2 || $GITLAB_TOFU_IGNORE_INIT_ERRORS } # If this script is executed and not sourced, a terraform command is ran. diff --git a/templates/validate.yml b/templates/validate.yml index 61e5ac2e434f4d4d4d53d919fc03ca4748a3db62..3bd868d902f1bc1b877ac82fe4c174fe6fa3a0a8 100644 --- a/templates/validate.yml +++ b/templates/validate.yml @@ -104,7 +104,7 @@ spec: __CACHE_KEY_HACK: "$[[ inputs.root_dir ]]" 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. + GITLAB_TOFU_IGNORE_INIT_ERRORS: 'true' # Tofu can report errors which might be the reason init failed. 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 ]]'