mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
feat: Add support for version constraints in tfupdate (#437)
This commit is contained in:
parent
f5aa7c83b6
commit
a4466425fb
12 changed files with 140 additions and 112 deletions
|
|
@ -13,37 +13,36 @@ function main {
|
|||
common::export_provided_env_vars "${ENV_VARS[@]}"
|
||||
common::parse_and_export_env_vars
|
||||
# Support for setting PATH to repo root.
|
||||
# shellcheck disable=SC2178 # It's the simplest syntax for that case
|
||||
ARGS=${ARGS[*]/__GIT_WORKING_DIR__/$(pwd)\/}
|
||||
for i in "${!ARGS[@]}"; do
|
||||
ARGS[i]=${ARGS[i]/__GIT_WORKING_DIR__/$(pwd)\/}
|
||||
done
|
||||
|
||||
# Suppress tfsec color
|
||||
if [ "$PRE_COMMIT_COLOR" = "never" ]; then
|
||||
# shellcheck disable=SC2178,SC2128 # It's the simplest syntax for that case
|
||||
ARGS+=" --no-color"
|
||||
ARGS+=("--no-color")
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2128 # It's the simplest syntax for that case
|
||||
common::per_dir_hook "$ARGS" "$HOOK_ID" "${FILES[@]}"
|
||||
common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}"
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# Unique part of `common::per_dir_hook`. The function is executed in loop
|
||||
# on each provided dir path. Run wrapped tool with specified arguments
|
||||
# Arguments:
|
||||
# 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
|
||||
# args (array) arguments that configure wrapped tool behavior
|
||||
# Outputs:
|
||||
# If failed - print out hook checks status
|
||||
#######################################################################
|
||||
function per_dir_hook_unique_part {
|
||||
local -r args="$1"
|
||||
# shellcheck disable=SC2034 # Unused var.
|
||||
local -r dir_path="$2"
|
||||
local -r dir_path="$1"
|
||||
shift
|
||||
local -a -r args=("$@")
|
||||
|
||||
# pass the arguments to hook
|
||||
# shellcheck disable=SC2068 # hook fails when quoting is used ("$arg[@]")
|
||||
tfsec ${args[@]}
|
||||
tfsec "${args[@]}"
|
||||
|
||||
# return exit code to common::per_dir_hook
|
||||
local exit_code=$?
|
||||
|
|
@ -54,14 +53,13 @@ function per_dir_hook_unique_part {
|
|||
# Unique part of `common::per_dir_hook`. The function is executed one time
|
||||
# in the root git repo
|
||||
# Arguments:
|
||||
# args (string with array) arguments that configure wrapped tool behavior
|
||||
# args (array) arguments that configure wrapped tool behavior
|
||||
#######################################################################
|
||||
function run_hook_on_whole_repo {
|
||||
local -r args="$1"
|
||||
local -a -r args=("$@")
|
||||
|
||||
# pass the arguments to hook
|
||||
# shellcheck disable=SC2068 # hook fails when quoting is used ("$arg[@]")
|
||||
tfsec "$(pwd)" ${args[@]}
|
||||
tfsec "$(pwd)" "${args[@]}"
|
||||
|
||||
# return exit code to common::per_dir_hook
|
||||
local exit_code=$?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue