mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
feat: Allow terraform_providers_lock specify terraform init args (#406)
This commit is contained in:
parent
0f25122485
commit
32b232f039
4 changed files with 57 additions and 23 deletions
|
|
@ -88,8 +88,6 @@ function parse_cmdline_ {
|
|||
# args (string with array) arguments that configure wrapped tool behavior
|
||||
# dir_path (string) PATH to dir relative to git repo root.
|
||||
# Can be used in error logging
|
||||
# Globals:
|
||||
# INIT_ARGS (array) arguments for `terraform init` command`
|
||||
# ENVS (array) environment variables that will be used with
|
||||
# `terraform` commands
|
||||
# Outputs:
|
||||
|
|
@ -100,19 +98,12 @@ function per_dir_hook_unique_part {
|
|||
local -r dir_path="$2"
|
||||
|
||||
local exit_code
|
||||
local init_output
|
||||
local validate_output
|
||||
|
||||
if [ ! -d .terraform ]; then
|
||||
init_output=$(terraform init -backend=false "${INIT_ARGS[@]}" 2>&1)
|
||||
common::terraform_init 'terraform validate' "$dir_path" || {
|
||||
exit_code=$?
|
||||
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
common::colorify "yellow" "'terraform init' failed, 'terraform validate' skipped: $dir_path"
|
||||
echo "$init_output"
|
||||
return $exit_code
|
||||
fi
|
||||
fi
|
||||
return $exit_code
|
||||
}
|
||||
|
||||
# pass the arguments to hook
|
||||
# shellcheck disable=SC2068 # hook fails when quoting is used ("$arg[@]")
|
||||
|
|
@ -129,7 +120,6 @@ function per_dir_hook_unique_part {
|
|||
}
|
||||
|
||||
# global arrays
|
||||
declare -a INIT_ARGS
|
||||
declare -a ENVS
|
||||
|
||||
[ "${BASH_SOURCE[0]}" != "$0" ] || main "$@"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue