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

Pass var file to init

This change set passes the configured var file, if any, to the `tofu
init` command when it's executed.

Closes https://gitlab.com/components/opentofu/-/issues/96

Changelog: changed
parent 296ff938
No related branches found
No related tags found
No related merge requests found
...@@ -217,6 +217,10 @@ fi ...@@ -217,6 +217,10 @@ fi
# Misc variables # Misc variables
var_file="${GITLAB_TOFU_VAR_FILE}" var_file="${GITLAB_TOFU_VAR_FILE}"
var_file_args=""
if [ -n "${var_file}" ]; then
var_file_args="--var-file=${var_file}"
fi
# Helper functions # Helper functions
# ================ # ================
...@@ -282,8 +286,7 @@ tofu_init() { ...@@ -282,8 +286,7 @@ tofu_init() {
fi fi
# shellcheck disable=SC2086 # We want to allow word splitting here for `init_flags` # shellcheck disable=SC2086 # We want to allow word splitting here for `init_flags`
tofu "${tf_chdir_opt}" init "${@}" -input=false ${tofu_init_reconfigure_flag} ${init_flags} \ tofu "${tf_chdir_opt}" init "${@}" -input=false ${tofu_init_reconfigure_flag} ${init_flags} ${var_file_args} 1>&2 || $should_ignore_init_errors
1>&2 || $should_ignore_init_errors
} }
...@@ -357,11 +360,6 @@ if [ $sourced -eq 0 ]; then ...@@ -357,11 +360,6 @@ if [ $sourced -eq 0 ]; then
# Authenticate to private registry # Authenticate to private registry
tofu_authenticate_private_registry tofu_authenticate_private_registry
var_file_args=""
if [ -n "${var_file}" ]; then
var_file_args="--var-file=${var_file}"
fi
case "${1}" in case "${1}" in
"apply") "apply")
$should_do_implicit_init && tofu_init $should_do_implicit_init && tofu_init
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment