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

command: Add -check flag to fmt #15387

Merged
merged 2 commits into from
Sep 14, 2017

Conversation

kylemcc
Copy link
Contributor

@kylemcc kylemcc commented Jun 23, 2017

This addresses #15304. There are a couple ways to solve this, but I chose to modify the fmt command with a -check flag that produces the desired behavior.

I chose not to put this functionality in github.com/hashicorp/hcl/hcl/fmtcmd, because that would have required a change to the API. That has broader implications. If the consensus is that said functionality would be useful outside of terraform fmt, I can move the logic to the hcl lib.

Alternatively, fmt could have been updated to alter its return code without the -check flag - like gofmt. However, as pointed out, that changes the current behavior which could have a downstream impact. Additionally, the default semantics of terraform fmt are different from gofmt. Namely, -write defaults to true with terraform fmt, but false with gofmt. Unless that default were changed (which seems like bad idea), you would need to run terraform fmt -write=false to achieve the requested effect. terraform fmt -check seems simpler and more intuitive to me.

@kylemcc kylemcc force-pushed the terraform-fmt-check branch from 3531791 to c2d86ed Compare July 21, 2017 19:42
@apparentlymart apparentlymart merged commit b95610c into hashicorp:master Sep 14, 2017
@apparentlymart
Copy link
Contributor

Thanks for working on this, @kylemcc! Sorry it took so long to get reviewed.

@kylemcc
Copy link
Contributor Author

kylemcc commented Sep 14, 2017

👍

@ghost
Copy link

ghost commented Apr 7, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants