Skip to content

Commit

Permalink
feat: Speedup terraform_validate - firstly try run validate without…
Browse files Browse the repository at this point in the history
… checking is `.terraform/` is valid (#524)
  • Loading branch information
smelchior committed Jun 12, 2023
1 parent 148eb8f commit d0d08ac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions hooks/terraform_validate.sh
Expand Up @@ -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
Expand Down

0 comments on commit d0d08ac

Please sign in to comment.