From 7fde7d9f20df101dddb0af8030111871ba99572f Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 27 Sep 2017 19:26:14 -0400 Subject: [PATCH] make a destroy plan work the same as destroy When working on an existing plan, the context always used walkApply, even if the plan was for a full destroy. Mark in the plan if it was icreated for a destroy, and transfer that to the context when reading the plan. --- terraform/context.go | 1 + terraform/plan.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/terraform/context.go b/terraform/context.go index 28ca14cbf..724ce39ed 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -539,6 +539,7 @@ func (c *Context) Plan() (*Plan, error) { var operation walkOperation if c.destroy { operation = walkPlanDestroy + p.Destroy = true } else { // Set our state to be something temporary. We do this so that // the plan can update a fake state so that variables work, then diff --git a/terraform/plan.go b/terraform/plan.go index 7b9ae1b52..8611628e3 100644 --- a/terraform/plan.go +++ b/terraform/plan.go @@ -71,6 +71,9 @@ type Plan struct { // Backend is the backend that this plan should use and store data with. Backend *BackendState + // Destroy indicates that this plan was created for a full destroy operation + Destroy bool + once sync.Once } @@ -100,6 +103,7 @@ func (p *Plan) contextOpts(base *ContextOpts) (*ContextOpts, error) { opts.Module = p.Module opts.Targets = p.Targets opts.ProviderSHA256s = p.ProviderSHA256s + opts.Destroy = p.Destroy if opts.State == nil { opts.State = p.State