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
_, err = c.walk(graph, walkApply)
if c.destroy {
_, err = c.walk(graph, walkDestroy)
} else {
_, err = c.walk(graph, walkApply)
}
// Clean out any unused things
c.state.prune()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,9 +4,9 @@ package terraform
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 {
if i >= walkOperation(len(_walkOperation_index)-1) {