terraform/plans
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
..
internal/planproto plans: Plan.Mode is now Plan.UIMode 2021-04-30 10:30:56 -07:00
objchange use new dynamic decoding behavior 2021-04-14 12:13:22 -04:00
planfile plans/planfile: Read state snapshots as part of reading a plan 2021-05-10 09:22:47 -07:00
action.go Version tools per Go convention under tools.go 2019-10-17 22:23:39 +02:00
action_string.go stringer: Regenerate files with latest version 2019-05-13 15:34:27 +01:00
changes.go plans: Track an optional extra "reason" for some planned actions 2021-04-29 17:50:46 -07:00
changes_src.go plans: Track an optional extra "reason" for some planned actions 2021-04-29 17:50:46 -07:00
changes_state.go plans: New package for in-memory plan models 2018-10-16 18:50:29 -07:00
changes_sync.go s/FullDestroy/IsFullDdestroy/ 2020-10-05 10:50:25 -04:00
doc.go plans: New package for in-memory plan models 2018-10-16 18:50:29 -07:00
dynamic_value.go Use UnmarkDeepWithPaths and MarkWithPaths 2020-09-10 11:04:17 -04:00
mode.go core: Generalize the idea of a "plan mode", vs just destroy flag 2021-04-27 08:23:54 -07:00
mode_string.go core: Generalize the idea of a "plan mode", vs just destroy flag 2021-04-27 08:23:54 -07:00
plan.go plans: Track both the previous run and prior states in the plan 2021-05-05 15:11:05 -07:00
plan_test.go don't render plan for module outputs 2020-11-17 09:31:18 -05:00
resourceinstancechangeactionreason_string.go plans: Track an optional extra "reason" for some planned actions 2021-04-29 17:50:46 -07:00