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 colored Terraform Plan diffs #51

Open
MPV opened this issue Oct 21, 2021 · 4 comments
Open

Support colored Terraform Plan diffs #51

MPV opened this issue Oct 21, 2021 · 4 comments

Comments

@MPV
Copy link

MPV commented Oct 21, 2021

Wouldn't it be cool to support something like on the image below?

i.e. for any terraform syntax-highligted terraform plan output in GitHub (now that it's used there since #5)

(the above was inspired by what they're doing over at https://github.com/robburger/terraform-pr-commenter)

Any ideas of what changes in this repo might be needed in order to support this?

@radeksimko
Copy link
Collaborator

Hi @MPV 👋🏻
As you may be aware, the default terraform plan output is designed to be human readable, as such it comes without any stability guarantees. While maintaining highlighting grammar is possible, it's going to be fragile.

I do not necessarily represent @alexlouden's views here, but speaking for my team at HashiCorp, we have plans to maintain a canonical generic HCL syntax grammar and such grammar would unlikely support any such human-readable diff output.


What may be worth exploring though is some processing of the machine-readable JSON plan output. It should contain basically all the same details that the human-readable output does, or more and it was designed for external integrations just like these and it does come with compatibility guarantees.

It does of course mean that you would need to come up with your own "human-readable" format, but the current default terraform plan is designed for terminal and trying to display it anywhere else is going to be difficult anyway. This provides you the opportunity to format it in a way that's more convenient for GitHub.

@FichteFoll
Copy link
Member

FichteFoll commented Jul 24, 2024

Asking out of curiosity, in which situation would you want to view the plan output in your editor? And, if not in an editor, where would you want to view it?

@michaelblyons
Copy link

michaelblyons commented Aug 1, 2024

Maybe there's a build that does that in the output pane? But honestly it just looks like Diff syntax to me, plus the weird -/+ destroy/create, and optionally (very optionally) highlight the "reason" part at the end.

@FichteFoll
Copy link
Member

Hm fair, that is the output of terraform plan after all. I also added a project-specific build system for me (for terraform validate) but I'm not sure how generally applicable it is to always run that on the current file's directory, though seeing how the cli doesn't accept a path parameter anyway that seems like the only sane way regardless.

In that sense: yes, if we want to add a build system for the plan command, it makes total sense to also have a syntax for it.

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

No branches or pull requests

4 participants