Add operation walkDestroy

This commit is contained in:
Radek Simko 2015-10-02 11:18:33 -07:00
parent 2b60d0c6b6
commit 40b04154fe
11 changed files with 19 additions and 14 deletions

View File

@ -292,7 +292,11 @@ func (c *Context) Apply() (*State, error) {
} }
// Do the walk // Do the walk
_, err = c.walk(graph, walkApply) if c.destroy {
_, err = c.walk(graph, walkDestroy)
} else {
_, err = c.walk(graph, walkApply)
}
// Clean out any unused things // Clean out any unused things
c.state.prune() c.state.prune()

View File

@ -71,7 +71,7 @@ func ProviderEvalTree(n string, config *config.RawConfig) EvalNode {
// Apply stuff // Apply stuff
seq = append(seq, &EvalOpFilter{ seq = append(seq, &EvalOpFilter{
Ops: []walkOperation{walkRefresh, walkPlan, walkApply}, Ops: []walkOperation{walkRefresh, walkPlan, walkApply, walkDestroy},
Node: &EvalSequence{ Node: &EvalSequence{
Nodes: []EvalNode{ Nodes: []EvalNode{
&EvalGetProvider{ &EvalGetProvider{
@ -98,7 +98,7 @@ func ProviderEvalTree(n string, config *config.RawConfig) EvalNode {
// We configure on everything but validate, since validate may // We configure on everything but validate, since validate may
// not have access to all the variables. // not have access to all the variables.
seq = append(seq, &EvalOpFilter{ seq = append(seq, &EvalOpFilter{
Ops: []walkOperation{walkRefresh, walkPlan, walkApply}, Ops: []walkOperation{walkRefresh, walkPlan, walkApply, walkDestroy},
Node: &EvalSequence{ Node: &EvalSequence{
Nodes: []EvalNode{ Nodes: []EvalNode{
&EvalConfigProvider{ &EvalConfigProvider{

View File

@ -44,7 +44,7 @@ func (n *GraphNodeConfigOutput) DependentOn() []string {
// GraphNodeEvalable impl. // GraphNodeEvalable impl.
func (n *GraphNodeConfigOutput) EvalTree() EvalNode { func (n *GraphNodeConfigOutput) EvalTree() EvalNode {
return &EvalOpFilter{ return &EvalOpFilter{
Ops: []walkOperation{walkRefresh, walkPlan, walkApply}, Ops: []walkOperation{walkRefresh, walkPlan, walkApply, walkDestroy},
Node: &EvalSequence{ Node: &EvalSequence{
Nodes: []EvalNode{ Nodes: []EvalNode{
&EvalWriteOutput{ &EvalWriteOutput{

View File

@ -13,4 +13,5 @@ const (
walkPlanDestroy walkPlanDestroy
walkRefresh walkRefresh
walkValidate walkValidate
walkDestroy
) )

View File

@ -110,7 +110,7 @@ func (n *graphNodeDeposedResource) EvalTree() EvalNode {
var diff *InstanceDiff var diff *InstanceDiff
var err error var err error
seq.Nodes = append(seq.Nodes, &EvalOpFilter{ seq.Nodes = append(seq.Nodes, &EvalOpFilter{
Ops: []walkOperation{walkApply}, Ops: []walkOperation{walkApply, walkDestroy},
Node: &EvalSequence{ Node: &EvalSequence{
Nodes: []EvalNode{ Nodes: []EvalNode{
&EvalGetProvider{ &EvalGetProvider{

View File

@ -263,7 +263,7 @@ func (n *graphNodeOrphanResource) EvalTree() EvalNode {
// Apply // Apply
var err error var err error
seq.Nodes = append(seq.Nodes, &EvalOpFilter{ seq.Nodes = append(seq.Nodes, &EvalOpFilter{
Ops: []walkOperation{walkApply}, Ops: []walkOperation{walkApply, walkDestroy},
Node: &EvalSequence{ Node: &EvalSequence{
Nodes: []EvalNode{ Nodes: []EvalNode{
&EvalReadDiff{ &EvalReadDiff{

View File

@ -62,7 +62,7 @@ func (n *graphNodeOrphanOutput) Name() string {
func (n *graphNodeOrphanOutput) EvalTree() EvalNode { func (n *graphNodeOrphanOutput) EvalTree() EvalNode {
return &EvalOpFilter{ return &EvalOpFilter{
Ops: []walkOperation{walkApply, walkRefresh}, Ops: []walkOperation{walkApply, walkDestroy, walkRefresh},
Node: &EvalDeleteOutput{ Node: &EvalDeleteOutput{
Name: n.OutputName, Name: n.OutputName,
}, },
@ -90,7 +90,7 @@ func (n *graphNodeOrphanOutputFlat) Name() string {
func (n *graphNodeOrphanOutputFlat) EvalTree() EvalNode { func (n *graphNodeOrphanOutputFlat) EvalTree() EvalNode {
return &EvalOpFilter{ return &EvalOpFilter{
Ops: []walkOperation{walkApply, walkRefresh}, Ops: []walkOperation{walkApply, walkDestroy, walkRefresh},
Node: &EvalDeleteOutput{ Node: &EvalDeleteOutput{
Name: n.OutputName, Name: n.OutputName,
}, },

View File

@ -255,7 +255,7 @@ func (n *graphNodeDisabledProvider) EvalTree() EvalNode {
var resourceConfig *ResourceConfig var resourceConfig *ResourceConfig
return &EvalOpFilter{ return &EvalOpFilter{
Ops: []walkOperation{walkInput, walkValidate, walkRefresh, walkPlan, walkApply}, Ops: []walkOperation{walkInput, walkValidate, walkRefresh, walkPlan, walkApply, walkDestroy},
Node: &EvalSequence{ Node: &EvalSequence{
Nodes: []EvalNode{ Nodes: []EvalNode{
&EvalInterpolate{ &EvalInterpolate{

View File

@ -369,7 +369,7 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode {
var createNew, tainted bool var createNew, tainted bool
var createBeforeDestroyEnabled bool var createBeforeDestroyEnabled bool
seq.Nodes = append(seq.Nodes, &EvalOpFilter{ seq.Nodes = append(seq.Nodes, &EvalOpFilter{
Ops: []walkOperation{walkApply}, Ops: []walkOperation{walkApply, walkDestroy},
Node: &EvalSequence{ Node: &EvalSequence{
Nodes: []EvalNode{ Nodes: []EvalNode{
// Get the saved diff for apply // Get the saved diff for apply
@ -591,7 +591,7 @@ func (n *graphNodeExpandedResourceDestroy) EvalTree() EvalNode {
var state *InstanceState var state *InstanceState
var err error var err error
return &EvalOpFilter{ return &EvalOpFilter{
Ops: []walkOperation{walkApply}, Ops: []walkOperation{walkApply, walkDestroy},
Node: &EvalSequence{ Node: &EvalSequence{
Nodes: []EvalNode{ Nodes: []EvalNode{
// Get the saved diff for apply // Get the saved diff for apply

View File

@ -114,7 +114,7 @@ func (n *graphNodeTaintedResource) EvalTree() EvalNode {
// Apply // Apply
var diff *InstanceDiff var diff *InstanceDiff
seq.Nodes = append(seq.Nodes, &EvalOpFilter{ seq.Nodes = append(seq.Nodes, &EvalOpFilter{
Ops: []walkOperation{walkApply}, Ops: []walkOperation{walkApply, walkDestroy},
Node: &EvalSequence{ Node: &EvalSequence{
Nodes: []EvalNode{ Nodes: []EvalNode{
&EvalGetProvider{ &EvalGetProvider{

View File

@ -4,9 +4,9 @@ package terraform
import "fmt" import "fmt"
const _walkOperation_name = "walkInvalidwalkInputwalkApplywalkPlanwalkPlanDestroywalkRefreshwalkValidate" const _walkOperation_name = "walkInvalidwalkInputwalkApplywalkPlanwalkPlanDestroywalkRefreshwalkValidatewalkDestroy"
var _walkOperation_index = [...]uint8{0, 11, 20, 29, 37, 52, 63, 75} var _walkOperation_index = [...]uint8{0, 11, 20, 29, 37, 52, 63, 75, 86}
func (i walkOperation) String() string { func (i walkOperation) String() string {
if i >= walkOperation(len(_walkOperation_index)-1) { if i >= walkOperation(len(_walkOperation_index)-1) {