You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifc, ok:=d.actionExpansionDeferred.GetOk(ai.Addr.ConfigAction()); ok {
765
+
ifc.Has(ai.Addr) {
766
+
// Then in this case, the resource wasn't deferred but the action
767
+
// was and so we will consider this to be an error.
768
+
diags=diags.Append(&hcl.Diagnostic{
769
+
Severity: hcl.DiagError,
770
+
Summary: "Invalid action deferral",
771
+
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),
772
+
Subject: triggerRange,
773
+
})
785
774
}
786
775
}
787
776
788
-
// We found no reason, so we return false
789
-
returnfalse
777
+
returnfalse, diags
790
778
}
791
779
792
780
// 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",
1835
+
`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.`,
1836
+
),
1849
1837
}
1850
1838
},
1851
1839
},
@@ -1888,37 +1876,17 @@ resource "test_object" "a" {
1888
1876
},
1889
1877
}
1890
1878
},
1891
-
1892
-
assertPlan: func(t*testing.T, p*plans.Plan) {
1893
-
iflen(p.Changes.ActionInvocations) !=0 {
1894
-
t.Fatalf("expected 0 actions in plan, got %d", len(p.Changes.ActionInvocations))
1895
-
}
1896
-
1897
-
iflen(p.DeferredActionInvocations) !=2 {
1898
-
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
1881
+
// this gets implemented we should check that all the
1882
+
// actions are deferred even though only one of them
1883
+
// was actually marked as deferred.
1884
+
return tfdiags.Diagnostics{
1885
+
tfdiags.Sourceless(
1886
+
tfdiags.Error,
1887
+
"Provider deferred changes when Terraform did not allow deferrals",
1888
+
`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.`,
1889
+
),
1922
1890
}
1923
1891
},
1924
1892
},
@@ -1965,50 +1933,17 @@ resource "test_object" "a" {
1965
1933
},
1966
1934
}
1967
1935
},
1968
-
1969
-
assertPlan: func(t*testing.T, p*plans.Plan) {
1970
-
iflen(p.Changes.ActionInvocations) !=0 {
1971
-
t.Fatalf("expected 0 actions in plan, got %d", len(p.Changes.ActionInvocations))
1972
-
}
1973
-
1974
-
iflen(p.DeferredActionInvocations) !=2 {
1975
-
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())
1999
-
}
2000
-
2001
-
iflen(p.DeferredResources) !=1 {
2002
-
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
1938
+
// this gets implemented we should check that all the
1939
+
// actions are deferred even though only one of them
1940
+
// was actually marked as deferred.
1941
+
return tfdiags.Diagnostics{
1942
+
tfdiags.Sourceless(
1943
+
tfdiags.Error,
1944
+
"Provider deferred changes when Terraform did not allow deferrals",
1945
+
`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.`,
1946
+
),
2012
1947
}
2013
1948
},
2014
1949
},
@@ -2130,26 +2065,17 @@ resource "test_object" "a" {
2130
2065
},
2131
2066
},
2132
2067
},
2133
-
assertPlan: func(t*testing.T, p*plans.Plan) {
2134
-
iflen(p.DeferredActionInvocations) !=1 {
2135
-
t.Fatalf("expected exactly one invocation, and found %d", len(p.DeferredActionInvocations))
0 commit comments