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:
parent
78964d305c
commit
7fde7d9f20
|
@ -539,6 +539,7 @@ func (c *Context) Plan() (*Plan, error) {
|
||||||
var operation walkOperation
|
var operation walkOperation
|
||||||
if c.destroy {
|
if c.destroy {
|
||||||
operation = walkPlanDestroy
|
operation = walkPlanDestroy
|
||||||
|
p.Destroy = true
|
||||||
} else {
|
} else {
|
||||||
// Set our state to be something temporary. We do this so that
|
// Set our state to be something temporary. We do this so that
|
||||||
// the plan can update a fake state so that variables work, then
|
// the plan can update a fake state so that variables work, then
|
||||||
|
|
|
@ -71,6 +71,9 @@ type Plan struct {
|
||||||
// Backend is the backend that this plan should use and store data with.
|
// Backend is the backend that this plan should use and store data with.
|
||||||
Backend *BackendState
|
Backend *BackendState
|
||||||
|
|
||||||
|
// Destroy indicates that this plan was created for a full destroy operation
|
||||||
|
Destroy bool
|
||||||
|
|
||||||
once sync.Once
|
once sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +103,7 @@ func (p *Plan) contextOpts(base *ContextOpts) (*ContextOpts, error) {
|
||||||
opts.Module = p.Module
|
opts.Module = p.Module
|
||||||
opts.Targets = p.Targets
|
opts.Targets = p.Targets
|
||||||
opts.ProviderSHA256s = p.ProviderSHA256s
|
opts.ProviderSHA256s = p.ProviderSHA256s
|
||||||
|
opts.Destroy = p.Destroy
|
||||||
|
|
||||||
if opts.State == nil {
|
if opts.State == nil {
|
||||||
opts.State = p.State
|
opts.State = p.State
|
||||||
|
|
Loading…
Reference in New Issue