From 47b63863485ba4fa74cfb2f00125cf4fef745c6b Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 19 Oct 2022 08:43:16 -0400 Subject: [PATCH] remove IsFullDestroy workaround IsFullDestroy was a workaround during apply to detect when the change set was created by a destroy plan. This no longer works correctly, and we need to fall back to the UIMode set in the plan. --- internal/plans/changes_sync.go | 18 ------------------ internal/terraform/evaluate.go | 2 +- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/internal/plans/changes_sync.go b/internal/plans/changes_sync.go index 95920c1c6b..2b4254b044 100644 --- a/internal/plans/changes_sync.go +++ b/internal/plans/changes_sync.go @@ -21,24 +21,6 @@ type ChangesSync struct { changes *Changes } -// IsFullDestroy returns true if the set of changes indicates we are doing a -// destroy of all resources. -func (cs *ChangesSync) IsFullDestroy() bool { - if cs == nil { - panic("FullDestroy on nil ChangesSync") - } - cs.lock.Lock() - defer cs.lock.Unlock() - - for _, c := range cs.changes.Resources { - if c.Action != Delete { - return false - } - } - - return true -} - // AppendResourceInstanceChange records the given resource instance change in // the set of planned resource changes. // diff --git a/internal/terraform/evaluate.go b/internal/terraform/evaluate.go index b841dbd863..d521443472 100644 --- a/internal/terraform/evaluate.go +++ b/internal/terraform/evaluate.go @@ -728,7 +728,7 @@ func (d *evaluationStateData) GetResource(addr addrs.Resource, rng tfdiags.Sourc // Decode all instances in the current state instances := map[addrs.InstanceKey]cty.Value{} - pendingDestroy := d.Evaluator.Changes.IsFullDestroy() + pendingDestroy := d.Operation == walkDestroy for key, is := range rs.Instances { if is == nil || is.Current == nil { // Assume we're dealing with an instance that hasn't been created yet.