Skip to content
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

feat: Add argument like force-init to do init before terraform validate #224

Closed
antonbabenko opened this issue Sep 14, 2021 · 1 comment
Closed
Labels
estimate/2h Need 2 hours to be done feature New feature or request good first issue Good for newcomers hook/terraform_validate Bash hook

Comments

@antonbabenko
Copy link
Owner

antonbabenko commented Sep 14, 2021

Add an argument to terraform_validate to run terraform init before running terraform validate.

Originally posted by @eytanhanig in #203 (comment)

Notes fo contributors:


Additionally to force-init option, we can use terraform providers and run terraform init if necessary, automatically. See this comment for more details - #299 (comment)

@MaxymVlasov
Copy link
Collaborator

Not needed anymore. The current realization is superior to that

If there are no deps for t validate - it will fail in a fraction of a second, so no need to "force-init"

# 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[@]}" &> /dev/null && {
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
}
if [ "$retry_once_with_cleanup" != "true" ]; then
# terraform validate only
validate_output=$(terraform validate "${args[@]}" 2>&1)
exit_code=$?
else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
estimate/2h Need 2 hours to be done feature New feature or request good first issue Good for newcomers hook/terraform_validate Bash hook
Projects
None yet
2 participants