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.
This commit is contained in:
James Bardin 2017-09-27 19:26:14 -04:00
parent 78964d305c
commit 7fde7d9f20
2 changed files with 5 additions and 0 deletions

View File

@ -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

View File

@ -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