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

This commit is contained in:
Sebastian Melchior 2023-06-12 17:59:13 +02:00 committed by GitHub
commit d0d08ac63c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -109,6 +109,16 @@ function per_dir_hook_unique_part {
esac
done
# First try `terraform validate` with the hope that all deps are
# pre-installed. That is needed for cases when `.terraform/modules`
# or `.terraform/providers` missed AND that is expected.
terraform validate "${args[@]}" 2>&1 && {
exit_code=$?
return $exit_code
}
# In case `terraform validate` failed to execute
# - check is simple `terraform init` will help
common::terraform_init 'terraform validate' "$dir_path" || {
exit_code=$?
return $exit_code