mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
terraform: partial state works properly
This commit is contained in:
parent
5f8d1b86d5
commit
b8ebcc85d7
@ -19,7 +19,6 @@ type EvalApply struct {
|
|||||||
Output **InstanceState
|
Output **InstanceState
|
||||||
CreateNew *bool
|
CreateNew *bool
|
||||||
Error *error
|
Error *error
|
||||||
Tainted *bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *EvalApply) Args() ([]EvalNode, []EvalType) {
|
func (n *EvalApply) Args() ([]EvalNode, []EvalType) {
|
||||||
@ -96,11 +95,6 @@ func (n *EvalApply) Eval(
|
|||||||
*n.Output = state
|
*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 there are no errors, then we append it to our output error
|
||||||
// if we have one, otherwise we just output it.
|
// if we have one, otherwise we just output it.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -175,13 +169,23 @@ func (n *EvalApplyProvisioners) Eval(
|
|||||||
ctx EvalContext, args []interface{}) (interface{}, error) {
|
ctx EvalContext, args []interface{}) (interface{}, error) {
|
||||||
state := *n.State
|
state := *n.State
|
||||||
|
|
||||||
if *n.Tainted {
|
if !*n.CreateNew {
|
||||||
// We're already tainted, so just return out
|
// If we're not creating a new resource, then don't run provisioners
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*n.CreateNew {
|
if len(n.Resource.Provisioners) == 0 {
|
||||||
// If we're not creating a new resource, then don't run provisioners
|
// 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
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,9 +337,8 @@ const testTerraformApplyDestroyStr = `
|
|||||||
`
|
`
|
||||||
|
|
||||||
const testTerraformApplyErrorStr = `
|
const testTerraformApplyErrorStr = `
|
||||||
aws_instance.bar: (1 tainted)
|
aws_instance.bar:
|
||||||
ID = <not created>
|
ID = bar
|
||||||
Tainted ID 1 = bar
|
|
||||||
|
|
||||||
Dependencies:
|
Dependencies:
|
||||||
aws_instance.foo
|
aws_instance.foo
|
||||||
@ -361,9 +360,8 @@ aws_instance.bar: (1 tainted)
|
|||||||
`
|
`
|
||||||
|
|
||||||
const testTerraformApplyErrorPartialStr = `
|
const testTerraformApplyErrorPartialStr = `
|
||||||
aws_instance.bar: (1 tainted)
|
aws_instance.bar:
|
||||||
ID = <not created>
|
ID = bar
|
||||||
Tainted ID 1 = bar
|
|
||||||
|
|
||||||
Dependencies:
|
Dependencies:
|
||||||
aws_instance.foo
|
aws_instance.foo
|
||||||
@ -464,9 +462,10 @@ foo_num = bar
|
|||||||
`
|
`
|
||||||
|
|
||||||
const testTerraformApplyUnknownAttrStr = `
|
const testTerraformApplyUnknownAttrStr = `
|
||||||
aws_instance.foo: (1 tainted)
|
aws_instance.foo:
|
||||||
ID = <not created>
|
ID = foo
|
||||||
Tainted ID 1 = foo
|
num = 2
|
||||||
|
type = aws_instance
|
||||||
`
|
`
|
||||||
|
|
||||||
const testTerraformApplyVarsStr = `
|
const testTerraformApplyVarsStr = `
|
||||||
|
@ -287,7 +287,6 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode {
|
|||||||
Output: &state,
|
Output: &state,
|
||||||
Error: &err,
|
Error: &err,
|
||||||
CreateNew: &createNew,
|
CreateNew: &createNew,
|
||||||
Tainted: &tainted,
|
|
||||||
},
|
},
|
||||||
&EvalWriteState{
|
&EvalWriteState{
|
||||||
Name: n.stateId(),
|
Name: n.stateId(),
|
||||||
|
Loading…
Reference in New Issue
Block a user