Skip to content
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

feat: Speedup terraform_validate - firstly try run validate without checking is .terraform/ is valid #524

Merged
merged 3 commits into from
Jun 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hooks/terraform_validate.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -eo pipefail


MaxymVlasov marked this conversation as resolved.
Show resolved Hide resolved
# 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)"
Expand Down Expand Up @@ -104,6 +105,12 @@ function per_dir_hook_unique_part {
esac
done

# first try to terraform validate without prior terraform init call
MaxymVlasov marked this conversation as resolved.
Show resolved Hide resolved
terraform validate "${args[@]}" 2>&1 && {
exit_code=$?
return $exit_code
}

MaxymVlasov marked this conversation as resolved.
Show resolved Hide resolved
common::terraform_init 'terraform validate' "$dir_path" || {
exit_code=$?
return $exit_code
Expand Down