terraform/command/views
Martin Atkins f2adfb6e2a core: Treat deposed objects the same as orphaned current objects
In many ways a deposed object is equivalent to an orphaned current object
in that the only action we can take with it is to destroy it. However, we
do still need to take some preparation steps in both cases: first, we must
ensure we track the upgraded version of the existing object so that we'll
be able to successfully render our plan, and secondly we must refresh the
existing object to make sure it still exists in the remote system.

We were previously doing these extra steps for orphan objects but not for
deposed ones, which meant that the behavior for deposed objects would be
subtly different and violate the invariants our callers expect in order
to display a plan. This also created the risk that a deposed object
already deleted in the remote system would become "stuck" because
Terraform would still plan to destroy it, which might cause the provider
to return an error when it tries to delete an already-absent object.

This also makes the deposed object planning take into account the
"skipPlanChanges" flag, which is important to get a correct result in
the "refresh only" planning mode.

It's a shame that we have almost identical code handling both the orphan
and deposed situations, but they differ in that the latter must call
different functions to interact with the deposed rather than the current
objects in the state. Perhaps a later change can improve on this with some
more refactoring, but this commit is already a little more disruptive than
I'd like and so I'm intentionally deferring that for another day.
2021-05-13 09:05:06 -07:00
..
json command+backend/local: -refresh-only and drift detection 2021-05-13 09:05:06 -07:00
apply.go command/views: Remove command-specific runningInAutomation 2021-05-10 10:50:05 -07:00
apply_test.go command/views: Remove command-specific runningInAutomation 2021-05-10 10:50:05 -07:00
hook_count.go cli: Migrate apply to command views 2021-02-22 11:47:40 -05:00
hook_count_test.go cli: Migrate apply to command views 2021-02-22 11:47:40 -05:00
hook_json.go cli: Add JSON logs for operations commands 2021-04-30 11:37:36 -04:00
hook_json_test.go cli: Add JSON logs for operations commands 2021-04-30 11:37:36 -04:00
hook_ui.go core: Treat deposed objects the same as orphaned current objects 2021-05-13 09:05:06 -07:00
hook_ui_test.go core: Treat deposed objects the same as orphaned current objects 2021-05-13 09:05:06 -07:00
json_view.go command+backend/local: -refresh-only and drift detection 2021-05-13 09:05:06 -07:00
json_view_test.go cli: Add JSON logs for operations commands 2021-04-30 11:37:36 -04:00
operation.go command+backend/local: -refresh-only and drift detection 2021-05-13 09:05:06 -07:00
operation_test.go command+backend/local: -refresh-only and drift detection 2021-05-13 09:05:06 -07:00
output.go views: Fix missing source in diagnostic output 2021-02-26 16:43:03 -05:00
output_test.go views: Expand test coverage for views.Output 2021-02-16 08:48:31 -05:00
plan.go command+backend/local: -refresh-only and drift detection 2021-05-13 09:05:06 -07:00
plan_test.go command/views: Remove command-specific runningInAutomation 2021-05-10 10:50:05 -07:00
refresh.go command/views: Remove command-specific runningInAutomation 2021-05-10 10:50:05 -07:00
refresh_test.go command/views: Remove command-specific runningInAutomation 2021-05-10 10:50:05 -07:00
show.go command/views: Remove baseState argument from plan-rendering views 2021-05-10 09:25:30 -07:00
state_locker.go views: Fix missing source in diagnostic output 2021-02-26 16:43:03 -05:00
test.go command: Experimental "terraform test" command 2021-02-22 14:21:45 -08:00
test_test.go command: Experimental "terraform test" command 2021-02-22 14:21:45 -08:00
validate.go cli: Migrate validate command to views 2021-03-18 15:56:28 -04:00
validate_test.go cli: Migrate validate command to views 2021-03-18 15:56:28 -04:00
view.go command/views: Remove command-specific runningInAutomation 2021-05-10 10:50:05 -07:00