-
Notifications
You must be signed in to change notification settings - Fork 0
ci: Fixing pre-commit validate hook #6
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
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the terraform_validate_docker hook to provide feature parity with the script-based terraform_validate hook by implementing automatic retry logic for handling missing providers and modules.
- Replaces direct
terraform validatecall with the existing validation script that includes retry logic - Enables automatic
terraform initand retry behavior when validation fails due to missing dependencies - Updates hook description to clarify the new automatic initialization behavior
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Put an
xinto the box if that apply:Description of your changes
This PR fixes the
terraform_validate_dockerhook to properly handle missing providers and modules by implementing automatic retry logic withterraform init.Problem: The
terraform_validate_dockerhook was previously configured to runterraform validatedirectly, without the retry logic present in the script-basedterraform_validatehook. As a result, if validation failed due to missing providers or uninitialized modules, the Docker hook would fail immediately instead of attempting to runterraform initand retry.Solution: The hook is now configured to:
/usr/bin/hooks/terraform_validate.shscript (already present in the Docker image) instead of callingterraform validatedirectly.--retry-once-with-cleanup=trueby default to automatically handle missing provider/module scenarios.terraform validateterraform initand retry.terraform/modulesand.terraform/providersdirectories and retry once moreThis ensures feature parity between the script-based and Docker-based validation hooks, providing a consistent user experience regardless of which version is used.
How can we test changes
Test with missing providers:
.terraformdirectory.terraform_validate_dockerhook and verify it automatically runsterraform initand succeeds.Test retry logic with corrupted state:
.terraform/providersor.terraform/modules.Compare with script-based hook:
terraform_validateandterraform_validate_dockerhooks.Test in CI/CD environments: