From b3fed27dbf45a6d273f0abd508f3fe60c7fd3be7 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Mon, 15 Oct 2018 21:07:01 -0400 Subject: [PATCH] export MustShimLegacyState for resource tests We also need to convert legacy states for helper resource tests. --- terraform/context.go | 36 ++++++ terraform/context_apply_test.go | 138 +++++++++++------------ terraform/context_plan_test.go | 64 +++++------ terraform/context_refresh_test.go | 38 +++---- terraform/context_test.go | 34 ------ terraform/context_validate_test.go | 6 +- terraform/eval_state_test.go | 2 +- terraform/graph_builder_apply_test.go | 2 +- terraform/graph_builder_refresh_test.go | 2 +- terraform/module_dependencies_test.go | 2 +- terraform/node_data_refresh_test.go | 4 +- terraform/node_resource_refresh_test.go | 4 +- terraform/transform_orphan_count_test.go | 12 +- 13 files changed, 173 insertions(+), 171 deletions(-) diff --git a/terraform/context.go b/terraform/context.go index b6e6b73ac..a817f3c8a 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -1,6 +1,7 @@ package terraform import ( + "bytes" "context" "fmt" "log" @@ -18,6 +19,7 @@ import ( "github.com/hashicorp/terraform/providers" "github.com/hashicorp/terraform/provisioners" "github.com/hashicorp/terraform/states" + "github.com/hashicorp/terraform/states/statefile" "github.com/hashicorp/terraform/tfdiags" ) @@ -897,3 +899,37 @@ func parseVariableAsHCL(name string, input string, targetType config.VariableTyp panic(fmt.Errorf("unknown type %s", targetType.Printable())) } } + +// shimLegacyState is a helper that takes the legacy state type and +// converts it to the new state type. +// +// This is implemented as a state file upgrade, so it will not preserve +// parts of the state structure that are not included in a serialized state, +// such as the resolved results of any local values, outputs in non-root +// modules, etc. +func shimLegacyState(legacy *State) (*states.State, error) { + if legacy == nil { + return nil, nil + } + var buf bytes.Buffer + err := WriteState(legacy, &buf) + if err != nil { + return nil, err + } + f, err := statefile.Read(&buf) + if err != nil { + return nil, err + } + return f.State, err +} + +// MustShimLegacyState is a wrapper around ShimLegacyState that panics if +// the conversion does not succeed. This is primarily intended for tests where +// the given legacy state is an object constructed within the test. +func MustShimLegacyState(legacy *State) *states.State { + ret, err := shimLegacyState(legacy) + if err != nil { + panic(err) + } + return ret +} diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 7adb4d553..760373d03 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -290,7 +290,7 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) { p := testProvider("aws") p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -811,7 +811,7 @@ func TestContext2Apply_createBeforeDestroy(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -868,7 +868,7 @@ func TestContext2Apply_createBeforeDestroyUpdate(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -926,7 +926,7 @@ func TestContext2Apply_createBeforeDestroy_dependsNonCBD(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -999,7 +999,7 @@ func TestContext2Apply_createBeforeDestroy_hook(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1072,7 +1072,7 @@ func TestContext2Apply_createBeforeDestroy_deposedCount(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1151,7 +1151,7 @@ func TestContext2Apply_createBeforeDestroy_deposedOnly(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1207,7 +1207,7 @@ func TestContext2Apply_destroyComputed(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1264,7 +1264,7 @@ func testContext2Apply_destroyDependsOn(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1341,7 +1341,7 @@ func testContext2Apply_destroyDependsOnStateOnly(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1421,7 +1421,7 @@ func testContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child"}, @@ -1528,7 +1528,7 @@ func TestContext2Apply_destroyData(t *testing.T) { p := testProvider("null") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1598,7 +1598,7 @@ func TestContext2Apply_destroySkipsCBD(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1646,7 +1646,7 @@ func TestContext2Apply_destroyModuleVarProviderConfig(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child"}, @@ -1735,7 +1735,7 @@ func TestContext2Apply_destroyCrossProviders(t *testing.T) { } func getContextForApply_destroyCrossProviders(t *testing.T, m *configs.Config, providerFactories map[string]providers.Factory) *Context { - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2150,7 +2150,7 @@ func TestContext2Apply_countDecrease(t *testing.T) { p := testProvider("aws") p.DiffFn = testDiffFn p.ApplyFn = testApplyFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2219,7 +2219,7 @@ func TestContext2Apply_countDecreaseToOneX(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2286,7 +2286,7 @@ func TestContext2Apply_countDecreaseToOneCorrupted(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2351,7 +2351,7 @@ func TestContext2Apply_countTainted(t *testing.T) { p := testProvider("aws") p.DiffFn = testDiffFn p.ApplyFn = testApplyFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2609,7 +2609,7 @@ func TestContext2Apply_moduleDestroyOrder(t *testing.T) { }, } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2818,7 +2818,7 @@ func TestContext2Apply_moduleOrphanInheritAlias(t *testing.T) { } // Create a state with an orphan module - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child"}, @@ -2876,7 +2876,7 @@ func TestContext2Apply_moduleOrphanProvider(t *testing.T) { } // Create a state with an orphan module - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child"}, @@ -2927,7 +2927,7 @@ func TestContext2Apply_moduleOrphanGrandchildProvider(t *testing.T) { } // Create a state with an orphan module that is nested (grandchild) - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "parent", "child"}, @@ -3129,7 +3129,7 @@ func TestContext2Apply_moduleProviderCloseNested(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child", "subchild"}, @@ -3167,7 +3167,7 @@ func TestContext2Apply_moduleVarRefExisting(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -4263,7 +4263,7 @@ func TestContext2Apply_outputOrphan(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -4315,7 +4315,7 @@ func TestContext2Apply_outputOrphanModule(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child"}, @@ -4705,7 +4705,7 @@ func TestContext2Apply_provisionerFail_createBeforeDestroy(t *testing.T) { return fmt.Errorf("EXPLOSION") } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -4755,7 +4755,7 @@ func TestContext2Apply_provisionerFail_createBeforeDestroy(t *testing.T) { func TestContext2Apply_error_createBeforeDestroy(t *testing.T) { m := testModule(t, "apply-error-create-before") p := testProvider("aws") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -4806,7 +4806,7 @@ func TestContext2Apply_error_createBeforeDestroy(t *testing.T) { func TestContext2Apply_errorDestroy_createBeforeDestroy(t *testing.T) { m := testModule(t, "apply-error-create-before") p := testProvider("aws") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -4878,7 +4878,7 @@ func TestContext2Apply_multiDepose_createBeforeDestroy(t *testing.T) { }, } ps := map[string]providers.Factory{"aws": testProviderFuncFixed(p)} - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -5146,7 +5146,7 @@ func TestContext2Apply_provisionerDestroy(t *testing.T) { return nil } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -5204,7 +5204,7 @@ func TestContext2Apply_provisionerDestroyFail(t *testing.T) { return fmt.Errorf("provisioner error") } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -5278,7 +5278,7 @@ func TestContext2Apply_provisionerDestroyFailContinue(t *testing.T) { return fmt.Errorf("provisioner error") } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -5354,7 +5354,7 @@ func TestContext2Apply_provisionerDestroyFailContinueFail(t *testing.T) { return fmt.Errorf("provisioner error") } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -5434,7 +5434,7 @@ func TestContext2Apply_provisionerDestroyTainted(t *testing.T) { return nil } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -5506,7 +5506,7 @@ func TestContext2Apply_provisionerDestroyModule(t *testing.T) { return nil } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child"}, @@ -5568,7 +5568,7 @@ func TestContext2Apply_provisionerDestroyRef(t *testing.T) { return nil } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -5638,7 +5638,7 @@ func TestContext2Apply_provisionerDestroyRefInvalid(t *testing.T) { return nil } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -6077,7 +6077,7 @@ func TestContext2Apply_Provisioner_Diff(t *testing.T) { func TestContext2Apply_outputDiffVars(t *testing.T) { m := testModule(t, "apply-good") p := testProvider("aws") - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -6333,7 +6333,7 @@ func TestContext2Apply_destroyNestedModule(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child", "subchild"}, @@ -6383,7 +6383,7 @@ func TestContext2Apply_destroyDeeplyNestedModule(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child", "subchild", "subsubchild"}, @@ -6825,7 +6825,7 @@ func TestContext2Apply_destroyOutputs(t *testing.T) { func TestContext2Apply_destroyOrphan(t *testing.T) { m := testModule(t, "apply-error") p := testProvider("aws") - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -6897,7 +6897,7 @@ func TestContext2Apply_destroyTaintedProvisioner(t *testing.T) { return nil } - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -7012,7 +7012,7 @@ func TestContext2Apply_errorPartial(t *testing.T) { m := testModule(t, "apply-error") p := testProvider("aws") - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -7123,7 +7123,7 @@ func TestContext2Apply_hookOrphan(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -7417,7 +7417,7 @@ func TestContext2Apply_taintX(t *testing.T) { return testApplyFn(info, s, d) } p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -7474,7 +7474,7 @@ func TestContext2Apply_taintDep(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -7538,7 +7538,7 @@ func TestContext2Apply_taintDepRequiresNew(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -7727,7 +7727,7 @@ func TestContext2Apply_targetedDestroy(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -7806,7 +7806,7 @@ func TestContext2Apply_destroyProvisionerWithLocals(t *testing.T) { Provisioners: map[string]ProvisionerFactory{ "shell": testProvisionerFuncFixed(pr), }, - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -7903,7 +7903,7 @@ func TestContext2Apply_destroyProvisionerWithMultipleLocals(t *testing.T) { Provisioners: map[string]ProvisionerFactory{ "shell": testProvisionerFuncFixed(pr), }, - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -7954,7 +7954,7 @@ func TestContext2Apply_destroyProvisionerWithOutput(t *testing.T) { Provisioners: map[string]ProvisionerFactory{ "shell": testProvisionerFuncFixed(pr), }, - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -8027,7 +8027,7 @@ func TestContext2Apply_targetedDestroyCountDeps(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -8071,7 +8071,7 @@ func TestContext2Apply_targetedDestroyModule(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -8133,7 +8133,7 @@ func TestContext2Apply_targetedDestroyCountIndex(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -8303,7 +8303,7 @@ func TestContext2Apply_targetedModuleUnrelatedOutputs(t *testing.T) { Targets: []addrs.Targetable{ addrs.RootModuleInstance.Child("child2", addrs.NoKey), }, - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ { Path: []string{"root"}, @@ -8558,7 +8558,7 @@ func TestContext2Apply_createBefore_depends(t *testing.T) { p := testProvider("aws") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -8673,7 +8673,7 @@ func TestContext2Apply_singleDestroy(t *testing.T) { return testApplyFn(info, s, d) } p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -8899,7 +8899,7 @@ func TestContext2Apply_targetedWithTaintedInState(t *testing.T) { addrs.ManagedResourceMode, "aws_instance", "iambeingadded", ), }, - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -9035,7 +9035,7 @@ func TestContext2Apply_ignoreChangesWithDep(t *testing.T) { return nil, nil } } - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -9450,7 +9450,7 @@ func TestContext2Apply_destroyWithLocals(t *testing.T) { d, err := testDiffFn(info, s, c) return d, err } - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -9571,7 +9571,7 @@ func TestContext2Apply_destroyWithProviders(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -9646,7 +9646,7 @@ func TestContext2Apply_providersFromState(t *testing.T) { }{ { name: "add implicit provider", - state: mustShimLegacyState(&State{ + state: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -9669,7 +9669,7 @@ func TestContext2Apply_providersFromState(t *testing.T) { // an aliased provider must be in the config to remove a resource { name: "add aliased provider", - state: mustShimLegacyState(&State{ + state: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -9692,7 +9692,7 @@ func TestContext2Apply_providersFromState(t *testing.T) { // allowed even without an alias { name: "add unaliased module provider", - state: mustShimLegacyState(&State{ + state: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child"}, @@ -9759,7 +9759,7 @@ func TestContext2Apply_plannedInterpolatedCount(t *testing.T) { }, ) - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -9821,7 +9821,7 @@ func TestContext2Apply_plannedDestroyInterpolatedCount(t *testing.T) { }, ) - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -9898,7 +9898,7 @@ func TestContext2Apply_scaleInMultivarRef(t *testing.T) { }, ) - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index 786b04f34..581a0f429 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -86,7 +86,7 @@ func TestContext2Plan_createBefore_deposed(t *testing.T) { p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -800,7 +800,7 @@ func TestContext2Plan_moduleOrphans(t *testing.T) { m := testModule(t, "plan-modules-remove") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child"}, @@ -880,7 +880,7 @@ func TestContext2Plan_moduleOrphansWithProvisioner(t *testing.T) { p := testProvider("aws") pr := testProvisioner() p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -1422,7 +1422,7 @@ func TestContext2Plan_preventDestroy_bad(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1461,7 +1461,7 @@ func TestContext2Plan_preventDestroy_good(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1499,7 +1499,7 @@ func TestContext2Plan_preventDestroy_countBad(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1554,7 +1554,7 @@ func TestContext2Plan_preventDestroy_countGood(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1608,7 +1608,7 @@ func TestContext2Plan_preventDestroy_countGoodNoChange(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1650,7 +1650,7 @@ func TestContext2Plan_preventDestroy_destroyPlan(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2007,7 +2007,7 @@ func TestContext2Plan_dataResourceBecomesComputed(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2653,7 +2653,7 @@ func TestContext2Plan_countDecreaseToOne(t *testing.T) { m := testModule(t, "plan-count-dec") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2760,7 +2760,7 @@ func TestContext2Plan_countIncreaseFromNotSet(t *testing.T) { m := testModule(t, "plan-count-inc") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2849,7 +2849,7 @@ func TestContext2Plan_countIncreaseFromOne(t *testing.T) { m := testModule(t, "plan-count-inc") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -2943,7 +2943,7 @@ func TestContext2Plan_countIncreaseFromOneCorrupted(t *testing.T) { m := testModule(t, "plan-count-inc") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -3065,7 +3065,7 @@ func TestContext2Plan_countIncreaseWithSplatReference(t *testing.T) { } p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -3167,7 +3167,7 @@ func TestContext2Plan_destroy(t *testing.T) { m := testModule(t, "plan-destroy") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -3233,7 +3233,7 @@ func TestContext2Plan_moduleDestroy(t *testing.T) { m := testModule(t, "plan-module-destroy") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -3304,7 +3304,7 @@ func TestContext2Plan_moduleDestroyCycle(t *testing.T) { m := testModule(t, "plan-module-destroy-gh-1835") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "a_module"}, @@ -3375,7 +3375,7 @@ func TestContext2Plan_moduleDestroyMultivar(t *testing.T) { m := testModule(t, "plan-module-destroy-multivar") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -3508,7 +3508,7 @@ func TestContext2Plan_pathVar(t *testing.T) { func TestContext2Plan_diffVar(t *testing.T) { m := testModule(t, "plan-diffvar") p := testProvider("aws") - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -3658,7 +3658,7 @@ func TestContext2Plan_orphan(t *testing.T) { m := testModule(t, "plan-orphan") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -3746,7 +3746,7 @@ func TestContext2Plan_state(t *testing.T) { m := testModule(t, "plan-good") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -3826,7 +3826,7 @@ func TestContext2Plan_taint(t *testing.T) { m := testModule(t, "plan-taint") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -3914,7 +3914,7 @@ func TestContext2Plan_taintIgnoreChanges(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -3988,7 +3988,7 @@ func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) { m := testModule(t, "plan-taint-interpolated-count") p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -4234,7 +4234,7 @@ func TestContext2Plan_targetedOrphan(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -4304,7 +4304,7 @@ func TestContext2Plan_targetedModuleOrphan(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child"}, @@ -4468,7 +4468,7 @@ func TestContext2Plan_targetedOverTen(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -4562,7 +4562,7 @@ func TestContext2Plan_ignoreChanges(t *testing.T) { p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -4631,7 +4631,7 @@ func TestContext2Plan_ignoreChangesWildcard(t *testing.T) { p := testProvider("aws") p.DiffFn = testDiffFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -5036,7 +5036,7 @@ func TestContext2Plan_ignoreChangesWithFlatmaps(t *testing.T) { }, }, } - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -5124,7 +5124,7 @@ func TestContext2Plan_resourceNestedCount(t *testing.T) { NewState: req.PriorState, } } - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, diff --git a/terraform/context_refresh_test.go b/terraform/context_refresh_test.go index 14c42440a..72d019eab 100644 --- a/terraform/context_refresh_test.go +++ b/terraform/context_refresh_test.go @@ -21,7 +21,7 @@ func TestContext2Refresh(t *testing.T) { p := testProvider("aws") m := testModule(t, "refresh-basic") - startingState := mustShimLegacyState(&State{ + startingState := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -189,7 +189,7 @@ func TestContext2Refresh_targeted(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -272,7 +272,7 @@ func TestContext2Refresh_targetedCount(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -365,7 +365,7 @@ func TestContext2Refresh_targetedCountIndex(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -453,7 +453,7 @@ func TestContext2Refresh_delete(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -527,7 +527,7 @@ func TestContext2Refresh_hook(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -558,7 +558,7 @@ func TestContext2Refresh_hook(t *testing.T) { func TestContext2Refresh_modules(t *testing.T) { p := testProvider("aws") m := testModule(t, "refresh-modules") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -733,7 +733,7 @@ func TestContext2Refresh_output(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -809,7 +809,7 @@ func TestContext2Refresh_outputPartial(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -842,7 +842,7 @@ func TestContext2Refresh_outputPartial(t *testing.T) { func TestContext2Refresh_stateBasic(t *testing.T) { p := testProvider("aws") m := testModule(t, "refresh-basic") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -904,7 +904,7 @@ func TestContext2Refresh_stateBasic(t *testing.T) { func TestContext2Refresh_dataOrphan(t *testing.T) { p := testProvider("null") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -940,7 +940,7 @@ func TestContext2Refresh_dataOrphan(t *testing.T) { func TestContext2Refresh_dataState(t *testing.T) { m := testModule(t, "refresh-data-resource-basic") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1065,7 +1065,7 @@ func TestContext2Refresh_dataStateRefData(t *testing.T) { } m := testModule(t, "refresh-data-ref-data") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1111,7 +1111,7 @@ func TestContext2Refresh_dataStateRefData(t *testing.T) { func TestContext2Refresh_tainted(t *testing.T) { p := testProvider("aws") m := testModule(t, "refresh-basic") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1176,7 +1176,7 @@ func TestContext2Refresh_unknownProvider(t *testing.T) { ProviderResolver: providers.ResolverFixed( map[string]providers.Factory{}, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1231,7 +1231,7 @@ func TestContext2Refresh_vars(t *testing.T) { "aws": testProviderFuncFixed(p), }, ), - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ @@ -1311,7 +1311,7 @@ func TestContext2Refresh_orphanModule(t *testing.T) { } } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1461,7 +1461,7 @@ func TestContext2Refresh_noDiffHookOnScaleOut(t *testing.T) { // we need to make DiffFn available to let that complete. p.DiffFn = testDiffFn - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -1522,7 +1522,7 @@ func TestContext2Refresh_updateProviderInState(t *testing.T) { p.DiffFn = testDiffFn p.ApplyFn = testApplyFn - s := mustShimLegacyState(&State{ + s := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, diff --git a/terraform/context_test.go b/terraform/context_test.go index 5349bff6e..1b368112f 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -780,40 +780,6 @@ func contextOptsForPlanViaFile(configSnap *configload.Snapshot, state *states.St }, nil } -// shimLegacyState is a helper that takes the legacy state type and -// converts it to the new state type. -// -// This is implemented as a state file upgrade, so it will not preserve -// parts of the state structure that are not included in a serialized state, -// such as the resolved results of any local values, outputs in non-root -// modules, etc. -func shimLegacyState(legacy *State) (*states.State, error) { - if legacy == nil { - return nil, nil - } - var buf bytes.Buffer - err := WriteState(legacy, &buf) - if err != nil { - return nil, err - } - f, err := statefile.Read(&buf) - if err != nil { - return nil, err - } - return f.State, err -} - -// mustShimLegacyState is a wrapper around ShimLegacyState that panics if -// the conversion does not succeed. This is primarily intended for tests where -// the given legacy state is an object constructed within the test. -func mustShimLegacyState(legacy *State) *states.State { - ret, err := shimLegacyState(legacy) - if err != nil { - panic(err) - } - return ret -} - // legacyPlanComparisonString produces a string representation of the changes // from a plan and a given state togther, as was formerly produced by the // String method of terraform.Plan. diff --git a/terraform/context_validate_test.go b/terraform/context_validate_test.go index ddf3a679d..bee5b9eb0 100644 --- a/terraform/context_validate_test.go +++ b/terraform/context_validate_test.go @@ -537,7 +537,7 @@ func TestContext2Validate_orphans(t *testing.T) { } m := testModule(t, "validate-good") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -868,7 +868,7 @@ func TestContext2Validate_tainted(t *testing.T) { } m := testModule(t, "validate-good") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -937,7 +937,7 @@ func TestContext2Validate_targetedDestroy(t *testing.T) { Provisioners: map[string]ProvisionerFactory{ "shell": testProvisionerFuncFixed(pr), }, - State: mustShimLegacyState(&State{ + State: MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, diff --git a/terraform/eval_state_test.go b/terraform/eval_state_test.go index c117ee475..56097528f 100644 --- a/terraform/eval_state_test.go +++ b/terraform/eval_state_test.go @@ -152,7 +152,7 @@ func TestEvalReadState(t *testing.T) { for k, c := range cases { t.Run(k, func(t *testing.T) { ctx := new(MockEvalContext) - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, diff --git a/terraform/graph_builder_apply_test.go b/terraform/graph_builder_apply_test.go index 85b6fdc1a..6050be7df 100644 --- a/terraform/graph_builder_apply_test.go +++ b/terraform/graph_builder_apply_test.go @@ -241,7 +241,7 @@ func TestApplyGraphBuilder_destroyStateOnly(t *testing.T) { }, } - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root", "child"}, diff --git a/terraform/graph_builder_refresh_test.go b/terraform/graph_builder_refresh_test.go index 48da3cfd3..50f5b468a 100644 --- a/terraform/graph_builder_refresh_test.go +++ b/terraform/graph_builder_refresh_test.go @@ -11,7 +11,7 @@ func TestRefreshGraphBuilder_configOrphans(t *testing.T) { m := testModule(t, "refresh-config-orphan") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, diff --git a/terraform/module_dependencies_test.go b/terraform/module_dependencies_test.go index e79777e24..4245a767c 100644 --- a/terraform/module_dependencies_test.go +++ b/terraform/module_dependencies_test.go @@ -250,7 +250,7 @@ func TestModuleTreeDependencies(t *testing.T) { root = testModule(t, test.ConfigDir) } - got := ConfigTreeDependencies(root, mustShimLegacyState(test.State)) + got := ConfigTreeDependencies(root, MustShimLegacyState(test.State)) for _, problem := range deep.Equal(got, test.Want) { t.Error(problem) } diff --git a/terraform/node_data_refresh_test.go b/terraform/node_data_refresh_test.go index fc6573335..f3e006f1b 100644 --- a/terraform/node_data_refresh_test.go +++ b/terraform/node_data_refresh_test.go @@ -11,7 +11,7 @@ import ( func TestNodeRefreshableDataResourceDynamicExpand_scaleOut(t *testing.T) { m := testModule(t, "refresh-data-scale-inout") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -78,7 +78,7 @@ root - terraform.graphNodeRoot func TestNodeRefreshableDataResourceDynamicExpand_scaleIn(t *testing.T) { m := testModule(t, "refresh-data-scale-inout") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, diff --git a/terraform/node_resource_refresh_test.go b/terraform/node_resource_refresh_test.go index 006eed848..c2682ded7 100644 --- a/terraform/node_resource_refresh_test.go +++ b/terraform/node_resource_refresh_test.go @@ -13,7 +13,7 @@ import ( func TestNodeRefreshableManagedResourceDynamicExpand_scaleOut(t *testing.T) { m := testModule(t, "refresh-resource-scale-inout") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, @@ -78,7 +78,7 @@ root - terraform.graphNodeRoot func TestNodeRefreshableManagedResourceDynamicExpand_scaleIn(t *testing.T) { m := testModule(t, "refresh-resource-scale-inout") - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: rootModulePath, diff --git a/terraform/transform_orphan_count_test.go b/terraform/transform_orphan_count_test.go index 55e6914da..5cf2b895c 100644 --- a/terraform/transform_orphan_count_test.go +++ b/terraform/transform_orphan_count_test.go @@ -8,7 +8,7 @@ import ( ) func TestOrphanResourceCountTransformer(t *testing.T) { - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -62,7 +62,7 @@ func TestOrphanResourceCountTransformer(t *testing.T) { } func TestOrphanResourceCountTransformer_zero(t *testing.T) { - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -116,7 +116,7 @@ func TestOrphanResourceCountTransformer_zero(t *testing.T) { } func TestOrphanResourceCountTransformer_oneNoIndex(t *testing.T) { - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -170,7 +170,7 @@ func TestOrphanResourceCountTransformer_oneNoIndex(t *testing.T) { } func TestOrphanResourceCountTransformer_oneIndex(t *testing.T) { - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -224,7 +224,7 @@ func TestOrphanResourceCountTransformer_oneIndex(t *testing.T) { } func TestOrphanResourceCountTransformer_zeroAndNone(t *testing.T) { - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"}, @@ -278,7 +278,7 @@ func TestOrphanResourceCountTransformer_zeroAndNone(t *testing.T) { } func TestOrphanResourceCountTransformer_zeroAndNoneCount(t *testing.T) { - state := mustShimLegacyState(&State{ + state := MustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{ Path: []string{"root"},