terraform: set the diff up properly with tainted resources
This commit is contained in:
parent
e82affdf5c
commit
ef32656a65
|
@ -1177,7 +1177,6 @@ func TestContext2Plan_state(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func TestContext2Plan_taint(t *testing.T) {
|
func TestContext2Plan_taint(t *testing.T) {
|
||||||
m := testModule(t, "plan-taint")
|
m := testModule(t, "plan-taint")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
|
|
|
@ -184,6 +184,50 @@ func (n *EvalDiffDestroyModule) Type() EvalType {
|
||||||
return EvalTypeNull
|
return EvalTypeNull
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EvalDiffTainted is an EvalNode implementation that writes the diff to
|
||||||
|
// the full diff.
|
||||||
|
type EvalDiffTainted struct {
|
||||||
|
Name string
|
||||||
|
Diff *InstanceDiff
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *EvalDiffTainted) Args() ([]EvalNode, []EvalType) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: test
|
||||||
|
func (n *EvalDiffTainted) Eval(
|
||||||
|
ctx EvalContext, args []interface{}) (interface{}, error) {
|
||||||
|
state, lock := ctx.State()
|
||||||
|
|
||||||
|
// Get a read lock so we can access this instance
|
||||||
|
lock.RLock()
|
||||||
|
defer lock.RUnlock()
|
||||||
|
|
||||||
|
// Look for the module state. If we don't have one, then it doesn't matter.
|
||||||
|
mod := state.ModuleByPath(ctx.Path())
|
||||||
|
if mod == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for the resource state. If we don't have one, then it is okay.
|
||||||
|
rs := mod.Resources[n.Name]
|
||||||
|
if rs == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have tainted, then mark it on the diff
|
||||||
|
if len(rs.Tainted) > 0 {
|
||||||
|
n.Diff.DestroyTainted = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *EvalDiffTainted) Type() EvalType {
|
||||||
|
return EvalTypeNull
|
||||||
|
}
|
||||||
|
|
||||||
// EvalWriteDiff is an EvalNode implementation that writes the diff to
|
// EvalWriteDiff is an EvalNode implementation that writes the diff to
|
||||||
// the full diff.
|
// the full diff.
|
||||||
type EvalWriteDiff struct {
|
type EvalWriteDiff struct {
|
||||||
|
|
|
@ -175,6 +175,10 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode {
|
||||||
Output: &diff,
|
Output: &diff,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
&EvalDiffTainted{
|
||||||
|
Diff: &diff,
|
||||||
|
Name: n.stateId(),
|
||||||
|
},
|
||||||
&EvalWriteDiff{
|
&EvalWriteDiff{
|
||||||
Name: n.stateId(),
|
Name: n.stateId(),
|
||||||
Diff: &diff,
|
Diff: &diff,
|
||||||
|
|
Loading…
Reference in New Issue