Skip to content

Commit d0d08ac

Browse files
authored
feat: Speedup terraform_validate - firstly try run validate without checking is .terraform/ is valid (antonbabenko#524)
1 parent 148eb8f commit d0d08ac

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

hooks/terraform_validate.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ function per_dir_hook_unique_part {
109109
esac
110110
done
111111

112+
# First try `terraform validate` with the hope that all deps are
113+
# pre-installed. That is needed for cases when `.terraform/modules`
114+
# or `.terraform/providers` missed AND that is expected.
115+
terraform validate "${args[@]}" 2>&1 && {
116+
exit_code=$?
117+
return $exit_code
118+
}
119+
120+
# In case `terraform validate` failed to execute
121+
# - check is simple `terraform init` will help
112122
common::terraform_init 'terraform validate' "$dir_path" || {
113123
exit_code=$?
114124
return $exit_code

0 commit comments

Comments
 (0)