terraform/plans/planfile
Martin Atkins 0f936b9d80 plans/planfile: Read state snapshots as part of reading a plan
Our model for plans/planfile has unfortunately grown inconsistent with
changes to our modeling of plans.Plan.

Originally we considered the plan "header" and the planned changes as an
entirely separate artifact from the prior state, but we later realized
that carrying the prior state around with the plan is important to
ensuring we always have enough context to faithfully render a plan to the
user, and so we added the prior state as a field of plans.Plan.
More recently we've also added the "previous run state" to plans.Plan for
similar reasons.

Unfortunately as a result of that modeling drift our ReadPlan method was
silently producing an incomplete plans.Plan object, causing use-cases like
"terraform show" to produce slightly different results due to the
plan object not round-tripping completely.

As a short-term tactical fix, here we add state snapshot reading into the
ReadPlan function. This is not an ideal solution because it means that
in the case of applying a plan, where we really do need access to the
state _file_, we'll end up reading the prior state file twice. However,
the goal here is only to heal the modelling quirk with as little change
as possible, because we're not currently at a point where we'd be willing
to risk regressions from a larger refactoring.
2021-05-10 09:22:47 -07:00
..
testdata/test-config plans/planfile: Reading and writing the new plan format 2018-10-16 18:50:29 -07:00
config_snapshot.go plans/planfile: Reading and writing the new plan format 2018-10-16 18:50:29 -07:00
config_snapshot_test.go plans/planfile: Reading and writing the new plan format 2018-10-16 18:50:29 -07:00
doc.go plans/planfile: Reading and writing the new plan format 2018-10-16 18:50:29 -07:00
planfile_test.go plans/planfile: Read state snapshots as part of reading a plan 2021-05-10 09:22:47 -07:00
reader.go plans/planfile: Read state snapshots as part of reading a plan 2021-05-10 09:22:47 -07:00
tfplan.go plans: Plan.Mode is now Plan.UIMode 2021-04-30 10:30:56 -07:00
tfplan_test.go plans: Track an optional extra "reason" for some planned actions 2021-04-29 17:50:46 -07:00
writer.go plans: Track both the previous run and prior states in the plan 2021-05-05 15:11:05 -07:00