Terraform.tmLanguage icon indicating copy to clipboard operation
Terraform.tmLanguage copied to clipboard

Support colored Terraform Plan diffs

Open MPV opened this issue 4 years ago • 4 comments
trafficstars

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?

MPV avatar Oct 21 '21 09:10 MPV

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.

radeksimko avatar Oct 21 '21 11:10 radeksimko