Skip to content

Update terraform-fmt to match terraform-validate#46

Merged
brikis98 merged 2 commits intomasterfrom
brikis98-patch-1
Dec 10, 2020
Merged

Update terraform-fmt to match terraform-validate#46
brikis98 merged 2 commits intomasterfrom
brikis98-patch-1

Conversation

@brikis98
Copy link
Member

@brikis98 brikis98 commented Dec 9, 2020

This PR updates the terraform-fmt hook as follows:

  1. Run with -diff -check so the differences are printed, rather than made on disk.
  2. Instead of exiting on the first error, save the exit codes, and print out all fmt errors before exiting.

These changes are very similar to #45.

This PR updates the `terraform-fmt` hook as follows:

1. Extract all the directories with Terraform code first and run `terraform fmt` once per directory. 
1. Print out the directory where we're running `terraform fmt` to make debugging errors much easier.
1. Instead of exiting on the first error, save the exit codes, and print out all `fmt` errors before exiting.

These changes are very similar to #45.
Co-authored-by: David Alger <davidmalger@gmail.com>
@brikis98
Copy link
Member Author

Seems to work great! PR updated.

@zackproser zackproser self-requested a review December 10, 2020 14:58
Copy link
Contributor

@zackproser zackproser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brikis98
Copy link
Member Author

Thanks for the review! Merging now.

@brikis98 brikis98 merged commit e9250bd into master Dec 10, 2020
@brikis98 brikis98 deleted the brikis98-patch-1 branch December 10, 2020 16:11
@brikis98
Copy link
Member Author

@ayk33
Copy link

ayk33 commented Jul 9, 2021

What was the reason for adding -check? It was kind of nice having it automatically format the tf code for you instead of someone manually making the changes that need to be made?

@L1ghtn1ng
Copy link

What was the reason for adding -check? It was kind of nice having it automatically format the tf code for you instead of someone manually making the changes that need to be made?

I second this as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants