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

Support -diff=true option in FormatCheck function #288

Open
Vince-Chenal opened this issue Apr 7, 2022 · 2 comments
Open

Support -diff=true option in FormatCheck function #288

Vince-Chenal opened this issue Apr 7, 2022 · 2 comments
Labels
question Further information is requested

Comments

@Vince-Chenal
Copy link

It would be nice being able to get the diffs output from terraform fmt command.

@radeksimko
Copy link
Member

Hi @Vince-Chenal
As far as I can tell the fmt -diff flag is not considered a stable interface from Terraform's perspective, as it doesn't control the output - internally Terraform just calls out to diff and basically passes the output back to the user - i.e. while diff is likely to have stable output itself, Terraform has no control over the stability of it.

https://github.com/hashicorp/terraform/blob/6d03303b7917be206a7fad0c8fe5838af0ac11a9/internal/command/fmt.go#L566-L591

On the positive side you could probably relatively easily implement comparable functionality yourself by copying that linked bytesDiff function from there and pass formatted & unformatted []byte + filename into it, and use that alongside the tfexec.Format(). Would that work for you?

cc @kmoe to confirm the stability expectations on Core side

@radeksimko radeksimko added the question Further information is requested label Apr 7, 2022
@Vince-Chenal
Copy link
Author

Thanks for you answer @radeksimko 👍
I was going to implement it myself but wanted to make sure it could not be handled from within tfexec.
I'll try implementing your option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants