terraform: partial state works properly

This commit is contained in:
Mitchell Hashimoto 2015-02-13 12:50:13 -08:00
parent 5f8d1b86d5
commit b8ebcc85d7
3 changed files with 22 additions and 20 deletions

View File

@ -19,7 +19,6 @@ type EvalApply struct {
Output **InstanceState
CreateNew *bool
Error *error
Tainted *bool
}
func (n *EvalApply) Args() ([]EvalNode, []EvalType) {
@ -96,11 +95,6 @@ func (n *EvalApply) Eval(
*n.Output = state
}
// Set the tainted state
if n.Tainted != nil {
*n.Tainted = err != nil
}
// If there are no errors, then we append it to our output error
// if we have one, otherwise we just output it.
if err != nil {
@ -175,13 +169,23 @@ func (n *EvalApplyProvisioners) Eval(
ctx EvalContext, args []interface{}) (interface{}, error) {
state := *n.State
if *n.Tainted {
// We're already tainted, so just return out
if !*n.CreateNew {
// If we're not creating a new resource, then don't run provisioners
return nil, nil
}
if !*n.CreateNew {
// If we're not creating a new resource, then don't run provisioners
if len(n.Resource.Provisioners) == 0 {
// We have no provisioners, so don't do anything
return nil, nil
}
if n.Error != nil && *n.Error != nil {
// We're already errored creating, so mark as tainted and continue
if n.Tainted != nil {
*n.Tainted = true
}
// We're already tainted, so just return out
return nil, nil
}

View File

@ -337,9 +337,8 @@ const testTerraformApplyDestroyStr = `
`
const testTerraformApplyErrorStr = `
aws_instance.bar: (1 tainted)
ID = <not created>
Tainted ID 1 = bar
aws_instance.bar:
ID = bar
Dependencies:
aws_instance.foo
@ -361,9 +360,8 @@ aws_instance.bar: (1 tainted)
`
const testTerraformApplyErrorPartialStr = `
aws_instance.bar: (1 tainted)
ID = <not created>
Tainted ID 1 = bar
aws_instance.bar:
ID = bar
Dependencies:
aws_instance.foo
@ -464,9 +462,10 @@ foo_num = bar
`
const testTerraformApplyUnknownAttrStr = `
aws_instance.foo: (1 tainted)
ID = <not created>
Tainted ID 1 = foo
aws_instance.foo:
ID = foo
num = 2
type = aws_instance
`
const testTerraformApplyVarsStr = `

View File

@ -287,7 +287,6 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode {
Output: &state,
Error: &err,
CreateNew: &createNew,
Tainted: &tainted,
},
&EvalWriteState{
Name: n.stateId(),