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
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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 = `
|
||||
|
@ -287,7 +287,6 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode {
|
||||
Output: &state,
|
||||
Error: &err,
|
||||
CreateNew: &createNew,
|
||||
Tainted: &tainted,
|
||||
},
|
||||
&EvalWriteState{
|
||||
Name: n.stateId(),
|
||||
|
Loading…
Reference in New Issue
Block a user