// Then in this case, the resource wasn't deferred but the action
// was and so we will consider this to be an error.
diags=diags.Append(&hcl.Diagnostic{
Severity:hcl.DiagError,
Summary:"Invalid action deferral",
Detail:fmt.Sprintf("The action %s was marked as deferred, but was triggered by a non-deferred resource %s. To work around this, use the -target argument to first apply only the resources that the action block depends on.",ai.Addr,at.TriggeringResourceAddr),
Subject:triggerRange,
})
}
}
// We found no reason, so we return false
returnfalse
returnfalse,diags
}
// ShouldDeferAction returns true if the action should be deferred. This is the case if a
t.Fatalf("expected deferred action to be triggered by test_object.a, but got %s",deferredActionInvocation.ActionInvocationInstanceSrc.ActionTrigger.(*plans.LifecycleActionTrigger).TriggeringResourceAddr.String())
t.Fatalf("expected deferred action to be triggered by action.test_action.hello, but got %s",deferredActionInvocation.ActionInvocationInstanceSrc.Addr.String())
"Provider deferred changes when Terraform did not allow deferrals",
`The provider signaled a deferred action for "action.test_action.hello", but in this context deferrals are disabled. This is a bug in the provider, please file an issue with the provider developers.`,
),
}
},
},
@ -1888,37 +1876,17 @@ resource "test_object" "a" {
},
}
},
assertPlan:func(t*testing.T,p*plans.Plan){
iflen(p.Changes.ActionInvocations)!=0{
t.Fatalf("expected 0 actions in plan, got %d",len(p.Changes.ActionInvocations))
}
iflen(p.DeferredActionInvocations)!=2{
t.Fatalf("expected 2 deferred actions in plan, got %d",len(p.DeferredActionInvocations))
t.Fatalf("expected deferred action to be triggered by test_object.a, but got %s",firstDeferredActionInvocation.ActionInvocationInstanceSrc.ActionTrigger.(*plans.LifecycleActionTrigger).TriggeringResourceAddr.String())
t.Fatalf("expected deferred action to be triggered by action.test_action.hello, but got %s",firstDeferredActionInvocation.ActionInvocationInstanceSrc.Addr.String())
t.Fatalf("expected second deferred action to be triggered by test_object.a, but got %s",secondDeferredActionInvocation.ActionInvocationInstanceSrc.ActionTrigger.(*plans.LifecycleActionTrigger).TriggeringResourceAddr.String())
t.Fatalf("expected second deferred action to be triggered by action.ecosystem.world, but got %s",secondDeferredActionInvocation.ActionInvocationInstanceSrc.Addr.String())
// for now, it's just an error for any deferrals but when
// this gets implemented we should check that all the
// actions are deferred even though only one of them
// was actually marked as deferred.
returntfdiags.Diagnostics{
tfdiags.Sourceless(
tfdiags.Error,
"Provider deferred changes when Terraform did not allow deferrals",
`The provider signaled a deferred action for "action.test_action.hello", but in this context deferrals are disabled. This is a bug in the provider, please file an issue with the provider developers.`,
),
}
},
},
@ -1965,50 +1933,17 @@ resource "test_object" "a" {
},
}
},
assertPlan:func(t*testing.T,p*plans.Plan){
iflen(p.Changes.ActionInvocations)!=0{
t.Fatalf("expected 0 actions in plan, got %d",len(p.Changes.ActionInvocations))
}
iflen(p.DeferredActionInvocations)!=2{
t.Fatalf("expected 2 deferred actions in plan, got %d",len(p.DeferredActionInvocations))
t.Fatalf("expected deferred action to be triggered by test_object.a, but got %s",firstDeferredActionInvocation.ActionInvocationInstanceSrc.ActionTrigger.(*plans.LifecycleActionTrigger).TriggeringResourceAddr.String())
t.Fatalf("expected deferred action to be triggered by action.test_action.hello, but got %s",firstDeferredActionInvocation.ActionInvocationInstanceSrc.Addr.String())
t.Fatalf("expected second deferred action to be triggered by test_object.a, but got %s",secondDeferredActionInvocation.ActionInvocationInstanceSrc.ActionTrigger.(*plans.LifecycleActionTrigger).TriggeringResourceAddr.String())
t.Fatalf("expected second deferred action to be triggered by action.ecosystem.world, but got %s",secondDeferredActionInvocation.ActionInvocationInstanceSrc.Addr.String())
}
iflen(p.DeferredResources)!=1{
t.Fatalf("expected 1 resource to be deferred, got %d",len(p.DeferredResources))
// for now, it's just an error for any deferrals but when
// this gets implemented we should check that all the
// actions are deferred even though only one of them
// was actually marked as deferred.
returntfdiags.Diagnostics{
tfdiags.Sourceless(
tfdiags.Error,
"Provider deferred changes when Terraform did not allow deferrals",
`The provider signaled a deferred action for "action.test_action.hello", but in this context deferrals are disabled. This is a bug in the provider, please file an issue with the provider developers.`,
),
}
},
},
@ -2130,26 +2065,17 @@ resource "test_object" "a" {
},
},
},
assertPlan:func(t*testing.T,p *plans.Plan){
iflen(p.DeferredActionInvocations)!=1{
t.Fatalf("expected exactly one invocation, and found %d",len(p.DeferredActionInvocations))