With introduction of mode support to terraform_providers_lock hooks it should be possible to run the hook without terraform_validate when mode=only-check-is-current-lockfile-cross-platform, but it is not working as advertised.
It works as advertised only when lockfile_contains_all_needed_sha returns 0 = when the lock file is valid. If it NOT valid, for example it is missing hash for some platform, the condition
|
lockfile_contains_all_needed_sha "$platforms_count"; then |
fails and code continues and runs
terraform providers lock on line
|
"$tf_path" providers lock "${args[@]}" |
.
IMHO the condition could be rewritten to:
if [ "$mode" == "only-check-is-current-lockfile-cross-platform" ] ; then
lockfile_contains_all_needed_sha "$platforms_count"
exit_code=$?
return $exit_code
fi
In this case it could be executed in mode=only-check-is-current-lockfile-cross-platform without running terraform_validate which runs terraform init under the hood.
With introduction of
modesupport toterraform_providers_lockhooks it should be possible to run the hook withoutterraform_validatewhenmode=only-check-is-current-lockfile-cross-platform, but it is not working as advertised.It works as advertised only when
lockfile_contains_all_needed_shareturns0= when the lock file is valid. If it NOT valid, for example it is missing hash for some platform, the conditionpre-commit-terraform/hooks/terraform_providers_lock.sh
Line 150 in cba8773
terraform providers lockon linepre-commit-terraform/hooks/terraform_providers_lock.sh
Line 158 in cba8773
IMHO the condition could be rewritten to:
In this case it could be executed in
mode=only-check-is-current-lockfile-cross-platformwithout runningterraform_validatewhich runsterraform initunder the hood.