terraform/internal/command/jsonplan
Martin Atkins 884e1fb2a4 terraform: Plans can be "complete" and "applyable"
These ideas are both already implied by some logic elsewhere in the system,
but until now we didn't have the decision logic centralized in a single
place that could therefore evolve over time without necessarily always
updating every caller together.

We'll now have the modules runtime produce its own boolean ruling about
each characteristic, which callers can rely on for the mechanical
decision-making of whether to offer the user an "approve" prompt, and
whether to remind the user after apply that it was an incomplete plan
that will probably therefore need at least one more plan/apply round to
converge.

The "Applyable" flag directly replaces the previous method Plan.CanApply,
with equivalent logic. Making this a field instead of a method means that
we can freeze it as part of a saved plan, rather than recalculating it
when we reload the plan, and we can export the field value in our export
formats like JSON while ensuring it'll always be consistent with what
Terraform is using internally.

Callers can (and should) still use other context in the plan to return
more tailored messages for specific situations they already know about
that might be useful to users, but with these flags as a baseline callers
can now just fall back to a generic presentation when encountering a
situation they don't yet understand, rather than making the wrong decision
and causing something strange to happen. That is: a lack of awareness of
a new rule will now cause just a generic message in the UI, rather than
incorrect behavior.

This commit mostly just deals with populating the flags, and then all of
the direct consequences of that on our various tests. Further changes to
actually make use of these flags elsewhere in the system will follow in
later commits, both in this repository and in other repositories.
2024-02-09 09:24:27 -08:00
..
doc.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
module.go Embed the schemas directly in the testing framework JSON verbose outputs (#33755) 2023-08-28 10:25:29 +02:00
plan.go terraform: Plans can be "complete" and "applyable" 2024-02-09 09:24:27 -08:00
plan_test.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
resource.go Embed the schemas directly in the testing framework JSON verbose outputs (#33755) 2023-08-28 10:25:29 +02:00
values.go Embed the schemas directly in the testing framework JSON verbose outputs (#33755) 2023-08-28 10:25:29 +02:00
values_test.go Embed the schemas directly in the testing framework JSON verbose outputs (#33755) 2023-08-28 10:25:29 +02:00