diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index a1f9fb03e..ce98a4631 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -34,8 +34,8 @@ import ( func TestContext2Apply_basic(t *testing.T) { m := testModule(t, "apply-good") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -75,8 +75,8 @@ func TestContext2Apply_unstable(t *testing.T) { m := testModule(t, "apply-unstable") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -132,8 +132,8 @@ func TestContext2Apply_unstable(t *testing.T) { func TestContext2Apply_escape(t *testing.T) { m := testModule(t, "apply-escape") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -162,8 +162,8 @@ aws_instance.bar: func TestContext2Apply_resourceCountOneList(t *testing.T) { m := testModule(t, "apply-resource-count-one-list") p := testProvider("null") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -193,8 +193,8 @@ test = [foo]`) func TestContext2Apply_resourceCountZeroList(t *testing.T) { m := testModule(t, "apply-resource-count-zero-list") p := testProvider("null") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -224,13 +224,13 @@ test = []`) func TestContext2Apply_resourceDependsOnModule(t *testing.T) { m := testModule(t, "apply-resource-depends-on-module") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn // verify the apply happens in the correct order var mu sync.Mutex var order []string - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { ami := req.PlannedState.GetAttr("ami").AsString() switch ami { case "child": @@ -279,7 +279,7 @@ func TestContext2Apply_resourceDependsOnModule(t *testing.T) { func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) { m := testModule(t, "apply-resource-depends-on-module-empty") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -307,7 +307,7 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) { var mu sync.Mutex var order []string - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { id := req.PriorState.GetAttr("id") if id.IsKnown() && id.AsString() == "parent" { // make the dep slower than the parent @@ -351,11 +351,11 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) { func TestContext2Apply_resourceDependsOnModuleDestroy(t *testing.T) { m := testModule(t, "apply-resource-depends-on-module") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn var globalState *states.State { - p.ApplyFn = testApplyFn + p.ApplyResourceChangeFn = testApplyFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -380,7 +380,7 @@ func TestContext2Apply_resourceDependsOnModuleDestroy(t *testing.T) { // called a child. var called int32 var checked bool - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { ami := req.PriorState.GetAttr("ami").AsString() if ami == "parent" { checked = true @@ -428,14 +428,14 @@ func TestContext2Apply_resourceDependsOnModuleDestroy(t *testing.T) { func TestContext2Apply_resourceDependsOnModuleGrandchild(t *testing.T) { m := testModule(t, "apply-resource-depends-on-module-deep") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn { // Wait for the dependency, sleep, and verify the graph never // called a child. var called int32 var checked bool - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { planned := req.PlannedState.AsValueMap() if ami, ok := planned["ami"]; ok && ami.AsString() == "grandchild" { checked = true @@ -481,14 +481,14 @@ func TestContext2Apply_resourceDependsOnModuleGrandchild(t *testing.T) { func TestContext2Apply_resourceDependsOnModuleInModule(t *testing.T) { m := testModule(t, "apply-resource-depends-on-module-in-module") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn { // Wait for the dependency, sleep, and verify the graph never // called a child. var called int32 var checked bool - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { planned := req.PlannedState.AsValueMap() if ami, ok := planned["ami"]; ok && ami.AsString() == "grandchild" { checked = true @@ -534,8 +534,8 @@ func TestContext2Apply_resourceDependsOnModuleInModule(t *testing.T) { func TestContext2Apply_mapVarBetweenModules(t *testing.T) { m := testModule(t, "apply-map-var-through-module") p := testProvider("null") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -574,8 +574,8 @@ module.test: func TestContext2Apply_refCount(t *testing.T) { m := testModule(t, "apply-ref-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -607,8 +607,8 @@ func TestContext2Apply_refCount(t *testing.T) { func TestContext2Apply_providerAlias(t *testing.T) { m := testModule(t, "apply-provider-alias") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -642,8 +642,8 @@ func TestContext2Apply_providerAliasConfigure(t *testing.T) { m := testModule(t, "apply-provider-alias-configure") p2 := testProvider("another") - p2.ApplyFn = testApplyFn - p2.DiffFn = testDiffFn + p2.ApplyResourceChangeFn = testApplyFn + p2.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -691,8 +691,8 @@ func TestContext2Apply_providerAliasConfigure(t *testing.T) { func TestContext2Apply_providerWarning(t *testing.T) { m := testModule(t, "apply-provider-warning") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.ValidateResourceTypeConfigFn = func(req providers.ValidateResourceTypeConfigRequest) (resp providers.ValidateResourceTypeConfigResponse) { resp.Diagnostics = resp.Diagnostics.Append(tfdiags.SimpleWarning("just a warning")) return @@ -733,8 +733,8 @@ func TestContext2Apply_emptyModule(t *testing.T) { // A module with only outputs (no resources) m := testModule(t, "apply-empty-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -762,8 +762,8 @@ func TestContext2Apply_emptyModule(t *testing.T) { func TestContext2Apply_createBeforeDestroy(t *testing.T) { m := testModule(t, "apply-good-create-before") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -809,8 +809,8 @@ func TestContext2Apply_createBeforeDestroy(t *testing.T) { func TestContext2Apply_createBeforeDestroyUpdate(t *testing.T) { m := testModule(t, "apply-good-create-before-update") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -859,8 +859,8 @@ func TestContext2Apply_createBeforeDestroyUpdate(t *testing.T) { func TestContext2Apply_createBeforeDestroy_dependsNonCBD(t *testing.T) { m := testModule(t, "apply-cbd-depends-non-cbd") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -922,8 +922,8 @@ func TestContext2Apply_createBeforeDestroy_hook(t *testing.T) { h := new(MockHook) m := testModule(t, "apply-good-create-before") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -983,8 +983,8 @@ func TestContext2Apply_createBeforeDestroy_hook(t *testing.T) { func TestContext2Apply_createBeforeDestroy_deposedCount(t *testing.T) { m := testModule(t, "apply-cbd-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1061,8 +1061,8 @@ aws_instance.bar.1: func TestContext2Apply_createBeforeDestroy_deposedOnly(t *testing.T) { m := testModule(t, "apply-cbd-deposed-only") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1114,8 +1114,8 @@ aws_instance.bar: func TestContext2Apply_destroyComputed(t *testing.T) { m := testModule(t, "apply-destroy-computed") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -1160,8 +1160,8 @@ func TestContext2Apply_destroyDependsOn(t *testing.T) { func testContext2Apply_destroyDependsOn(t *testing.T) { m := testModule(t, "apply-destroy-depends-on") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1186,7 +1186,7 @@ func testContext2Apply_destroyDependsOn(t *testing.T) { // Record the order we see Apply var actual []string var actualLock sync.Mutex - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { actualLock.Lock() defer actualLock.Unlock() id := req.PriorState.GetAttr("id").AsString() @@ -1278,12 +1278,12 @@ func TestContext2Apply_destroyDependsOnStateOnly(t *testing.T) { func testContext2Apply_destroyDependsOnStateOnly(t *testing.T, state *states.State) { m := testModule(t, "empty") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn // Record the order we see Apply var actual []string var actualLock sync.Mutex - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { actualLock.Lock() defer actualLock.Unlock() id := req.PriorState.GetAttr("id").AsString() @@ -1374,13 +1374,13 @@ func TestContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) { func testContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T, state *states.State) { m := testModule(t, "empty") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn // Record the order we see Apply var actual []string var actualLock sync.Mutex - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { actualLock.Lock() defer actualLock.Unlock() id := req.PriorState.GetAttr("id").AsString() @@ -1415,8 +1415,8 @@ func testContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T, state *stat func TestContext2Apply_dataBasic(t *testing.T) { m := testModule(t, "apply-data-basic") p := testProvider("null") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.ReadDataSourceResponse = providers.ReadDataSourceResponse{ State: cty.ObjectVal(map[string]cty.Value{ "id": cty.StringVal("yo"), @@ -1450,8 +1450,8 @@ func TestContext2Apply_dataBasic(t *testing.T) { func TestContext2Apply_destroyData(t *testing.T) { m := testModule(t, "apply-destroy-data-resource") p := testProvider("null") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -1510,8 +1510,8 @@ func TestContext2Apply_destroySkipsCBD(t *testing.T) { // just doing a `terraform destroy`. m := testModule(t, "apply-destroy-cbd") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -1554,8 +1554,8 @@ func TestContext2Apply_destroySkipsCBD(t *testing.T) { func TestContext2Apply_destroyModuleVarProviderConfig(t *testing.T) { m := testModule(t, "apply-destroy-mod-var-provider-config") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -1589,8 +1589,8 @@ func TestContext2Apply_destroyCrossProviders(t *testing.T) { m := testModule(t, "apply-destroy-cross-providers") p_aws := testProvider("aws") - p_aws.ApplyFn = testApplyFn - p_aws.DiffFn = testDiffFn + p_aws.ApplyResourceChangeFn = testApplyFn + p_aws.PlanResourceChangeFn = testDiffFn p_aws.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "aws_instance": { @@ -1667,8 +1667,8 @@ func getContextForApply_destroyCrossProviders(t *testing.T, m *configs.Config, p func TestContext2Apply_minimal(t *testing.T) { m := testModule(t, "apply-minimal") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -1704,7 +1704,7 @@ func TestContext2Apply_cancel(t *testing.T) { }, }) - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { if !stopped { stopped = true go ctx.Stop() @@ -1718,7 +1718,7 @@ func TestContext2Apply_cancel(t *testing.T) { } return testApplyFn(req) } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn if _, diags := ctx.Plan(); diags.HasErrors() { t.Fatalf("plan errors: %s", diags.Err()) @@ -1761,8 +1761,8 @@ func TestContext2Apply_cancelBlock(t *testing.T) { }) applyCh := make(chan struct{}) - p.DiffFn = testDiffFn - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + p.PlanResourceChangeFn = testDiffFn + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { close(applyCh) for !ctx.sh.Stopped() { @@ -1829,8 +1829,8 @@ aws_instance.foo: func TestContext2Apply_cancelProvisioner(t *testing.T) { m := testModule(t, "apply-cancel-provisioner") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn pr := testProvisioner() pr.GetSchemaResponse = provisioners.GetSchemaResponse{ @@ -1855,12 +1855,12 @@ func TestContext2Apply_cancelProvisioner(t *testing.T) { }) prStopped := make(chan struct{}) - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { // Start the stop process go ctx.Stop() <-prStopped - return nil + return } pr.StopFn = func() error { close(prStopped) @@ -1901,8 +1901,8 @@ aws_instance.foo: (tainted) func TestContext2Apply_compute(t *testing.T) { m := testModule(t, "apply-compute") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "aws_instance": { @@ -1973,8 +1973,8 @@ func TestContext2Apply_compute(t *testing.T) { func TestContext2Apply_countDecrease(t *testing.T) { m := testModule(t, "apply-count-dec") p := testProvider("aws") - p.DiffFn = testDiffFn - p.ApplyFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -2028,8 +2028,8 @@ func TestContext2Apply_countDecrease(t *testing.T) { func TestContext2Apply_countDecreaseToOneX(t *testing.T) { m := testModule(t, "apply-count-dec-one") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -2089,8 +2089,8 @@ func TestContext2Apply_countDecreaseToOneX(t *testing.T) { func TestContext2Apply_countDecreaseToOneCorrupted(t *testing.T) { m := testModule(t, "apply-count-dec-one") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -2143,8 +2143,8 @@ func TestContext2Apply_countDecreaseToOneCorrupted(t *testing.T) { func TestContext2Apply_countTainted(t *testing.T) { m := testModule(t, "apply-count-tainted") p := testProvider("aws") - p.DiffFn = testDiffFn - p.ApplyFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -2206,8 +2206,8 @@ aws_instance.foo.1: func TestContext2Apply_countVariable(t *testing.T) { m := testModule(t, "apply-count-variable") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2234,8 +2234,8 @@ func TestContext2Apply_countVariable(t *testing.T) { func TestContext2Apply_countVariableRef(t *testing.T) { m := testModule(t, "apply-count-variable-ref") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2267,8 +2267,8 @@ func TestContext2Apply_provisionerInterpCount(t *testing.T) { m, snap := testModuleWithSnapshot(t, "apply-provisioner-interp-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn pr := testProvisioner() @@ -2319,8 +2319,8 @@ func TestContext2Apply_provisionerInterpCount(t *testing.T) { func TestContext2Apply_foreachVariable(t *testing.T) { m := testModule(t, "plan-for-each-unknown-value") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2352,8 +2352,8 @@ func TestContext2Apply_foreachVariable(t *testing.T) { func TestContext2Apply_moduleBasic(t *testing.T) { m := testModule(t, "apply-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2380,12 +2380,12 @@ func TestContext2Apply_moduleBasic(t *testing.T) { func TestContext2Apply_moduleDestroyOrder(t *testing.T) { m := testModule(t, "apply-module-destroy-order") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn // Create a custom apply function to track the order they were destroyed var order []string var orderLock sync.Mutex - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { id := req.PriorState.GetAttr("id").AsString() if id == "b" { @@ -2470,8 +2470,8 @@ func TestContext2Apply_moduleDestroyOrder(t *testing.T) { func TestContext2Apply_moduleInheritAlias(t *testing.T) { m := testModule(t, "apply-module-provider-inherit-alias") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.ConfigureFn = func(req providers.ConfigureRequest) (resp providers.ConfigureResponse) { val := req.Config.GetAttr("value") @@ -2521,8 +2521,8 @@ func TestContext2Apply_orphanResource(t *testing.T) { // 2. Apply an empty configuration against the same state, which should // then clean up both the instances and the containing resource objects. p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "test_thing": { @@ -2596,8 +2596,8 @@ func TestContext2Apply_orphanResource(t *testing.T) { func TestContext2Apply_moduleOrphanInheritAlias(t *testing.T) { m := testModule(t, "apply-module-provider-inherit-alias-orphan") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.ConfigureFn = func(req providers.ConfigureRequest) (resp providers.ConfigureResponse) { val := req.Config.GetAttr("value") @@ -2652,8 +2652,8 @@ func TestContext2Apply_moduleOrphanInheritAlias(t *testing.T) { func TestContext2Apply_moduleOrphanProvider(t *testing.T) { m := testModule(t, "apply-module-orphan-provider-inherit") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.ConfigureFn = func(req providers.ConfigureRequest) (resp providers.ConfigureResponse) { val := req.Config.GetAttr("value") @@ -2696,8 +2696,8 @@ func TestContext2Apply_moduleOrphanProvider(t *testing.T) { func TestContext2Apply_moduleOrphanGrandchildProvider(t *testing.T) { m := testModule(t, "apply-module-orphan-provider-inherit") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.ConfigureFn = func(req providers.ConfigureRequest) (resp providers.ConfigureResponse) { val := req.Config.GetAttr("value") @@ -2740,8 +2740,8 @@ func TestContext2Apply_moduleOrphanGrandchildProvider(t *testing.T) { func TestContext2Apply_moduleGrandchildProvider(t *testing.T) { m := testModule(t, "apply-module-grandchild-provider-inherit") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn var callLock sync.Mutex called := false @@ -2787,11 +2787,11 @@ func TestContext2Apply_moduleGrandchildProvider(t *testing.T) { func TestContext2Apply_moduleOnlyProvider(t *testing.T) { m := testModule(t, "apply-module-only-provider") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn pTest := testProvider("test") - pTest.ApplyFn = testApplyFn - pTest.DiffFn = testDiffFn + pTest.ApplyResourceChangeFn = testApplyFn + pTest.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -2820,8 +2820,8 @@ func TestContext2Apply_moduleOnlyProvider(t *testing.T) { func TestContext2Apply_moduleProviderAlias(t *testing.T) { m := testModule(t, "apply-module-provider-alias") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2848,8 +2848,8 @@ func TestContext2Apply_moduleProviderAlias(t *testing.T) { func TestContext2Apply_moduleProviderAliasTargets(t *testing.T) { m := testModule(t, "apply-module-provider-alias") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2888,8 +2888,8 @@ func TestContext2Apply_moduleProviderAliasTargets(t *testing.T) { func TestContext2Apply_moduleProviderCloseNested(t *testing.T) { m := testModule(t, "apply-module-provider-close-nested") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -2927,8 +2927,8 @@ func TestContext2Apply_moduleProviderCloseNested(t *testing.T) { func TestContext2Apply_moduleVarRefExisting(t *testing.T) { m := testModule(t, "apply-ref-existing") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -2967,8 +2967,8 @@ func TestContext2Apply_moduleVarRefExisting(t *testing.T) { func TestContext2Apply_moduleVarResourceCount(t *testing.T) { m := testModule(t, "apply-module-var-resource-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -3017,8 +3017,8 @@ func TestContext2Apply_moduleVarResourceCount(t *testing.T) { func TestContext2Apply_moduleBool(t *testing.T) { m := testModule(t, "apply-module-bool") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -3047,8 +3047,8 @@ func TestContext2Apply_moduleBool(t *testing.T) { func TestContext2Apply_moduleTarget(t *testing.T) { m := testModule(t, "plan-targeted-cross-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -3095,12 +3095,12 @@ module.B: func TestContext2Apply_multiProvider(t *testing.T) { m := testModule(t, "apply-multi-provider") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn pDO := testProvider("do") - pDO.ApplyFn = testApplyFn - pDO.DiffFn = testDiffFn + pDO.ApplyResourceChangeFn = testApplyFn + pDO.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -3134,8 +3134,8 @@ func TestContext2Apply_multiProvider(t *testing.T) { func TestContext2Apply_multiProviderDestroy(t *testing.T) { m := testModule(t, "apply-multi-provider-destroy") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ Provider: &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -3153,8 +3153,8 @@ func TestContext2Apply_multiProviderDestroy(t *testing.T) { } p2 := testProvider("vault") - p2.ApplyFn = testApplyFn - p2.DiffFn = testDiffFn + p2.ApplyResourceChangeFn = testApplyFn + p2.PlanResourceChangeFn = testDiffFn p2.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "vault_instance": { @@ -3217,8 +3217,8 @@ func TestContext2Apply_multiProviderDestroy(t *testing.T) { } // Set the apply functions - p.ApplyFn = applyFn - p2.ApplyFn = applyFn + p.ApplyResourceChangeFn = applyFn + p2.ApplyResourceChangeFn = applyFn ctx := testContext2(t, &ContextOpts{ Destroy: true, @@ -3255,8 +3255,8 @@ func TestContext2Apply_multiProviderDestroy(t *testing.T) { func TestContext2Apply_multiProviderDestroyChild(t *testing.T) { m := testModule(t, "apply-multi-provider-destroy-child") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ Provider: &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -3274,8 +3274,8 @@ func TestContext2Apply_multiProviderDestroyChild(t *testing.T) { } p2 := testProvider("vault") - p2.ApplyFn = testApplyFn - p2.DiffFn = testDiffFn + p2.ApplyResourceChangeFn = testApplyFn + p2.PlanResourceChangeFn = testDiffFn p2.GetSchemaReturn = &ProviderSchema{ Provider: &configschema.Block{}, ResourceTypes: map[string]*configschema.Block{ @@ -3339,8 +3339,8 @@ func TestContext2Apply_multiProviderDestroyChild(t *testing.T) { } // Set the apply functions - p.ApplyFn = applyFn - p2.ApplyFn = applyFn + p.ApplyResourceChangeFn = applyFn + p2.ApplyResourceChangeFn = applyFn ctx := testContext2(t, &ContextOpts{ Destroy: true, @@ -3376,8 +3376,8 @@ func TestContext2Apply_multiProviderDestroyChild(t *testing.T) { func TestContext2Apply_multiVar(t *testing.T) { m := testModule(t, "apply-multi-var") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn // First, apply with a count of 3 ctx := testContext2(t, &ContextOpts{ @@ -3461,14 +3461,14 @@ func TestContext2Apply_multiVarComprehensive(t *testing.T) { configs := map[string]*ResourceConfig{} var configsLock sync.Mutex - p.ApplyFn = testApplyFn + p.ApplyResourceChangeFn = testApplyFn p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse { proposed := req.ProposedNewState configsLock.Lock() defer configsLock.Unlock() key := proposed.GetAttr("key").AsString() - // This test was originally written using the legacy p.DiffFn interface, + // This test was originally written using the legacy p.PlanResourceChangeFn interface, // and so the assertions below expect an old-style ResourceConfig, which // we'll construct via our shim for now to avoid rewriting all of the // assertions. @@ -3666,8 +3666,8 @@ func TestContext2Apply_multiVarComprehensive(t *testing.T) { func TestContext2Apply_multiVarOrder(t *testing.T) { m := testModule(t, "apply-multi-var-order") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn // First, apply with a count of 3 ctx := testContext2(t, &ContextOpts{ @@ -3700,8 +3700,8 @@ func TestContext2Apply_multiVarOrder(t *testing.T) { func TestContext2Apply_multiVarOrderInterp(t *testing.T) { m := testModule(t, "apply-multi-var-order-interp") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn // First, apply with a count of 3 ctx := testContext2(t, &ContextOpts{ @@ -3738,8 +3738,8 @@ func TestContext2Apply_multiVarCountDec(t *testing.T) { { m := testModule(t, "apply-multi-var-count-dec") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -3773,7 +3773,7 @@ func TestContext2Apply_multiVarCountDec(t *testing.T) { // right order. m := testModule(t, "apply-multi-var-count-dec") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn // Verify that aws_instance.bar is modified first and nothing // else happens at the same time. @@ -3781,7 +3781,7 @@ func TestContext2Apply_multiVarCountDec(t *testing.T) { var checked bool var called int32 var lock sync.Mutex - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { lock.Lock() defer lock.Unlock() @@ -3845,8 +3845,8 @@ func TestContext2Apply_multiVarCountDec(t *testing.T) { func TestContext2Apply_multiVarMissingState(t *testing.T) { m := testModule(t, "apply-multi-var-missing-state") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "test_thing": { @@ -3881,8 +3881,8 @@ func TestContext2Apply_multiVarMissingState(t *testing.T) { func TestContext2Apply_outputOrphan(t *testing.T) { m := testModule(t, "apply-output-orphan") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -3916,8 +3916,8 @@ func TestContext2Apply_outputOrphan(t *testing.T) { func TestContext2Apply_outputOrphanModule(t *testing.T) { m := testModule(t, "apply-output-orphan-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() @@ -3971,12 +3971,12 @@ func TestContext2Apply_outputOrphanModule(t *testing.T) { func TestContext2Apply_providerComputedVar(t *testing.T) { m := testModule(t, "apply-provider-computed") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn pTest := testProvider("test") - pTest.ApplyFn = testApplyFn - pTest.DiffFn = testDiffFn + pTest.ApplyResourceChangeFn = testApplyFn + pTest.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -4007,8 +4007,8 @@ func TestContext2Apply_providerComputedVar(t *testing.T) { func TestContext2Apply_providerConfigureDisabled(t *testing.T) { m := testModule(t, "apply-provider-configure-disabled") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.ConfigureFn = func(req providers.ConfigureRequest) (resp providers.ConfigureResponse) { val := req.Config.GetAttr("value") @@ -4043,8 +4043,8 @@ func TestContext2Apply_provisionerModule(t *testing.T) { m := testModule(t, "apply-provisioner-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn pr := testProvisioner() pr.GetSchemaResponse = provisioners.GetSchemaResponse{ @@ -4090,15 +4090,16 @@ func TestContext2Apply_Provisioner_compute(t *testing.T) { m := testModule(t, "apply-provisioner-compute") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - val, ok := c.Config["command"] - if !ok || val != "computed_value" { - t.Fatalf("bad value for foo: %v %#v", val, c) + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + + val := req.Config.GetAttr("command").AsString() + if val != "computed_value" { + t.Fatalf("bad value for foo: %q", val) } - return nil + return } ctx := testContext2(t, &ContextOpts{ Config: m, @@ -4141,9 +4142,9 @@ func TestContext2Apply_provisionerCreateFail(t *testing.T) { m := testModule(t, "apply-provisioner-fail-create") p := testProvider("aws") pr := testProvisioner() - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { resp := testApplyFn(req) resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("error")) @@ -4180,9 +4181,9 @@ func TestContext2Apply_provisionerCreateFailNoId(t *testing.T) { m := testModule(t, "apply-provisioner-fail-create") p := testProvider("aws") pr := testProvisioner() - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("error")) return } @@ -4217,10 +4218,11 @@ func TestContext2Apply_provisionerFail(t *testing.T) { m := testModule(t, "apply-provisioner-fail") p := testProvider("aws") pr := testProvisioner() - p.DiffFn = testDiffFn - p.ApplyFn = testApplyFn - pr.ApplyFn = func(*InstanceState, *ResourceConfig) error { - return fmt.Errorf("EXPLOSION") + p.PlanResourceChangeFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("EXPLOSION")) + return } ctx := testContext2(t, &ContextOpts{ @@ -4253,10 +4255,11 @@ func TestContext2Apply_provisionerFail_createBeforeDestroy(t *testing.T) { m := testModule(t, "apply-provisioner-fail-create-before") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - pr.ApplyFn = func(*InstanceState, *ResourceConfig) error { - return fmt.Errorf("EXPLOSION") + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("EXPLOSION")) + return } state := states.NewState() @@ -4319,11 +4322,11 @@ func TestContext2Apply_error_createBeforeDestroy(t *testing.T) { }, State: state, }) - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("placeholder error from ApplyFn")) return } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn if _, diags := ctx.Plan(); diags.HasErrors() { t.Fatalf("plan errors: %s", diags.Err()) @@ -4368,7 +4371,7 @@ func TestContext2Apply_errorDestroy_createBeforeDestroy(t *testing.T) { }, State: state, }) - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { // Fail the destroy! if req.PlannedState.IsNull() { resp.NewState = req.PriorState @@ -4378,7 +4381,7 @@ func TestContext2Apply_errorDestroy_createBeforeDestroy(t *testing.T) { return testApplyFn(req) } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn if _, diags := ctx.Plan(); diags.HasErrors() { t.Fatalf("plan errors: %s", diags.Err()) @@ -4422,7 +4425,7 @@ func TestContext2Apply_multiDepose_createBeforeDestroy(t *testing.T) { mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`), ) - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -4449,7 +4452,7 @@ func TestContext2Apply_multiDepose_createBeforeDestroy(t *testing.T) { resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("destroy failed")) return } - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { if req.PlannedState.IsNull() { return destroyFunc(req) } else { @@ -4613,11 +4616,12 @@ func TestContext2Apply_provisionerFailContinue(t *testing.T) { m := testModule(t, "apply-provisioner-fail-continue") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - return fmt.Errorf("provisioner error") + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("provisioner error")) + return } ctx := testContext2(t, &ContextOpts{ @@ -4660,10 +4664,11 @@ func TestContext2Apply_provisionerFailContinueHook(t *testing.T) { m := testModule(t, "apply-provisioner-fail-continue") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - return fmt.Errorf("provisioner error") + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("provisioner error")) + return } ctx := testContext2(t, &ContextOpts{ @@ -4697,15 +4702,15 @@ func TestContext2Apply_provisionerDestroy(t *testing.T) { m := testModule(t, "apply-provisioner-destroy") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - val, ok := c.Config["command"] - if !ok || val != "destroy a bar" { - t.Fatalf("bad value for foo: %v %#v", val, c) + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + val := req.Config.GetAttr("command").AsString() + if val != "destroy a bar" { + t.Fatalf("bad value for foo: %q", val) } - return nil + return } state := states.NewState() @@ -4753,10 +4758,11 @@ func TestContext2Apply_provisionerDestroyFail(t *testing.T) { m := testModule(t, "apply-provisioner-destroy") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - return fmt.Errorf("provisioner error") + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("provisioner error")) + return } state := states.NewState() @@ -4810,21 +4816,22 @@ func TestContext2Apply_provisionerDestroyFailContinue(t *testing.T) { m := testModule(t, "apply-provisioner-destroy-continue") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn var l sync.Mutex var calls []string - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - val, ok := c.Config["command"] - if !ok { - t.Fatalf("bad value for foo: %v %#v", val, c) + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + val := req.Config.GetAttr("command") + if val.IsNull() { + t.Fatalf("bad value for foo: %#v", val) } l.Lock() defer l.Unlock() - calls = append(calls, val.(string)) - return fmt.Errorf("provisioner error") + calls = append(calls, val.AsString()) + resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("provisioner error")) + return } state := states.NewState() @@ -4879,21 +4886,22 @@ func TestContext2Apply_provisionerDestroyFailContinueFail(t *testing.T) { m := testModule(t, "apply-provisioner-destroy-fail") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn var l sync.Mutex var calls []string - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - val, ok := c.Config["command"] - if !ok { - t.Fatalf("bad value for foo: %v %#v", val, c) + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + val := req.Config.GetAttr("command") + if val.IsNull() { + t.Fatalf("bad value for foo: %#v", val) } l.Lock() defer l.Unlock() - calls = append(calls, val.(string)) - return fmt.Errorf("provisioner error") + calls = append(calls, val.AsString()) + resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("provisioner error")) + return } state := states.NewState() @@ -4950,23 +4958,18 @@ func TestContext2Apply_provisionerDestroyTainted(t *testing.T) { m := testModule(t, "apply-provisioner-destroy") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn destroyCalled := false - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { expected := "create a b" - if rs.ID == "bar" { - destroyCalled = true - return nil + val := req.Config.GetAttr("command") + if val.AsString() != expected { + t.Fatalf("bad value for command: %#v", val) } - val, ok := c.Config["command"] - if !ok || val != expected { - t.Fatalf("bad value for command: %v %#v", val, c) - } - - return nil + return } state := states.NewState() @@ -5029,17 +5032,17 @@ aws_instance.foo["a"]: func TestContext2Apply_provisionerResourceRef(t *testing.T) { m := testModule(t, "apply-provisioner-resource-ref") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn pr := testProvisioner() - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - val, ok := c.Config["command"] - if !ok || val != "2" { - t.Fatalf("bad value for foo: %v %#v", val, c) + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + val := req.Config.GetAttr("command") + if val.AsString() != "2" { + t.Fatalf("bad value for command: %#v", val) } - return nil + return } ctx := testContext2(t, &ContextOpts{ @@ -5077,15 +5080,15 @@ func TestContext2Apply_provisionerSelfRef(t *testing.T) { m := testModule(t, "apply-provisioner-self-ref") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - val, ok := c.Config["command"] - if !ok || val != "bar" { - t.Fatalf("bad value for command: %v %#v", val, c) + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + val := req.Config.GetAttr("command") + if val.AsString() != "bar" { + t.Fatalf("bad value for command: %#v", val) } - return nil + return } ctx := testContext2(t, &ContextOpts{ @@ -5126,19 +5129,19 @@ func TestContext2Apply_provisionerMultiSelfRef(t *testing.T) { m := testModule(t, "apply-provisioner-multi-self-ref") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { lock.Lock() defer lock.Unlock() - val, ok := c.Config["command"] - if !ok { - t.Fatalf("bad value for command: %v %#v", val, c) + val := req.Config.GetAttr("command") + if val.IsNull() { + t.Fatalf("bad value for command: %#v", val) } - commands = append(commands, val.(string)) - return nil + commands = append(commands, val.AsString()) + return } ctx := testContext2(t, &ContextOpts{ @@ -5186,19 +5189,19 @@ func TestContext2Apply_provisionerMultiSelfRefSingle(t *testing.T) { m := testModule(t, "apply-provisioner-multi-self-ref-single") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { lock.Lock() defer lock.Unlock() - val, ok := c.Config["order"] - if !ok { - t.Fatalf("bad value for order: %v %#v", val, c) + val := req.Config.GetAttr("order") + if val.IsNull() { + t.Fatalf("no val for order") } - order = append(order, val.(string)) - return nil + order = append(order, val.AsString()) + return } ctx := testContext2(t, &ContextOpts{ @@ -5243,15 +5246,15 @@ func TestContext2Apply_provisionerExplicitSelfRef(t *testing.T) { m := testModule(t, "apply-provisioner-explicit-self-ref") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - val, ok := c.Config["command"] - if !ok || val != "bar" { - t.Fatalf("bad value for command: %v %#v", val, c) + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + val := req.Config.GetAttr("command") + if val.IsNull() || val.AsString() != "bar" { + t.Fatalf("bad value for command: %#v", val) } - return nil + return } var state *states.State @@ -5313,16 +5316,16 @@ func TestContext2Apply_provisionerForEachSelfRef(t *testing.T) { m := testModule(t, "apply-provisioner-for-each-self") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - val, ok := c.Config["command"] - if !ok { - t.Fatalf("bad value for command: %v %#v", val, c) + pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) { + val := req.Config.GetAttr("command") + if val.IsNull() { + t.Fatalf("bad value for command: %#v", val) } - return nil + return resp } ctx := testContext2(t, &ContextOpts{ @@ -5350,11 +5353,8 @@ func TestContext2Apply_Provisioner_Diff(t *testing.T) { m := testModule(t, "apply-provisioner-diff") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - return nil - } + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -5459,8 +5459,8 @@ func TestContext2Apply_outputDiffVars(t *testing.T) { State: state, }) - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn //func(info *InstanceInfo, s *InstanceState, rc *ResourceConfig) (*InstanceDiff, error) { // d := &InstanceDiff{ // Attributes: map[string]*ResourceAttrDiff{}, @@ -5502,8 +5502,8 @@ func TestContext2Apply_destroyX(t *testing.T) { m := testModule(t, "apply-destroy") h := new(HookRecordApplyOrder) p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Hooks: []Hook{h}, @@ -5562,8 +5562,8 @@ func TestContext2Apply_destroyOrder(t *testing.T) { m := testModule(t, "apply-destroy") h := new(HookRecordApplyOrder) p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Hooks: []Hook{h}, @@ -5625,8 +5625,8 @@ func TestContext2Apply_destroyModulePrefix(t *testing.T) { m := testModule(t, "apply-destroy-module-resource-prefix") h := new(MockHook) p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Hooks: []Hook{h}, @@ -5680,8 +5680,8 @@ func TestContext2Apply_destroyModulePrefix(t *testing.T) { func TestContext2Apply_destroyNestedModule(t *testing.T) { m := testModule(t, "apply-destroy-nested-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -5722,8 +5722,8 @@ func TestContext2Apply_destroyNestedModule(t *testing.T) { func TestContext2Apply_destroyDeeplyNestedModule(t *testing.T) { m := testModule(t, "apply-destroy-deeply-nested-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -5764,8 +5764,8 @@ func TestContext2Apply_destroyDeeplyNestedModule(t *testing.T) { func TestContext2Apply_destroyModuleWithAttrsReferencingResource(t *testing.T) { m, snap := testModuleWithSnapshot(t, "apply-destroy-module-with-attrs") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn var state *states.State { @@ -5845,8 +5845,8 @@ func TestContext2Apply_destroyModuleWithAttrsReferencingResource(t *testing.T) { func TestContext2Apply_destroyWithModuleVariableAndCount(t *testing.T) { m, snap := testModuleWithSnapshot(t, "apply-destroy-mod-var-and-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn var state *states.State var diags tfdiags.Diagnostics @@ -5922,8 +5922,8 @@ func TestContext2Apply_destroyWithModuleVariableAndCount(t *testing.T) { func TestContext2Apply_destroyTargetWithModuleVariableAndCount(t *testing.T) { m := testModule(t, "apply-destroy-mod-var-and-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn var state *states.State var diags tfdiags.Diagnostics @@ -6001,8 +6001,8 @@ func TestContext2Apply_destroyTargetWithModuleVariableAndCount(t *testing.T) { func TestContext2Apply_destroyWithModuleVariableAndCountNested(t *testing.T) { m, snap := testModuleWithSnapshot(t, "apply-destroy-mod-var-and-count-nested") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn var state *states.State var diags tfdiags.Diagnostics @@ -6078,8 +6078,8 @@ func TestContext2Apply_destroyWithModuleVariableAndCountNested(t *testing.T) { func TestContext2Apply_destroyOutputs(t *testing.T) { m := testModule(t, "apply-destroy-outputs") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.ReadDataSourceFn = func(req providers.ReadDataSourceRequest) providers.ReadDataSourceResponse { // add the required id @@ -6172,8 +6172,8 @@ func TestContext2Apply_destroyOrphan(t *testing.T) { State: state, }) - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn if _, diags := ctx.Plan(); diags.HasErrors() { t.Fatalf("plan errors: %s", diags.Err()) @@ -6194,14 +6194,8 @@ func TestContext2Apply_destroyTaintedProvisioner(t *testing.T) { m := testModule(t, "apply-destroy-provisioner") p := testProvider("aws") pr := testProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - - called := false - pr.ApplyFn = func(rs *InstanceState, c *ResourceConfig) error { - called = true - return nil - } + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -6235,7 +6229,7 @@ func TestContext2Apply_destroyTaintedProvisioner(t *testing.T) { t.Fatalf("diags: %s", diags.Err()) } - if called { + if pr.ProvisionResourceCalled { t.Fatal("provisioner should not be called") } @@ -6258,7 +6252,7 @@ func TestContext2Apply_error(t *testing.T) { }, }) - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { if errored { resp.NewState = req.PlannedState resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("error")) @@ -6268,7 +6262,7 @@ func TestContext2Apply_error(t *testing.T) { return testApplyFn(req) } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn if _, diags := ctx.Plan(); diags.HasErrors() { t.Fatalf("plan errors: %s", diags.Err()) @@ -6534,7 +6528,7 @@ func TestContext2Apply_errorPartial(t *testing.T) { State: state, }) - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { if errored { resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("error")) return @@ -6543,7 +6537,7 @@ func TestContext2Apply_errorPartial(t *testing.T) { return testApplyFn(req) } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn if _, diags := ctx.Plan(); diags.HasErrors() { t.Fatalf("plan errors: %s", diags.Err()) @@ -6570,8 +6564,8 @@ func TestContext2Apply_hook(t *testing.T) { m := testModule(t, "apply-good") h := new(MockHook) p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Hooks: []Hook{h}, @@ -6603,8 +6597,8 @@ func TestContext2Apply_hookOrphan(t *testing.T) { m := testModule(t, "apply-blank") h := new(MockHook) p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -6655,8 +6649,8 @@ func TestContext2Apply_idAttr(t *testing.T) { }, }) - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn if _, diags := ctx.Plan(); diags.HasErrors() { t.Fatalf("plan errors: %s", diags.Err()) @@ -6685,8 +6679,8 @@ func TestContext2Apply_idAttr(t *testing.T) { func TestContext2Apply_outputBasic(t *testing.T) { m := testModule(t, "apply-output") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -6713,8 +6707,8 @@ func TestContext2Apply_outputBasic(t *testing.T) { func TestContext2Apply_outputAdd(t *testing.T) { m1 := testModule(t, "apply-output-add-before") p1 := testProvider("aws") - p1.ApplyFn = testApplyFn - p1.DiffFn = testDiffFn + p1.ApplyResourceChangeFn = testApplyFn + p1.PlanResourceChangeFn = testDiffFn ctx1 := testContext2(t, &ContextOpts{ Config: m1, Providers: map[addrs.Provider]providers.Factory{ @@ -6733,8 +6727,8 @@ func TestContext2Apply_outputAdd(t *testing.T) { m2 := testModule(t, "apply-output-add-after") p2 := testProvider("aws") - p2.ApplyFn = testApplyFn - p2.DiffFn = testDiffFn + p2.ApplyResourceChangeFn = testApplyFn + p2.PlanResourceChangeFn = testDiffFn ctx2 := testContext2(t, &ContextOpts{ Config: m2, Providers: map[addrs.Provider]providers.Factory{ @@ -6763,8 +6757,8 @@ func TestContext2Apply_outputAdd(t *testing.T) { func TestContext2Apply_outputList(t *testing.T) { m := testModule(t, "apply-output-list") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -6791,8 +6785,8 @@ func TestContext2Apply_outputList(t *testing.T) { func TestContext2Apply_outputMulti(t *testing.T) { m := testModule(t, "apply-output-multi") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -6819,8 +6813,8 @@ func TestContext2Apply_outputMulti(t *testing.T) { func TestContext2Apply_outputMultiIndex(t *testing.T) { m := testModule(t, "apply-output-multi-index") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -6855,14 +6849,14 @@ func TestContext2Apply_taintX(t *testing.T) { time.Sleep(10 * time.Millisecond) } - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { once.Do(simulateProviderDelay) if req.PlannedState.IsNull() { atomic.AddInt32(&destroyCount, 1) } return testApplyFn(req) } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -6908,8 +6902,8 @@ func TestContext2Apply_taintX(t *testing.T) { func TestContext2Apply_taintDep(t *testing.T) { m := testModule(t, "apply-taint-dep") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -6960,8 +6954,8 @@ func TestContext2Apply_taintDep(t *testing.T) { func TestContext2Apply_taintDepRequiresNew(t *testing.T) { m := testModule(t, "apply-taint-dep-requires-new") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -7012,8 +7006,8 @@ func TestContext2Apply_taintDepRequiresNew(t *testing.T) { func TestContext2Apply_targeted(t *testing.T) { m := testModule(t, "apply-targeted") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -7052,8 +7046,8 @@ aws_instance.foo: func TestContext2Apply_targetedCount(t *testing.T) { m := testModule(t, "apply-targeted-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -7094,8 +7088,8 @@ aws_instance.foo.2: func TestContext2Apply_targetedCountIndex(t *testing.T) { m := testModule(t, "apply-targeted-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -7128,8 +7122,8 @@ aws_instance.foo.1: func TestContext2Apply_targetedDestroy(t *testing.T) { m := testModule(t, "destroy-targeted") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -7210,8 +7204,8 @@ func TestContext2Apply_targetedDestroy(t *testing.T) { func TestContext2Apply_targetedDestroyCountDeps(t *testing.T) { m := testModule(t, "apply-destroy-targeted-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -7263,8 +7257,8 @@ func TestContext2Apply_targetedDestroyCountDeps(t *testing.T) { func TestContext2Apply_targetedDestroyModule(t *testing.T) { m := testModule(t, "apply-targeted-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -7343,8 +7337,8 @@ module.child: func TestContext2Apply_targetedDestroyCountIndex(t *testing.T) { m := testModule(t, "apply-targeted-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn foo := &states.ResourceInstanceObjectSrc{ Status: states.ObjectReady, @@ -7433,8 +7427,8 @@ aws_instance.foo.1: func TestContext2Apply_targetedModule(t *testing.T) { m := testModule(t, "apply-targeted-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -7482,8 +7476,8 @@ module.child: func TestContext2Apply_targetedModuleDep(t *testing.T) { m := testModule(t, "apply-targeted-module-dep") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -7534,8 +7528,8 @@ module.child: func TestContext2Apply_targetedModuleUnrelatedOutputs(t *testing.T) { m := testModule(t, "apply-targeted-module-unrelated-outputs") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() _ = state.EnsureModule(addrs.RootModuleInstance.Child("child2", addrs.NoKey)) @@ -7585,8 +7579,8 @@ module.child2: func TestContext2Apply_targetedModuleResource(t *testing.T) { m := testModule(t, "apply-targeted-module-resource") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -7627,8 +7621,8 @@ module.child: func TestContext2Apply_targetedResourceOrphanModule(t *testing.T) { m := testModule(t, "apply-targeted-resource-orphan-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() child := state.EnsureModule(addrs.RootModuleInstance.Child("parent", addrs.NoKey)) @@ -7666,8 +7660,8 @@ func TestContext2Apply_targetedResourceOrphanModule(t *testing.T) { func TestContext2Apply_unknownAttribute(t *testing.T) { m := testModule(t, "apply-unknown") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { resp = testDiffFn(req) planned := resp.PlannedState.AsValueMap() planned["unknown"] = cty.UnknownVal(cty.String) @@ -7714,8 +7708,8 @@ func TestContext2Apply_unknownAttribute(t *testing.T) { func TestContext2Apply_unknownAttributeInterpolate(t *testing.T) { m := testModule(t, "apply-unknown-interpolate") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -7832,8 +7826,8 @@ func TestContext2Apply_createBefore_depends(t *testing.T) { m := testModule(t, "apply-depends-create-before") h := new(HookRecordApplyOrder) p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -7935,7 +7929,7 @@ func TestContext2Apply_singleDestroy(t *testing.T) { h := new(HookRecordApplyOrder) p := testProvider("aws") invokeCount := 0 - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { invokeCount++ switch invokeCount { case 1: @@ -7962,7 +7956,7 @@ func TestContext2Apply_singleDestroy(t *testing.T) { return testApplyFn(req) } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -8034,8 +8028,8 @@ func TestContext2Apply_singleDestroy(t *testing.T) { // GH-7824 func TestContext2Apply_issue7824(t *testing.T) { p := testProvider("template") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "template_file": { @@ -8090,8 +8084,8 @@ func TestContext2Apply_issue5254(t *testing.T) { // Create a provider. We use "template" here just to match the repro // we got from the issue itself. p := testProvider("template") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "template_file": { @@ -8183,8 +8177,8 @@ template_file.parent.0: func TestContext2Apply_targetedWithTaintedInState(t *testing.T) { p := testProvider("aws") - p.DiffFn = testDiffFn - p.ApplyFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn m, snap := testModuleWithSnapshot(t, "apply-tainted-targets") state := states.NewState() @@ -8256,8 +8250,8 @@ aws_instance.ifailedprovisioners: (tainted) func TestContext2Apply_ignoreChangesCreate(t *testing.T) { m := testModule(t, "apply-ignore-changes-create") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn instanceSchema := p.GetSchemaReturn.ResourceTypes["aws_instance"] instanceSchema.Attributes["required_field"] = &configschema.Attribute{ @@ -8305,9 +8299,9 @@ aws_instance.foo: func TestContext2Apply_ignoreChangesWithDep(t *testing.T) { m := testModule(t, "apply-ignore-changes-dep") p := testProvider("aws") - p.ApplyFn = testApplyFn + p.ApplyResourceChangeFn = testApplyFn - p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { + p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { resp.PlannedState = req.ProposedNewState switch req.TypeName { @@ -8400,8 +8394,8 @@ func TestContext2Apply_ignoreChangesWithDep(t *testing.T) { func TestContext2Apply_ignoreChangesWildcard(t *testing.T) { m := testModule(t, "apply-ignore-changes-wildcard") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn instanceSchema := p.GetSchemaReturn.ResourceTypes["aws_instance"] instanceSchema.Attributes["required_field"] = &configschema.Attribute{ @@ -8449,8 +8443,8 @@ aws_instance.foo: func TestContext2Apply_destroyNestedModuleWithAttrsReferencingResource(t *testing.T) { m, snap := testModuleWithSnapshot(t, "apply-destroy-nested-module-with-attrs") p := testProvider("null") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn var state *states.State var diags tfdiags.Diagnostics @@ -8545,13 +8539,13 @@ resource "null_instance" "depends" { // solely on the configuration providing "depends_on" provisionerOutput := "" - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { // the side effect of the resource being applied provisionerOutput = "APPLIED" return testApplyFn(req) } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.ReadDataSourceFn = func(req providers.ReadDataSourceRequest) providers.ReadDataSourceResponse { return providers.ReadDataSourceResponse{ State: cty.ObjectVal(map[string]cty.Value{ @@ -8615,7 +8609,7 @@ resource "null_instance" "depends" { } `}) - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse { // the side effect of the resource being applied provisionerOutput = "APPLIED_AGAIN" return testApplyFn(req) @@ -8648,8 +8642,8 @@ resource "null_instance" "depends" { func TestContext2Apply_terraformWorkspace(t *testing.T) { m := testModule(t, "apply-terraform-workspace") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Meta: &ContextMeta{Env: "foo"}, @@ -8679,8 +8673,8 @@ func TestContext2Apply_terraformWorkspace(t *testing.T) { func TestContext2Apply_multiRef(t *testing.T) { m := testModule(t, "apply-multi-ref") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -8706,8 +8700,8 @@ func TestContext2Apply_multiRef(t *testing.T) { func TestContext2Apply_targetedModuleRecursive(t *testing.T) { m := testModule(t, "apply-targeted-module-recursive") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -8780,8 +8774,8 @@ result_3 = hello world func TestContext2Apply_destroyWithLocals(t *testing.T) { m := testModule(t, "apply-destroy-with-locals") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -8835,8 +8829,8 @@ func TestContext2Apply_providerWithLocals(t *testing.T) { return } - p.DiffFn = testDiffFn - p.ApplyFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -8883,8 +8877,8 @@ func TestContext2Apply_providerWithLocals(t *testing.T) { func TestContext2Apply_destroyWithProviders(t *testing.T) { m := testModule(t, "destroy-module-with-provider") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() removed := state.EnsureModule(addrs.RootModuleInstance.Child("mod", addrs.NoKey).Child("removed", addrs.NoKey)) @@ -8942,7 +8936,7 @@ func TestContext2Apply_destroyWithProviders(t *testing.T) { func TestContext2Apply_providersFromState(t *testing.T) { m := configs.NewEmptyConfig() p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn implicitProviderState := states.NewState() impRoot := implicitProviderState.EnsureModule(addrs.RootModuleInstance) @@ -9041,8 +9035,8 @@ func TestContext2Apply_plannedInterpolatedCount(t *testing.T) { m, snap := testModuleWithSnapshot(t, "apply-interpolated-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn Providers := map[addrs.Provider]providers.Factory{ addrs.NewDefaultProvider("aws"): testProviderFuncFixed(p), @@ -9095,8 +9089,8 @@ func TestContext2Apply_plannedDestroyInterpolatedCount(t *testing.T) { m, snap := testModuleWithSnapshot(t, "plan-destroy-interpolated-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn providers := map[addrs.Provider]providers.Factory{ addrs.NewDefaultProvider("aws"): testProviderFuncFixed(p), } @@ -9158,8 +9152,8 @@ func TestContext2Apply_scaleInMultivarRef(t *testing.T) { m := testModule(t, "apply-resource-scale-in") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn Providers := map[addrs.Provider]providers.Factory{ addrs.NewDefaultProvider("aws"): testProviderFuncFixed(p), @@ -9350,7 +9344,7 @@ func TestContext2Apply_invalidIndexRef(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn m := testModule(t, "apply-invalid-index") c := testContext2(t, &ContextOpts{ @@ -9389,8 +9383,8 @@ func TestContext2Apply_moduleReplaceCycle(t *testing.T) { } p := testProvider("aws") - p.DiffFn = testDiffFn - p.ApplyFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn instanceSchema := &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -9528,8 +9522,8 @@ func TestContext2Apply_moduleReplaceCycle(t *testing.T) { func TestContext2Apply_destroyDataCycle(t *testing.T) { m, snap := testModuleWithSnapshot(t, "apply-destroy-data-cycle") p := testProvider("null") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -9605,8 +9599,8 @@ func TestContext2Apply_destroyDataCycle(t *testing.T) { func TestContext2Apply_taintedDestroyFailure(t *testing.T) { m := testModule(t, "apply-destroy-tainted") p := testProvider("test") - p.DiffFn = testDiffFn - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.PlanResourceChangeFn = testDiffFn + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { // All destroys fail. if req.PlannedState.IsNull() { resp.Diagnostics = resp.Diagnostics.Append(errors.New("failure")) @@ -9769,7 +9763,7 @@ func TestContext2Apply_taintedDestroyFailure(t *testing.T) { func TestContext2Apply_plannedConnectionRefs(t *testing.T) { m := testModule(t, "apply-plan-connection-refs") p := testProvider("test") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { s := req.PlannedState.AsValueMap() // delay "a" slightly, so if the reference edge is missing the "b" @@ -9827,8 +9821,8 @@ func TestContext2Apply_plannedConnectionRefs(t *testing.T) { func TestContext2Apply_cbdCycle(t *testing.T) { m, snap := testModuleWithSnapshot(t, "apply-cbd-cycle") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -9946,7 +9940,7 @@ func TestContext2Apply_cbdCycle(t *testing.T) { func TestContext2Apply_ProviderMeta_apply_set(t *testing.T) { m := testModule(t, "provider-meta-set") p := testProvider("test") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn schema := p.GetSchemaReturn schema.ProviderMeta = &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -10029,7 +10023,7 @@ func TestContext2Apply_ProviderMeta_apply_set(t *testing.T) { func TestContext2Apply_ProviderMeta_apply_unset(t *testing.T) { m := testModule(t, "provider-meta-unset") p := testProvider("test") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn schema := p.GetSchemaReturn schema.ProviderMeta = &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -10089,7 +10083,7 @@ func TestContext2Apply_ProviderMeta_apply_unset(t *testing.T) { func TestContext2Apply_ProviderMeta_plan_set(t *testing.T) { m := testModule(t, "provider-meta-set") p := testProvider("test") - p.ApplyFn = testApplyFn + p.ApplyResourceChangeFn = testApplyFn schema := p.GetSchemaReturn schema.ProviderMeta = &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -10158,7 +10152,7 @@ func TestContext2Apply_ProviderMeta_plan_set(t *testing.T) { func TestContext2Apply_ProviderMeta_plan_unset(t *testing.T) { m := testModule(t, "provider-meta-unset") p := testProvider("test") - p.ApplyFn = testApplyFn + p.ApplyResourceChangeFn = testApplyFn schema := p.GetSchemaReturn schema.ProviderMeta = &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -10206,8 +10200,8 @@ func TestContext2Apply_ProviderMeta_plan_unset(t *testing.T) { func TestContext2Apply_ProviderMeta_plan_setNoSchema(t *testing.T) { m := testModule(t, "provider-meta-set") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -10246,8 +10240,8 @@ func TestContext2Apply_ProviderMeta_plan_setNoSchema(t *testing.T) { func TestContext2Apply_ProviderMeta_plan_setInvalid(t *testing.T) { m := testModule(t, "provider-meta-set") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn schema := p.GetSchemaReturn schema.ProviderMeta = &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -10300,8 +10294,8 @@ func TestContext2Apply_ProviderMeta_plan_setInvalid(t *testing.T) { func TestContext2Apply_ProviderMeta_refresh_set(t *testing.T) { m := testModule(t, "provider-meta-set") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn schema := p.GetSchemaReturn schema.ProviderMeta = &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -10380,8 +10374,8 @@ func TestContext2Apply_ProviderMeta_refresh_set(t *testing.T) { func TestContext2Apply_ProviderMeta_refresh_setNoSchema(t *testing.T) { m := testModule(t, "provider-meta-set") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn // we need a schema for plan/apply so they don't error schema := p.GetSchemaReturn @@ -10449,8 +10443,8 @@ func TestContext2Apply_ProviderMeta_refresh_setNoSchema(t *testing.T) { func TestContext2Apply_ProviderMeta_refresh_setInvalid(t *testing.T) { m := testModule(t, "provider-meta-set") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn // we need a matching schema for plan/apply so they don't error schema := p.GetSchemaReturn @@ -10529,8 +10523,8 @@ func TestContext2Apply_ProviderMeta_refresh_setInvalid(t *testing.T) { func TestContext2Apply_ProviderMeta_refreshdata_set(t *testing.T) { m := testModule(t, "provider-meta-data-set") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn schema := p.GetSchemaReturn schema.ProviderMeta = &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -10625,8 +10619,8 @@ func TestContext2Apply_ProviderMeta_refreshdata_set(t *testing.T) { func TestContext2Apply_ProviderMeta_refreshdata_unset(t *testing.T) { m := testModule(t, "provider-meta-data-unset") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn schema := p.GetSchemaReturn schema.ProviderMeta = &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -10694,8 +10688,8 @@ func TestContext2Apply_ProviderMeta_refreshdata_unset(t *testing.T) { func TestContext2Apply_ProviderMeta_refreshdata_setNoSchema(t *testing.T) { m := testModule(t, "provider-meta-data-set") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -10740,8 +10734,8 @@ func TestContext2Apply_ProviderMeta_refreshdata_setNoSchema(t *testing.T) { func TestContext2Apply_ProviderMeta_refreshdata_setInvalid(t *testing.T) { m := testModule(t, "provider-meta-data-set") p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn schema := p.GetSchemaReturn schema.ProviderMeta = &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -10827,8 +10821,8 @@ output "out" { }) p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -10888,8 +10882,8 @@ resource "aws_instance" "cbd" { }) p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -10945,7 +10939,7 @@ func TestContext2Apply_moduleDependsOn(t *testing.T) { } return resp } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { state := req.PlannedState.AsValueMap() @@ -11020,8 +11014,8 @@ output "c" { }`}) p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -11089,8 +11083,8 @@ output "myoutput" { `}) p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -11213,7 +11207,7 @@ locals { ) p := testProvider("test") - p.ApplyFn = testApplyFn + p.ApplyResourceChangeFn = testApplyFn p.PlanResourceChangeFn = func(r providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { n := r.ProposedNewState.AsValueMap() @@ -11389,14 +11383,14 @@ output "output" { } return resp } - testP.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + testP.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { if providerConfig != "valid" { resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("provider config is %q", providerConfig)) return } return testApplyFn(req) } - testP.DiffFn = testDiffFn + testP.PlanResourceChangeFn = testDiffFn nullP := new(MockProvider) nullP.ReadResourceFn = func(req providers.ReadResourceRequest) providers.ReadResourceResponse { @@ -11404,8 +11398,8 @@ output "output" { } nullP.GetSchemaReturn = schemaFn("null") - nullP.ApplyFn = testApplyFn - nullP.DiffFn = testDiffFn + nullP.ApplyResourceChangeFn = testApplyFn + nullP.PlanResourceChangeFn = testDiffFn nullP.ReadDataSourceResponse = providers.ReadDataSourceResponse{ State: cty.ObjectVal(map[string]cty.Value{ @@ -11503,8 +11497,8 @@ output "outputs" { `}) p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.ReadDataSourceFn = func(req providers.ReadDataSourceRequest) providers.ReadDataSourceResponse { return providers.ReadDataSourceResponse{ State: cty.ObjectVal(map[string]cty.Value{ @@ -11583,7 +11577,7 @@ resource "test_resource" "a" { `}) p := testProvider("test") - p.ApplyFn = testApplyFn + p.ApplyResourceChangeFn = testApplyFn p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse { proposed := req.ProposedNewState.AsValueMap() proposed["id"] = cty.UnknownVal(cty.String) @@ -11655,8 +11649,8 @@ resource "test_instance" "b" { `}) p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -11718,8 +11712,8 @@ resource "test_resource" "c" { `}) p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -11792,8 +11786,8 @@ resource "test_resource" "foo" { }) p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -11874,8 +11868,8 @@ resource "test_resource" "foo" { }) p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, diff --git a/terraform/context_fixtures_test.go b/terraform/context_fixtures_test.go index 5b2a6eed9..2ed264396 100644 --- a/terraform/context_fixtures_test.go +++ b/terraform/context_fixtures_test.go @@ -48,8 +48,8 @@ func contextFixtureApplyVars(t *testing.T) *contextTestFixture { "map": {Type: cty.Map(cty.String), Optional: true}, }, }) - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn return &contextTestFixture{ Config: c, Providers: map[addrs.Provider]providers.Factory{ @@ -74,8 +74,8 @@ func contextFixtureApplyVarsEnv(t *testing.T) *contextTestFixture { "type": {Type: cty.String, Computed: true}, }, }) - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn return &contextTestFixture{ Config: c, Providers: map[addrs.Provider]providers.Factory{ diff --git a/terraform/context_input_test.go b/terraform/context_input_test.go index 00208d571..1887ac97c 100644 --- a/terraform/context_input_test.go +++ b/terraform/context_input_test.go @@ -17,8 +17,8 @@ import ( func TestContext2Input_provider(t *testing.T) { m := testModule(t, "input-provider") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ Provider: &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -89,8 +89,8 @@ func TestContext2Input_providerMulti(t *testing.T) { m := testModule(t, "input-provider-multi") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ Provider: &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -158,8 +158,8 @@ func TestContext2Input_providerMulti(t *testing.T) { func TestContext2Input_providerOnce(t *testing.T) { m := testModule(t, "input-provider-once") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -178,8 +178,8 @@ func TestContext2Input_providerId(t *testing.T) { m := testModule(t, "input-provider") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ Provider: &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -243,8 +243,8 @@ func TestContext2Input_providerOnly(t *testing.T) { m := testModule(t, "input-provider-vars") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ Provider: &configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -317,8 +317,8 @@ func TestContext2Input_providerVars(t *testing.T) { input := new(MockUIInput) m := testModule(t, "input-provider-with-vars") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -363,8 +363,8 @@ func TestContext2Input_providerVarsModuleInherit(t *testing.T) { input := new(MockUIInput) m := testModule(t, "input-provider-with-vars-and-module") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -383,8 +383,8 @@ func TestContext2Input_submoduleTriggersInvalidCount(t *testing.T) { input := new(MockUIInput) m := testModule(t, "input-submodule-count") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index 75cdf5a8c..96882212e 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -27,7 +27,7 @@ import ( func TestContext2Plan_basic(t *testing.T) { m := testModule(t, "plan-good") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -83,7 +83,7 @@ func TestContext2Plan_basic(t *testing.T) { func TestContext2Plan_createBefore_deposed(t *testing.T) { m := testModule(t, "plan-cbd") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -198,7 +198,7 @@ func TestContext2Plan_createBefore_deposed(t *testing.T) { func TestContext2Plan_createBefore_maintainRoot(t *testing.T) { m := testModule(t, "plan-cbd-maintain-root") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -230,7 +230,7 @@ func TestContext2Plan_createBefore_maintainRoot(t *testing.T) { func TestContext2Plan_emptyDiff(t *testing.T) { m := testModule(t, "plan-empty") p := testProvider("aws") - p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { + p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { resp.PlannedState = req.ProposedNewState return resp } @@ -273,7 +273,7 @@ func TestContext2Plan_emptyDiff(t *testing.T) { func TestContext2Plan_escapedVar(t *testing.T) { m := testModule(t, "plan-escaped-var") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -315,7 +315,7 @@ func TestContext2Plan_escapedVar(t *testing.T) { func TestContext2Plan_minimal(t *testing.T) { m := testModule(t, "plan-empty") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -354,7 +354,7 @@ func TestContext2Plan_minimal(t *testing.T) { func TestContext2Plan_modules(t *testing.T) { m := testModule(t, "plan-modules") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -414,7 +414,7 @@ func TestContext2Plan_moduleExpand(t *testing.T) { // Test a smattering of plan expansion behavior m := testModule(t, "plan-modules-expand") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -475,7 +475,7 @@ func TestContext2Plan_moduleCycle(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -530,7 +530,7 @@ func TestContext2Plan_moduleDeadlock(t *testing.T) { testCheckDeadlock(t, func() { m := testModule(t, "plan-module-deadlock") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -576,7 +576,7 @@ func TestContext2Plan_moduleDeadlock(t *testing.T) { func TestContext2Plan_moduleInput(t *testing.T) { m := testModule(t, "plan-module-input") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -631,7 +631,7 @@ func TestContext2Plan_moduleInput(t *testing.T) { func TestContext2Plan_moduleInputComputed(t *testing.T) { m := testModule(t, "plan-module-input-computed") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -683,7 +683,7 @@ func TestContext2Plan_moduleInputComputed(t *testing.T) { func TestContext2Plan_moduleInputFromVar(t *testing.T) { m := testModule(t, "plan-module-input-var") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -751,7 +751,7 @@ func TestContext2Plan_moduleMultiVar(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -815,7 +815,7 @@ func TestContext2Plan_moduleMultiVar(t *testing.T) { func TestContext2Plan_moduleOrphans(t *testing.T) { m := testModule(t, "plan-modules-remove") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() child := state.EnsureModule(addrs.RootModuleInstance.Child("child", addrs.NoKey)) @@ -889,7 +889,7 @@ func TestContext2Plan_moduleOrphansWithProvisioner(t *testing.T) { m := testModule(t, "plan-modules-remove-provisioners") p := testProvider("aws") pr := testProvisioner() - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1024,7 +1024,7 @@ func TestContext2Plan_moduleProviderInherit(t *testing.T) { return } - p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { + p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { from := req.Config.GetAttr("from").AsString() l.Lock() @@ -1089,7 +1089,7 @@ func TestContext2Plan_moduleProviderInheritDeep(t *testing.T) { return } - p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { + p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { if from != "root" { resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("bad resource")) return @@ -1153,7 +1153,7 @@ func TestContext2Plan_moduleProviderDefaultsVar(t *testing.T) { return } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn return p, nil }, }, @@ -1197,7 +1197,7 @@ func TestContext2Plan_moduleProviderVar(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -1241,7 +1241,7 @@ func TestContext2Plan_moduleProviderVar(t *testing.T) { func TestContext2Plan_moduleVar(t *testing.T) { m := testModule(t, "plan-module-var") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -1296,7 +1296,7 @@ func TestContext2Plan_moduleVar(t *testing.T) { func TestContext2Plan_moduleVarWrongTypeBasic(t *testing.T) { m := testModule(t, "plan-module-wrong-var-type") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -1313,7 +1313,7 @@ func TestContext2Plan_moduleVarWrongTypeBasic(t *testing.T) { func TestContext2Plan_moduleVarWrongTypeNested(t *testing.T) { m := testModule(t, "plan-module-wrong-var-type-nested") p := testProvider("null") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -1330,7 +1330,7 @@ func TestContext2Plan_moduleVarWrongTypeNested(t *testing.T) { func TestContext2Plan_moduleVarWithDefaultValue(t *testing.T) { m := testModule(t, "plan-module-var-with-default-value") p := testProvider("null") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -1347,7 +1347,7 @@ func TestContext2Plan_moduleVarWithDefaultValue(t *testing.T) { func TestContext2Plan_moduleVarComputed(t *testing.T) { m := testModule(t, "plan-module-var-computed") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -1398,7 +1398,7 @@ func TestContext2Plan_moduleVarComputed(t *testing.T) { func TestContext2Plan_preventDestroy_bad(t *testing.T) { m := testModule(t, "plan-prevent-destroy-bad") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -1432,7 +1432,7 @@ func TestContext2Plan_preventDestroy_bad(t *testing.T) { func TestContext2Plan_preventDestroy_good(t *testing.T) { m := testModule(t, "plan-prevent-destroy-good") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1466,7 +1466,7 @@ func TestContext2Plan_preventDestroy_good(t *testing.T) { func TestContext2Plan_preventDestroy_countBad(t *testing.T) { m := testModule(t, "plan-prevent-destroy-count-bad") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1519,7 +1519,7 @@ func TestContext2Plan_preventDestroy_countGood(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1572,7 +1572,7 @@ func TestContext2Plan_preventDestroy_countGoodNoChange(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1606,7 +1606,7 @@ func TestContext2Plan_preventDestroy_countGoodNoChange(t *testing.T) { func TestContext2Plan_preventDestroy_destroyPlan(t *testing.T) { m := testModule(t, "plan-prevent-destroy-good") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1642,7 +1642,7 @@ func TestContext2Plan_preventDestroy_destroyPlan(t *testing.T) { func TestContext2Plan_provisionerCycle(t *testing.T) { m := testModule(t, "plan-provisioner-cycle") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn pr := testProvisioner() ctx := testContext2(t, &ContextOpts{ Config: m, @@ -1663,7 +1663,7 @@ func TestContext2Plan_provisionerCycle(t *testing.T) { func TestContext2Plan_computed(t *testing.T) { m := testModule(t, "plan-computed") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -1806,7 +1806,7 @@ func TestContext2Plan_computedDataResource(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -1866,7 +1866,7 @@ func TestContext2Plan_computedInFunction(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.ReadDataSourceResponse = providers.ReadDataSourceResponse{ State: cty.ObjectVal(map[string]cty.Value{ "computed": cty.ListVal([]cty.Value{ @@ -1914,7 +1914,7 @@ func TestContext2Plan_computedDataCountResource(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -1945,7 +1945,7 @@ func TestContext2Plan_computedDataCountResource(t *testing.T) { func TestContext2Plan_localValueCount(t *testing.T) { m := testModule(t, "plan-local-value-count") p := testProvider("test") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2081,7 +2081,7 @@ func TestContext2Plan_computedList(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -2133,7 +2133,7 @@ func TestContext2Plan_computedList(t *testing.T) { func TestContext2Plan_computedMultiIndex(t *testing.T) { m := testModule(t, "plan-computed-multi-index") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ @@ -2147,7 +2147,7 @@ func TestContext2Plan_computedMultiIndex(t *testing.T) { }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -2203,7 +2203,7 @@ func TestContext2Plan_computedMultiIndex(t *testing.T) { func TestContext2Plan_count(t *testing.T) { m := testModule(t, "plan-count") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2278,7 +2278,7 @@ func TestContext2Plan_count(t *testing.T) { func TestContext2Plan_countComputed(t *testing.T) { m := testModule(t, "plan-count-computed") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2295,7 +2295,7 @@ func TestContext2Plan_countComputed(t *testing.T) { func TestContext2Plan_countComputedModule(t *testing.T) { m := testModule(t, "plan-count-computed-module") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2315,7 +2315,7 @@ func TestContext2Plan_countComputedModule(t *testing.T) { func TestContext2Plan_countModuleStatic(t *testing.T) { m := testModule(t, "plan-count-module-static") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2369,7 +2369,7 @@ func TestContext2Plan_countModuleStatic(t *testing.T) { func TestContext2Plan_countModuleStaticGrandchild(t *testing.T) { m := testModule(t, "plan-count-module-static-grandchild") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2423,7 +2423,7 @@ func TestContext2Plan_countModuleStaticGrandchild(t *testing.T) { func TestContext2Plan_countIndex(t *testing.T) { m := testModule(t, "plan-count-index") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2474,7 +2474,7 @@ func TestContext2Plan_countIndex(t *testing.T) { func TestContext2Plan_countVar(t *testing.T) { m := testModule(t, "plan-count-var") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2599,7 +2599,7 @@ func TestContext2Plan_countZero(t *testing.T) { func TestContext2Plan_countOneIndex(t *testing.T) { m := testModule(t, "plan-count-one-index") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -2650,7 +2650,7 @@ func TestContext2Plan_countOneIndex(t *testing.T) { func TestContext2Plan_countDecreaseToOne(t *testing.T) { m := testModule(t, "plan-count-dec") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -2752,7 +2752,7 @@ aws_instance.foo.2: func TestContext2Plan_countIncreaseFromNotSet(t *testing.T) { m := testModule(t, "plan-count-inc") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -2832,7 +2832,7 @@ func TestContext2Plan_countIncreaseFromNotSet(t *testing.T) { func TestContext2Plan_countIncreaseFromOne(t *testing.T) { m := testModule(t, "plan-count-inc") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -2916,7 +2916,7 @@ func TestContext2Plan_countIncreaseFromOne(t *testing.T) { func TestContext2Plan_countIncreaseFromOneCorrupted(t *testing.T) { m := testModule(t, "plan-count-inc") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -3027,7 +3027,7 @@ func TestContext2Plan_countIncreaseWithSplatReference(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -3120,7 +3120,7 @@ func TestContext2Plan_countIncreaseWithSplatReference(t *testing.T) { func TestContext2Plan_forEach(t *testing.T) { m := testModule(t, "plan-for-each") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -3156,7 +3156,7 @@ func TestContext2Plan_forEachUnknownValue(t *testing.T) { // expect this to produce an error, but not to panic. m := testModule(t, "plan-for-each-unknown-value") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -3187,7 +3187,7 @@ func TestContext2Plan_forEachUnknownValue(t *testing.T) { func TestContext2Plan_destroy(t *testing.T) { m := testModule(t, "plan-destroy") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -3250,7 +3250,7 @@ func TestContext2Plan_destroy(t *testing.T) { func TestContext2Plan_moduleDestroy(t *testing.T) { m := testModule(t, "plan-module-destroy") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -3314,7 +3314,7 @@ func TestContext2Plan_moduleDestroy(t *testing.T) { func TestContext2Plan_moduleDestroyCycle(t *testing.T) { m := testModule(t, "plan-module-destroy-gh-1835") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() aModule := state.EnsureModule(addrs.RootModuleInstance.Child("a_module", addrs.NoKey)) @@ -3378,7 +3378,7 @@ func TestContext2Plan_moduleDestroyCycle(t *testing.T) { func TestContext2Plan_moduleDestroyMultivar(t *testing.T) { m := testModule(t, "plan-module-destroy-multivar") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() child := state.EnsureModule(addrs.RootModuleInstance.Child("child", addrs.NoKey)) @@ -3457,7 +3457,7 @@ func TestContext2Plan_pathVar(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -3522,7 +3522,7 @@ func TestContext2Plan_diffVar(t *testing.T) { State: state, }) - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn plan, diags := ctx.Plan() if diags.HasErrors() { @@ -3576,7 +3576,7 @@ func TestContext2Plan_hook(t *testing.T) { m := testModule(t, "plan-good") h := new(MockHook) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Hooks: []Hook{h}, @@ -3604,7 +3604,7 @@ func TestContext2Plan_closeProvider(t *testing.T) { // "provider.aws". m := testModule(t, "plan-close-module-provider") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -3625,7 +3625,7 @@ func TestContext2Plan_closeProvider(t *testing.T) { func TestContext2Plan_orphan(t *testing.T) { m := testModule(t, "plan-orphan") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -3688,7 +3688,7 @@ func TestContext2Plan_orphan(t *testing.T) { func TestContext2Plan_shadowUuid(t *testing.T) { m := testModule(t, "plan-shadow-uuid") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -3705,7 +3705,7 @@ func TestContext2Plan_shadowUuid(t *testing.T) { func TestContext2Plan_state(t *testing.T) { m := testModule(t, "plan-good") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -3778,7 +3778,7 @@ func TestContext2Plan_state(t *testing.T) { func TestContext2Plan_taint(t *testing.T) { m := testModule(t, "plan-taint") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -3858,8 +3858,8 @@ func TestContext2Plan_taintIgnoreChanges(t *testing.T) { }, }, } - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -3923,7 +3923,7 @@ func TestContext2Plan_taintIgnoreChanges(t *testing.T) { func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) { m := testModule(t, "plan-taint-interpolated-count") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) root.SetResourceInstanceCurrent( @@ -4005,7 +4005,7 @@ func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) { func TestContext2Plan_targeted(t *testing.T) { m := testModule(t, "plan-targeted") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -4056,7 +4056,7 @@ func TestContext2Plan_targeted(t *testing.T) { func TestContext2Plan_targetedCrossModule(t *testing.T) { m := testModule(t, "plan-targeted-cross-module") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -4120,7 +4120,7 @@ func TestContext2Plan_targetedModuleWithProvider(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -4158,7 +4158,7 @@ func TestContext2Plan_targetedModuleWithProvider(t *testing.T) { func TestContext2Plan_targetedOrphan(t *testing.T) { m := testModule(t, "plan-targeted-orphan") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -4226,7 +4226,7 @@ func TestContext2Plan_targetedOrphan(t *testing.T) { func TestContext2Plan_targetedModuleOrphan(t *testing.T) { m := testModule(t, "plan-targeted-module-orphan") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() child := state.EnsureModule(addrs.RootModuleInstance.Child("child", addrs.NoKey)) @@ -4290,7 +4290,7 @@ func TestContext2Plan_targetedModuleOrphan(t *testing.T) { func TestContext2Plan_targetedModuleUntargetedVariable(t *testing.T) { m := testModule(t, "plan-targeted-module-untargeted-variable") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -4347,7 +4347,7 @@ func TestContext2Plan_targetedModuleUntargetedVariable(t *testing.T) { func TestContext2Plan_outputContainsTargetedResource(t *testing.T) { m := testModule(t, "plan-untargeted-resource-output") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -4379,7 +4379,7 @@ func TestContext2Plan_outputContainsTargetedResource(t *testing.T) { func TestContext2Plan_targetedOverTen(t *testing.T) { m := testModule(t, "plan-targeted-over-ten") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -4435,7 +4435,7 @@ func TestContext2Plan_targetedOverTen(t *testing.T) { func TestContext2Plan_provider(t *testing.T) { m := testModule(t, "plan-provider") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn var value interface{} p.ConfigureFn = func(req providers.ConfigureRequest) (resp providers.ConfigureResponse) { @@ -4485,7 +4485,7 @@ func TestContext2Plan_varListErr(t *testing.T) { func TestContext2Plan_ignoreChanges(t *testing.T) { m := testModule(t, "plan-ignore-changes") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -4544,7 +4544,7 @@ func TestContext2Plan_ignoreChanges(t *testing.T) { func TestContext2Plan_ignoreChangesWildcard(t *testing.T) { m := testModule(t, "plan-ignore-changes-wildcard") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -4605,7 +4605,7 @@ func TestContext2Plan_ignoreChangesInMap(t *testing.T) { } } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn s := states.BuildState(func(ss *states.SyncState) { ss.SetResourceInstanceCurrent( @@ -4680,8 +4680,8 @@ func TestContext2Plan_moduleMapLiteral(t *testing.T) { }, }, } - p.ApplyFn = testApplyFn - p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { s := req.ProposedNewState.AsValueMap() m := s["tags"].AsValueMap() @@ -4725,8 +4725,8 @@ func TestContext2Plan_computedValueInMap(t *testing.T) { }, }, } - p.DiffFn = testDiffFn - p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { + p.PlanResourceChangeFn = testDiffFn + p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) { resp = testDiffFn(req) if req.TypeName != "aws_computed_source" { @@ -4785,7 +4785,7 @@ func TestContext2Plan_computedValueInMap(t *testing.T) { func TestContext2Plan_moduleVariableFromSplat(t *testing.T) { m := testModule(t, "plan-module-variable-from-splat") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "aws_instance": { @@ -4945,8 +4945,8 @@ func TestContext2Plan_createBeforeDestroy_depends_datasource(t *testing.T) { func TestContext2Plan_listOrder(t *testing.T) { m := testModule(t, "plan-list-order") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "aws_instance": { @@ -4992,7 +4992,7 @@ func TestContext2Plan_listOrder(t *testing.T) { func TestContext2Plan_ignoreChangesWithFlatmaps(t *testing.T) { m := testModule(t, "plan-ignore-changes-with-flatmaps") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "aws_instance": { @@ -5081,7 +5081,7 @@ func TestContext2Plan_ignoreChangesWithFlatmaps(t *testing.T) { func TestContext2Plan_resourceNestedCount(t *testing.T) { m := testModule(t, "nested-resource-count-plan") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.ReadResourceFn = func(req providers.ReadResourceRequest) providers.ReadResourceResponse { return providers.ReadResourceResponse{ NewState: req.PriorState, @@ -5176,7 +5176,7 @@ func TestContext2Plan_resourceNestedCount(t *testing.T) { func TestContext2Plan_computedAttrRefTypeMismatch(t *testing.T) { m := testModule(t, "plan-computed-attr-ref-type-mismatch") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.ValidateResourceTypeConfigFn = func(req providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse { var diags tfdiags.Diagnostics if req.TypeName == "aws_instance" { @@ -5189,8 +5189,8 @@ func TestContext2Plan_computedAttrRefTypeMismatch(t *testing.T) { Diagnostics: diags, } } - p.DiffFn = testDiffFn - p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + p.PlanResourceChangeFn = testDiffFn + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { if req.TypeName != "aws_ami_list" { t.Fatalf("Reached apply for unexpected resource type! %s", req.TypeName) } @@ -5618,7 +5618,7 @@ func TestContext2Plan_requiredModuleOutput(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -5683,7 +5683,7 @@ func TestContext2Plan_requiredModuleObject(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -5768,7 +5768,7 @@ resource "aws_instance" "foo" { ) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -5830,7 +5830,7 @@ output"out" { }) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -5860,7 +5860,7 @@ resource "aws_instance" "foo" { }) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn targets := []addrs.Targetable{} target, diags := addrs.ParseTargetStr("module.mod[1].aws_instance.foo[0]") @@ -5924,7 +5924,7 @@ resource "aws_instance" "foo" { }) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn target, diags := addrs.ParseTargetStr("module.mod[1].aws_instance.foo") if diags.HasErrors() { @@ -5994,7 +5994,7 @@ resource "aws_instance" "foo" { }) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -6075,8 +6075,8 @@ data "test_data_source" "foo" {} // for_each can reference a resource with 0 instances func TestContext2Plan_scaleInForEach(t *testing.T) { p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn m := testModuleInline(t, map[string]string{ "main.tf": ` @@ -6129,7 +6129,7 @@ resource "test_instance" "b" { func TestContext2Plan_targetedModuleInstance(t *testing.T) { m := testModule(t, "plan-targeted") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -6212,8 +6212,8 @@ data "test_data_source" "d" { func TestContext2Plan_dataReferencesResource(t *testing.T) { p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.ReadDataSourceFn = func(req providers.ReadDataSourceRequest) (resp providers.ReadDataSourceResponse) { resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("data source should not be read")) @@ -6261,8 +6261,8 @@ data "test_data_source" "e" { func TestContext2Plan_skipRefresh(t *testing.T) { p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn m := testModuleInline(t, map[string]string{ "main.tf": ` @@ -6307,8 +6307,8 @@ resource "test_instance" "a" { func TestContext2Plan_dataInModuleDependsOn(t *testing.T) { p := testProvider("test") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn readDataSourceB := false p.ReadDataSourceFn = func(req providers.ReadDataSourceRequest) (resp providers.ReadDataSourceResponse) { diff --git a/terraform/context_refresh_test.go b/terraform/context_refresh_test.go index f91627437..77535d735 100644 --- a/terraform/context_refresh_test.go +++ b/terraform/context_refresh_test.go @@ -52,7 +52,7 @@ func TestContext2Refresh(t *testing.T) { p.ReadResourceResponse = providers.ReadResourceResponse{ NewState: readState, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn s, diags := ctx.Refresh() if diags.HasErrors() { @@ -282,7 +282,7 @@ func TestContext2Refresh_targeted(t *testing.T) { NewState: req.PriorState, } } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn _, diags := ctx.Refresh() if diags.HasErrors() { @@ -361,7 +361,7 @@ func TestContext2Refresh_targetedCount(t *testing.T) { NewState: req.PriorState, } } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn _, diags := ctx.Refresh() if diags.HasErrors() { @@ -448,7 +448,7 @@ func TestContext2Refresh_targetedCountIndex(t *testing.T) { NewState: req.PriorState, } } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn _, diags := ctx.Refresh() if diags.HasErrors() { @@ -480,7 +480,7 @@ func TestContext2Refresh_moduleComputedVar(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn m := testModule(t, "refresh-module-computed-var") ctx := testContext2(t, &ContextOpts{ @@ -517,7 +517,7 @@ func TestContext2Refresh_delete(t *testing.T) { p.ReadResourceResponse = providers.ReadResourceResponse{ NewState: cty.NullVal(p.GetSchemaReturn.ResourceTypes["aws_instance"].ImpliedType()), } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn s, diags := ctx.Refresh() if diags.HasErrors() { @@ -547,7 +547,7 @@ func TestContext2Refresh_ignoreUncreated(t *testing.T) { "id": cty.StringVal("foo"), }), } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn _, diags := ctx.Refresh() if diags.HasErrors() { @@ -561,7 +561,7 @@ func TestContext2Refresh_ignoreUncreated(t *testing.T) { func TestContext2Refresh_hook(t *testing.T) { h := new(MockHook) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn m := testModule(t, "refresh-basic") state := states.NewState() @@ -623,7 +623,7 @@ func TestContext2Refresh_modules(t *testing.T) { NewState: new, } } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn s, diags := ctx.Refresh() if diags.HasErrors() { @@ -640,7 +640,7 @@ func TestContext2Refresh_modules(t *testing.T) { func TestContext2Refresh_moduleInputComputedOutput(t *testing.T) { m := testModule(t, "refresh-module-input-computed-output") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ Provider: &configschema.Block{}, ResourceTypes: map[string]*configschema.Block{ @@ -675,7 +675,7 @@ func TestContext2Refresh_moduleInputComputedOutput(t *testing.T) { func TestContext2Refresh_moduleVarModule(t *testing.T) { m := testModule(t, "refresh-module-var-module") p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -705,7 +705,7 @@ func TestContext2Refresh_noState(t *testing.T) { "id": cty.StringVal("foo"), }), } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn if _, diags := ctx.Refresh(); diags.HasErrors() { t.Fatalf("refresh errs: %s", diags.Err()) @@ -732,7 +732,7 @@ func TestContext2Refresh_output(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn m := testModule(t, "refresh-output") @@ -768,7 +768,7 @@ func TestContext2Refresh_outputPartial(t *testing.T) { // Refresh creates a partial plan for any instances that don't have // remote objects yet, to get stub values for interpolation. Therefore // we need to make DiffFn available to let that complete. - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ Provider: &configschema.Block{}, @@ -840,7 +840,7 @@ func TestContext2Refresh_stateBasic(t *testing.T) { } p.ReadResourceFn = nil - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.ReadResourceResponse = providers.ReadResourceResponse{ NewState: readStateVal, } @@ -949,7 +949,7 @@ func TestContext2Refresh_dataState(t *testing.T) { State: readStateVal, } } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn s, diags := ctx.Refresh() if diags.HasErrors() { @@ -1015,7 +1015,7 @@ func TestContext2Refresh_dataStateRefData(t *testing.T) { State: cty.ObjectVal(m), } } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn s, diags := ctx.Refresh() if diags.HasErrors() { @@ -1053,7 +1053,7 @@ func TestContext2Refresh_tainted(t *testing.T) { NewState: cty.ObjectVal(m), } } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn s, diags := ctx.Refresh() if diags.HasErrors() { @@ -1077,8 +1077,8 @@ func TestContext2Refresh_tainted(t *testing.T) { func TestContext2Refresh_unknownProvider(t *testing.T) { m := testModule(t, "refresh-unknown-provider") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1141,7 +1141,7 @@ func TestContext2Refresh_vars(t *testing.T) { } p.ReadResourceFn = nil - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.ReadResourceResponse = providers.ReadResourceResponse{ NewState: readStateVal, } @@ -1195,7 +1195,7 @@ func TestContext2Refresh_orphanModule(t *testing.T) { NewState: req.PriorState, } } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1265,7 +1265,7 @@ func TestContext2Validate(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn m := testModule(t, "validate-good") c := testContext2(t, &ContextOpts{ @@ -1284,8 +1284,8 @@ func TestContext2Validate(t *testing.T) { func TestContext2Refresh_updateProviderInState(t *testing.T) { m := testModule(t, "update-resource-provider") p := testProvider("aws") - p.DiffFn = testDiffFn - p.ApplyFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn state := states.NewState() root := state.EnsureModule(addrs.RootModuleInstance) @@ -1338,7 +1338,7 @@ func TestContext2Refresh_schemaUpgradeFlatmap(t *testing.T) { "name": cty.StringVal("foo"), }), } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn s := states.BuildState(func(s *states.SyncState) { s.SetResourceInstanceCurrent( @@ -1425,7 +1425,7 @@ func TestContext2Refresh_schemaUpgradeJSON(t *testing.T) { "name": cty.StringVal("foo"), }), } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn s := states.BuildState(func(s *states.SyncState) { s.SetResourceInstanceCurrent( @@ -1503,7 +1503,7 @@ data "aws_data_source" "foo" { resp.State = req.Config return } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -1544,7 +1544,7 @@ func TestContext2Refresh_dataResourceDependsOn(t *testing.T) { }, }, } - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn p.ReadDataSourceResponse = providers.ReadDataSourceResponse{ State: cty.ObjectVal(map[string]cty.Value{ "compute": cty.StringVal("value"), @@ -1653,8 +1653,8 @@ resource "aws_instance" "foo" { }) p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -1722,8 +1722,8 @@ resource "aws_instance" "bar" { }) p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, diff --git a/terraform/context_validate_test.go b/terraform/context_validate_test.go index 28172182b..c1848a12f 100644 --- a/terraform/context_validate_test.go +++ b/terraform/context_validate_test.go @@ -928,8 +928,8 @@ func TestContext2Validate_targetedDestroy(t *testing.T) { m := testModule(t, "validate-targeted") p := testProvider("aws") pr := simpleMockProvisioner() - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "aws_instance": { @@ -1017,8 +1017,8 @@ func TestContext2Validate_interpolateVar(t *testing.T) { m := testModule(t, "input-interpolate-var") p := testProvider("null") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "template_file": { @@ -1050,8 +1050,8 @@ func TestContext2Validate_interpolateComputedModuleVarDef(t *testing.T) { m := testModule(t, "validate-computed-module-var-ref") p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "aws_instance": { @@ -1082,8 +1082,8 @@ func TestContext2Validate_interpolateMap(t *testing.T) { m := testModule(t, "issue-9549") p := testProvider("template") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn + p.ApplyResourceChangeFn = testApplyFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, @@ -1482,7 +1482,7 @@ resource "aws_instance" "foo" { }) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -1511,7 +1511,7 @@ resource "aws_instance" "foo" { }) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -1543,7 +1543,7 @@ resource "aws_instance" "foo" { }) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -1626,7 +1626,7 @@ output "out" { }) p := testProvider("aws") - p.DiffFn = testDiffFn + p.PlanResourceChangeFn = testDiffFn ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ diff --git a/terraform/provider_mock.go b/terraform/provider_mock.go index b7c647c49..45397fe22 100644 --- a/terraform/provider_mock.go +++ b/terraform/provider_mock.go @@ -86,9 +86,6 @@ type MockProvider struct { CloseCalled bool CloseError error - - DiffFn func(providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse - ApplyFn func(providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse } func (p *MockProvider) GetSchema() providers.GetSchemaResponse { @@ -263,9 +260,6 @@ func (p *MockProvider) PlanResourceChange(r providers.PlanResourceChangeRequest) p.PlanResourceChangeCalled = true p.PlanResourceChangeRequest = r - if p.DiffFn != nil { - return p.DiffFn(r) - } if p.PlanResourceChangeFn != nil { return p.PlanResourceChangeFn(r) } @@ -279,9 +273,6 @@ func (p *MockProvider) ApplyResourceChange(r providers.ApplyResourceChangeReques p.ApplyResourceChangeRequest = r p.Unlock() - if p.ApplyFn != nil { - return p.ApplyFn(r) - } if p.ApplyResourceChangeFn != nil { return p.ApplyResourceChangeFn(r) } diff --git a/terraform/provisioner_mock.go b/terraform/provisioner_mock.go index d476e4ea7..2a3323541 100644 --- a/terraform/provisioner_mock.go +++ b/terraform/provisioner_mock.go @@ -1,12 +1,8 @@ package terraform import ( - "fmt" "sync" - "github.com/zclconf/go-cty/cty" - "github.com/zclconf/go-cty/cty/convert" - "github.com/hashicorp/terraform/provisioners" ) @@ -39,12 +35,6 @@ type MockProvisioner struct { CloseCalled bool CloseResponse error CloseFn func() error - - // Legacy callbacks: if these are set, we will shim incoming calls for - // new-style methods to these old-fashioned terraform.ResourceProvider - // mock callbacks, for the benefit of older tests that were written against - // the old mock API. - ApplyFn func(rs *InstanceState, c *ResourceConfig) error } func (p *MockProvisioner) GetSchema() provisioners.GetSchemaResponse { @@ -79,45 +69,6 @@ func (p *MockProvisioner) ProvisionResource(r provisioners.ProvisionResourceRequ p.ProvisionResourceCalled = true p.ProvisionResourceRequest = r - if p.ApplyFn != nil { - if !r.Config.IsKnown() { - panic(fmt.Sprintf("cannot provision with unknown value: %#v", r.Config)) - } - - schema := p.getSchema() - rc := NewResourceConfigShimmed(r.Config, schema.Provisioner) - connVal := r.Connection - connMap := map[string]string{} - - if !connVal.IsNull() && connVal.IsKnown() { - for it := connVal.ElementIterator(); it.Next(); { - ak, av := it.Element() - name := ak.AsString() - - if !av.IsKnown() || av.IsNull() { - continue - } - - av, _ = convert.Convert(av, cty.String) - connMap[name] = av.AsString() - } - } - - // We no longer pass the full instance state to a provisioner, so we'll - // construct a partial one that should be good enough for what existing - // test mocks need. - is := &InstanceState{ - Ephemeral: EphemeralState{ - ConnInfo: connMap, - }, - } - var resp provisioners.ProvisionResourceResponse - err := p.ApplyFn(is, rc) - if err != nil { - resp.Diagnostics = resp.Diagnostics.Append(err) - } - return resp - } if p.ProvisionResourceFn != nil { fn := p.ProvisionResourceFn return fn(r)