-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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: "terraform show" to render plans like "terraform plan" #23292
Conversation
During the Terraform 0.12 work we briefly had a partial update of the old Terraform 0.11 (and prior) diff renderer that could work with the new plan structure, but could produce only partial results. We switched to the new plan implementation prior to release, but the "terraform show" command was left calling into the old partial implementation, and thus produced incomplete results when rendering a saved plan. Here we instead use the plan rendering logic from the "terraform plan" command, making the output of both identical. Unfortunately, due to the current backend architecture that logic lives inside the local backend package, and it contains some business logic around state and schema wrangling that would make it inappropriate to move wholesale into the command/format package. To allow for a low-risk fix to the "terraform show" output, here we avoid some more severe refactoring by just exporting the rendering functionality in a way that allows the "terraform show" command to call into it. In future we'd like to move all of the code that actually writes to the output into the "command" package so that the roles of these components are better segregated, but that is too big a change to block fixing this issue.
This "Plan" type, along with the other types it directly or indirectly embeds and the associated functions, are adaptations of the flatmap-oriented plan renderer logic from Terraform 0.11 and prior. The current diff rendering logic is in diff.go, and so the contents of the plan.go file are defunct apart from the DiffActionSymbol function that both implementations share. Therefore here we move DiffActionSymbol into diff.go and then remove plan.go entirely, in the interests of dead code removal.
// can call into it, but we're leaving it here for now in order to avoid | ||
// disruptive refactoring. | ||
// | ||
// If you find yourself wanting to call this function from a third callsite, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this comment
Thank you ! That was quick, hats off to you. |
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. |
During the Terraform 0.12 work we briefly had a partial update of the old Terraform 0.11 (and prior) diff renderer that could work with the new plan structure, but could produce only partial results.
We switched to the new plan implementation prior to release, but the
terraform show
command was left calling into the old partial implementation, and thus produced incomplete results when rendering a saved plan.Here we instead use the plan rendering logic from the
terraform plan
command, making the output of both identical.This fixes #23106.
Unfortunately, due to the current backend architecture that logic lives inside the
backend/local
, and it contains some business logic around state and schema wrangling that would make it inappropriate to move wholesale into thecommand/format
package. To allow for a low-risk fix to theterraform show
output, here we avoid some more severe refactoring by just exporting the rendering functionality in a way that allows theterraform show
command to call into it.In future we'd like to move all of the code that actually writes to the output into the
command
package so that the roles of these components are better segregated, but that is too big a change to block fixing this issue.This also left lots of dead code in
command/format
for the old and mostly-broken plan renderer. In order to reduce naming confusion in thecommand/format
package I've removedplan.go
entirely after removing the one function that was still used from there (DiffActionSymbol
) intodiff.go
.