Make terraform fmt more verbose
The following discussion from !69470 (merged) should be addressed:
-
@marcel.amirault started a discussion: (+2 comments) @willianpaixao Thanks a lot for the contribution! I agree with @Alexand that this looks good!
As a sidenote, I really wish
fmt
had a bit more verbose output. Something like "These files are not formatted:" or "All checked files are formatted." (but that's outside the scope of this MR). @Alexand, do you think we should raise a follow-up issue to write a little script that makes the output nicer, or will the average user of this template be OK with the "dry" output?Also, thanks a lot for the test pipeline links, the fail/pass examples were just what I needed!
🙇
Proposed solutions
-
Simply add the
-diff
flag.# lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml - - gitlab-terraform fmt -check -recursive + - gitlab-terraform fmt -check -recursive -diff
-
(optional) collect the exit code of the
terraform fmt...
command and echo a message explaining how to fix it. Something like:
To fix your terraform format, run locally:
terraform fmt -recursive