-
-
Notifications
You must be signed in to change notification settings - Fork 583
feat: Add terragrunt_providers_lock hook
#632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MaxymVlasov
merged 12 commits into
antonbabenko:master
from
wzooff:feat/add-terragrunt-providers-lock
Feb 22, 2024
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d1abce1
feat: add terragrunt_providers_lock hook
wzooff 78fb7a8
make executable
wzooff 5b9e33a
update readme
wzooff 582d87b
adjust include exclude files
wzooff 3c974c4
remove trailing spaces
wzooff 8ccb5ef
amend table of contents
wzooff 796df1a
optimize hook regexp
wzooff 056083a
Revert "remove trailing spaces"
wzooff 75a05e8
amend available hooks section
wzooff 97a352f
amend hook usage section
wzooff 2fda000
Minor docs changes
MaxymVlasov 4828847
Apply suggestions from code review
MaxymVlasov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| #!/usr/bin/env bash | ||
| set -eo pipefail | ||
|
|
||
| # globals variables | ||
| # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines | ||
| readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" | ||
| # shellcheck source=_common.sh | ||
| . "$SCRIPT_DIR/_common.sh" | ||
|
|
||
| function main { | ||
| common::initialize "$SCRIPT_DIR" | ||
| common::parse_cmdline "$@" | ||
| common::export_provided_env_vars "${ENV_VARS[@]}" | ||
| common::parse_and_export_env_vars | ||
| # JFYI: terragrunt providers lock color already suppressed via PRE_COMMIT_COLOR=never | ||
|
|
||
| # shellcheck disable=SC2153 # False positive | ||
| 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: | ||
| # dir_path (string) PATH to dir relative to git repo root. | ||
| # Can be used in error logging | ||
| # change_dir_in_unique_part (string/false) Modifier which creates | ||
| # possibilities to use non-common chdir strategies. | ||
| # Availability depends on hook. | ||
| # parallelism_disabled (bool) if true - skip lock mechanism | ||
| # args (array) arguments that configure wrapped tool behavior | ||
| # Outputs: | ||
| # If failed - print out hook checks status | ||
| ####################################################################### | ||
| function per_dir_hook_unique_part { | ||
| # shellcheck disable=SC2034 # Unused var. | ||
| local -r dir_path="$1" | ||
| # shellcheck disable=SC2034 # Unused var. | ||
| local -r change_dir_in_unique_part="$2" | ||
| # shellcheck disable=SC2034 # Unused var. | ||
| local -r parallelism_disabled="$3" | ||
| shift 3 | ||
| local -a -r args=("$@") | ||
|
|
||
| # pass the arguments to hook | ||
| terragrunt providers lock "${args[@]}" | ||
|
|
||
| # return exit code to common::per_dir_hook | ||
| local exit_code=$? | ||
| return $exit_code | ||
| } | ||
|
|
||
| ####################################################################### | ||
| # Unique part of `common::per_dir_hook`. The function is executed one time | ||
| # in the root git repo | ||
| # Arguments: | ||
| # args (array) arguments that configure wrapped tool behavior | ||
| ####################################################################### | ||
| function run_hook_on_whole_repo { | ||
| local -a -r args=("$@") | ||
|
|
||
| # pass the arguments to hook | ||
| terragrunt run-all providers lock "${args[@]}" | ||
|
|
||
| # return exit code to common::per_dir_hook | ||
| local exit_code=$? | ||
| return $exit_code | ||
| } | ||
|
|
||
| [ "${BASH_SOURCE[0]}" != "$0" ] || main "$@" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.