remove LegacyProvider (#26433)

This commit is contained in:
Kristin Laemmert 2020-10-05 08:33:49 -04:00 committed by GitHub
parent 69b03ebf42
commit 3933cbd491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 371 additions and 353 deletions

View File

@ -168,25 +168,25 @@ func TestAbsProviderConfigString(t *testing.T) {
{ {
AbsProviderConfig{ AbsProviderConfig{
Module: RootModule.Child("child_module"), Module: RootModule.Child("child_module"),
Provider: NewLegacyProvider("foo"), Provider: NewDefaultProvider("foo"),
}, },
`module.child_module.provider["registry.terraform.io/-/foo"]`, `module.child_module.provider["registry.terraform.io/hashicorp/foo"]`,
}, },
{ {
AbsProviderConfig{ AbsProviderConfig{
Module: RootModule, Module: RootModule,
Alias: "bar", Alias: "bar",
Provider: NewLegacyProvider("foo"), Provider: NewDefaultProvider("foo"),
}, },
`provider["registry.terraform.io/-/foo"].bar`, `provider["registry.terraform.io/hashicorp/foo"].bar`,
}, },
{ {
AbsProviderConfig{ AbsProviderConfig{
Module: RootModule.Child("child_module"), Module: RootModule.Child("child_module"),
Alias: "bar", Alias: "bar",
Provider: NewLegacyProvider("foo"), Provider: NewDefaultProvider("foo"),
}, },
`module.child_module.provider["registry.terraform.io/-/foo"].bar`, `module.child_module.provider["registry.terraform.io/hashicorp/foo"].bar`,
}, },
} }

View File

@ -150,7 +150,7 @@ func TestBackendStates(t *testing.T, b Backend) {
SchemaVersion: 0, SchemaVersion: 0,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )

View File

@ -373,7 +373,7 @@ func testStateFile(t *testing.T, s *states.State) string {
// testStateFileDefault writes the state out to the default statefile // testStateFileDefault writes the state out to the default statefile
// in the cwd. Use `testCwd` to change into a temp cwd. // in the cwd. Use `testCwd` to change into a temp cwd.
func testStateFileDefault(t *testing.T, s *terraform.State) string { func testStateFileDefault(t *testing.T, s *states.State) {
t.Helper() t.Helper()
f, err := os.Create(DefaultStateFilename) f, err := os.Create(DefaultStateFilename)
@ -382,11 +382,9 @@ func testStateFileDefault(t *testing.T, s *terraform.State) string {
} }
defer f.Close() defer f.Close()
if err := terraform.WriteState(s, f); err != nil { if err := writeStateForTesting(s, f); err != nil {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
return DefaultStateFilename
} }
// testStateFileWorkspaceDefault writes the state out to the default statefile // testStateFileWorkspaceDefault writes the state out to the default statefile

View File

@ -4312,7 +4312,7 @@ func runTestCases(t *testing.T, testCases map[string]testCase) {
Name: "example", Name: "example",
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance), }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.AbsProviderConfig{ ProviderAddr: addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{

View File

@ -139,7 +139,7 @@ func testSchemas() *terraform.Schemas {
provider := testProvider() provider := testProvider()
return &terraform.Schemas{ return &terraform.Schemas{
Providers: map[addrs.Provider]*terraform.ProviderSchema{ Providers: map[addrs.Provider]*terraform.ProviderSchema{
addrs.NewLegacyProvider("test"): provider.GetSchemaReturn, addrs.NewDefaultProvider("test"): provider.GetSchemaReturn,
}, },
} }
} }
@ -244,7 +244,7 @@ func basicState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles"}`), AttrsJSON: []byte(`{"woozles":"confuzles"}`),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -260,7 +260,7 @@ func basicState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"compute":"sure"}`), AttrsJSON: []byte(`{"compute":"sure"}`),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -296,7 +296,7 @@ func stateWithMoreOutputs(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles"}`), AttrsJSON: []byte(`{"woozles":"confuzles"}`),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -323,7 +323,7 @@ func nestedState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`), AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -346,7 +346,7 @@ func deposedState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`), AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -375,7 +375,7 @@ func onlyDeposedState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`), AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -392,7 +392,7 @@ func onlyDeposedState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`), AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )

View File

@ -126,7 +126,7 @@ func TestGraph_plan(t *testing.T) {
After: plans.DynamicValue(`null`), After: plans.DynamicValue(`null`),
}, },
ProviderAddr: addrs.AbsProviderConfig{ ProviderAddr: addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
}) })

View File

@ -16,6 +16,7 @@ import (
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
version "github.com/hashicorp/go-version"
"github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/configs" "github.com/hashicorp/terraform/configs"
"github.com/hashicorp/terraform/configs/configschema" "github.com/hashicorp/terraform/configs/configschema"
@ -23,8 +24,8 @@ import (
"github.com/hashicorp/terraform/internal/getproviders" "github.com/hashicorp/terraform/internal/getproviders"
"github.com/hashicorp/terraform/internal/providercache" "github.com/hashicorp/terraform/internal/providercache"
"github.com/hashicorp/terraform/states" "github.com/hashicorp/terraform/states"
"github.com/hashicorp/terraform/states/statefile"
"github.com/hashicorp/terraform/states/statemgr" "github.com/hashicorp/terraform/states/statemgr"
"github.com/hashicorp/terraform/terraform"
) )
func TestInit_empty(t *testing.T) { func TestInit_empty(t *testing.T) {
@ -956,9 +957,19 @@ func TestInit_getProvider(t *testing.T) {
// getting providers should fail if a state from a newer version of // getting providers should fail if a state from a newer version of
// terraform exists, since InitCommand.getProviders needs to inspect that // terraform exists, since InitCommand.getProviders needs to inspect that
// state. // state.
s := terraform.NewState()
s.TFVersion = "100.1.0" f, err := os.Create(DefaultStateFilename)
testStateFileDefault(t, s) if err != nil {
t.Fatalf("err: %s", err)
}
defer f.Close()
s := &statefile.File{
Lineage: "",
State: states.NewState(),
TerraformVersion: version.Must(version.NewVersion("100.1.0")),
}
statefile.WriteForTest(s, f)
ui := new(cli.MockUi) ui := new(cli.MockUi)
m.Ui = ui m.Ui = ui

View File

@ -133,7 +133,7 @@ func TestMarshalProvider(t *testing.T) {
func testProviders() *terraform.Schemas { func testProviders() *terraform.Schemas {
return &terraform.Schemas{ return &terraform.Schemas{
Providers: map[addrs.Provider]*terraform.ProviderSchema{ Providers: map[addrs.Provider]*terraform.ProviderSchema{
addrs.NewLegacyProvider("test"): testProvider(), addrs.NewDefaultProvider("test"): testProvider(),
}, },
} }
} }

View File

@ -8,6 +8,7 @@ import (
"sort" "sort"
"testing" "testing"
"github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/backend" "github.com/hashicorp/terraform/backend"
"github.com/hashicorp/terraform/configs" "github.com/hashicorp/terraform/configs"
"github.com/hashicorp/terraform/helper/copy" "github.com/hashicorp/terraform/helper/copy"
@ -15,7 +16,6 @@ import (
"github.com/hashicorp/terraform/states" "github.com/hashicorp/terraform/states"
"github.com/hashicorp/terraform/states/statefile" "github.com/hashicorp/terraform/states/statefile"
"github.com/hashicorp/terraform/states/statemgr" "github.com/hashicorp/terraform/states/statemgr"
"github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
@ -1783,21 +1783,9 @@ func TestMetaBackend_localDoesNotDeleteLocal(t *testing.T) {
defer os.RemoveAll(td) defer os.RemoveAll(td)
defer testChdir(t, td)() defer testChdir(t, td)()
// create our local state // // create our local state
orig := &terraform.State{ orig := states.NewState()
Modules: []*terraform.ModuleState{ orig.Module(addrs.RootModuleInstance).SetOutputValue("foo", cty.StringVal("bar"), false)
{
Path: []string{"root"},
Outputs: map[string]*terraform.OutputState{
"foo": {
Value: "bar",
Type: "string",
},
},
},
},
}
testStateFileDefault(t, orig) testStateFileDefault(t, orig)
m := testMetaBackend(t, nil) m := testMetaBackend(t, nil)

View File

@ -27,7 +27,7 @@ func TestStateMv(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -43,7 +43,7 @@ func TestStateMv(t *testing.T) {
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")}, Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")},
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -161,7 +161,7 @@ func TestStateMv_resourceToInstance(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -177,7 +177,7 @@ func TestStateMv_resourceToInstance(t *testing.T) {
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")}, Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")},
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -188,7 +188,7 @@ func TestStateMv_resourceToInstance(t *testing.T) {
Name: "bar", Name: "bar",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -219,12 +219,12 @@ func TestStateMv_resourceToInstance(t *testing.T) {
testStateOutput(t, statePath, ` testStateOutput(t, statePath, `
test_instance.bar.0: test_instance.bar.0:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.baz: test_instance.baz:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
`) `)
@ -250,7 +250,7 @@ func TestStateMv_instanceToResource(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -265,7 +265,7 @@ func TestStateMv_instanceToResource(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -296,12 +296,12 @@ func TestStateMv_instanceToResource(t *testing.T) {
testStateOutput(t, statePath, ` testStateOutput(t, statePath, `
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.baz: test_instance.baz:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
`) `)
@ -314,12 +314,12 @@ test_instance.baz:
testStateOutput(t, backups[0], ` testStateOutput(t, backups[0], `
test_instance.baz: test_instance.baz:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.0: test_instance.foo.0:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
`) `)
@ -338,7 +338,7 @@ func TestStateMv_instanceToNewResource(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -369,7 +369,7 @@ func TestStateMv_instanceToNewResource(t *testing.T) {
testStateOutput(t, statePath, ` testStateOutput(t, statePath, `
test_instance.bar["new"]: test_instance.bar["new"]:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
`) `)
@ -390,7 +390,7 @@ test_instance.bar["new"]:
module.test: module.test:
test_instance.baz["new"]: test_instance.baz["new"]:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
`) `)
@ -409,7 +409,7 @@ func TestStateMv_differentResourceTypes(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -462,7 +462,7 @@ func TestStateMv_explicitWithBackend(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -477,7 +477,7 @@ func TestStateMv_explicitWithBackend(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -537,7 +537,7 @@ func TestStateMv_backupExplicit(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -553,7 +553,7 @@ func TestStateMv_backupExplicit(t *testing.T) {
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")}, Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")},
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -602,7 +602,7 @@ func TestStateMv_stateOutNew(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -656,7 +656,7 @@ func TestStateMv_stateOutExisting(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -675,7 +675,7 @@ func TestStateMv_stateOutExisting(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -755,7 +755,7 @@ func TestStateMv_stateOutNew_count(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -770,7 +770,7 @@ func TestStateMv_stateOutNew_count(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -785,7 +785,7 @@ func TestStateMv_stateOutNew_count(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -843,7 +843,7 @@ func TestStateMv_stateOutNew_largeCount(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -859,7 +859,7 @@ func TestStateMv_stateOutNew_largeCount(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -913,7 +913,7 @@ func TestStateMv_stateOutNew_nestedModule(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -928,7 +928,7 @@ func TestStateMv_stateOutNew_nestedModule(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -983,7 +983,7 @@ func TestStateMv_toNewModule(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -1056,7 +1056,7 @@ func TestStateMv_withinBackend(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -1072,7 +1072,7 @@ func TestStateMv_withinBackend(t *testing.T) {
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")}, Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")},
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -1130,7 +1130,7 @@ func TestStateMv_fromBackendToLocal(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -1141,7 +1141,7 @@ func TestStateMv_fromBackendToLocal(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -1204,7 +1204,7 @@ func TestStateMv_onlyResourceInModule(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -1247,7 +1247,7 @@ func TestStateMv_onlyResourceInModule(t *testing.T) {
const testStateMvOutputOriginal = ` const testStateMvOutputOriginal = `
test_instance.baz: test_instance.baz:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
@ -1255,7 +1255,7 @@ test_instance.baz:
test_instance.foo test_instance.foo
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1263,12 +1263,12 @@ test_instance.foo:
const testStateMvOutput = ` const testStateMvOutput = `
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.baz: test_instance.baz:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1276,12 +1276,12 @@ test_instance.baz:
const testStateMvCount_stateOut = ` const testStateMvCount_stateOut = `
test_instance.bar.0: test_instance.bar.0:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.1: test_instance.bar.1:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1289,7 +1289,7 @@ test_instance.bar.1:
const testStateMvCount_stateOutSrc = ` const testStateMvCount_stateOutSrc = `
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1297,17 +1297,17 @@ test_instance.bar:
const testStateMvCount_stateOutOriginal = ` const testStateMvCount_stateOutOriginal = `
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.0: test_instance.foo.0:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.1: test_instance.foo.1:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1315,57 +1315,57 @@ test_instance.foo.1:
const testStateMvLargeCount_stateOut = ` const testStateMvLargeCount_stateOut = `
test_instance.bar.0: test_instance.bar.0:
ID = foo0 ID = foo0
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.1: test_instance.bar.1:
ID = foo1 ID = foo1
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.2: test_instance.bar.2:
ID = foo2 ID = foo2
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.3: test_instance.bar.3:
ID = foo3 ID = foo3
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.4: test_instance.bar.4:
ID = foo4 ID = foo4
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.5: test_instance.bar.5:
ID = foo5 ID = foo5
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.6: test_instance.bar.6:
ID = foo6 ID = foo6
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.7: test_instance.bar.7:
ID = foo7 ID = foo7
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.8: test_instance.bar.8:
ID = foo8 ID = foo8
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.9: test_instance.bar.9:
ID = foo9 ID = foo9
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.bar.10: test_instance.bar.10:
ID = foo10 ID = foo10
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1373,7 +1373,7 @@ test_instance.bar.10:
const testStateMvLargeCount_stateOutSrc = ` const testStateMvLargeCount_stateOutSrc = `
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1381,62 +1381,62 @@ test_instance.bar:
const testStateMvLargeCount_stateOutOriginal = ` const testStateMvLargeCount_stateOutOriginal = `
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.0: test_instance.foo.0:
ID = foo0 ID = foo0
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.1: test_instance.foo.1:
ID = foo1 ID = foo1
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.2: test_instance.foo.2:
ID = foo2 ID = foo2
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.3: test_instance.foo.3:
ID = foo3 ID = foo3
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.4: test_instance.foo.4:
ID = foo4 ID = foo4
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.5: test_instance.foo.5:
ID = foo5 ID = foo5
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.6: test_instance.foo.6:
ID = foo6 ID = foo6
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.7: test_instance.foo.7:
ID = foo7 ID = foo7
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.8: test_instance.foo.8:
ID = foo8 ID = foo8
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.9: test_instance.foo.9:
ID = foo9 ID = foo9
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo.10: test_instance.foo.10:
ID = foo10 ID = foo10
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1446,13 +1446,13 @@ const testStateMvNestedModule_stateOut = `
module.bar.child1: module.bar.child1:
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
module.bar.child2: module.bar.child2:
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1462,7 +1462,7 @@ const testStateMvNewModule_stateOut = `
module.bar: module.bar:
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1472,7 +1472,7 @@ const testStateMvModuleNewModule_stateOut = `
module.foo: module.foo:
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1480,7 +1480,7 @@ module.foo:
const testStateMvNewModule_stateOutOriginal = ` const testStateMvNewModule_stateOutOriginal = `
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1494,13 +1494,13 @@ const testStateMvNestedModule_stateOutOriginal = `
module.foo.child1: module.foo.child1:
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
module.foo.child2: module.foo.child2:
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1508,7 +1508,7 @@ module.foo.child2:
const testStateMvOutput_stateOut = ` const testStateMvOutput_stateOut = `
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1520,7 +1520,7 @@ const testStateMvOutput_stateOutSrc = `
const testStateMvOutput_stateOutOriginal = ` const testStateMvOutput_stateOutOriginal = `
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1532,18 +1532,18 @@ const testStateMvExisting_stateSrc = `
const testStateMvExisting_stateDst = ` const testStateMvExisting_stateDst = `
test_instance.bar: test_instance.bar:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.qux: test_instance.qux:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
` `
const testStateMvExisting_stateSrcOriginal = ` const testStateMvExisting_stateSrcOriginal = `
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1551,13 +1551,13 @@ test_instance.foo:
const testStateMvExisting_stateDstOriginal = ` const testStateMvExisting_stateDstOriginal = `
test_instance.qux: test_instance.qux:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
` `
const testStateMvOriginal_backend = ` const testStateMvOriginal_backend = `
test_instance.baz: test_instance.baz:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1567,7 +1567,7 @@ const testStateMvOnlyResourceInModule_original = `
module.foo: module.foo:
test_instance.foo.0: test_instance.foo.0:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -1577,7 +1577,7 @@ const testStateMvOnlyResourceInModule_output = `
module.foo: module.foo:
test_instance.bar.0: test_instance.bar.0:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `

View File

@ -26,7 +26,7 @@ func TestStateRm(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -41,7 +41,7 @@ func TestStateRm(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -91,7 +91,7 @@ func TestStateRmNotChildModule(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -109,7 +109,7 @@ func TestStateRmNotChildModule(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -141,7 +141,7 @@ func TestStateRmNotChildModule(t *testing.T) {
module.child: module.child:
test_instance.foo: test_instance.foo:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
`) `)
@ -154,14 +154,14 @@ module.child:
testStateOutput(t, backups[0], ` testStateOutput(t, backups[0], `
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
module.child: module.child:
test_instance.foo: test_instance.foo:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
`) `)
@ -180,7 +180,7 @@ func TestStateRmNoArgs(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -195,7 +195,7 @@ func TestStateRmNoArgs(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -239,7 +239,7 @@ func TestStateRmNonExist(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -254,7 +254,7 @@ func TestStateRmNonExist(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -294,7 +294,7 @@ func TestStateRm_backupExplicit(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -309,7 +309,7 @@ func TestStateRm_backupExplicit(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -410,7 +410,7 @@ func TestStateRm_backendState(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -425,7 +425,7 @@ func TestStateRm_backendState(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -474,12 +474,12 @@ func TestStateRm_backendState(t *testing.T) {
const testStateRmOutputOriginal = ` const testStateRmOutputOriginal = `
test_instance.bar: test_instance.bar:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `
@ -487,7 +487,7 @@ test_instance.foo:
const testStateRmOutput = ` const testStateRmOutput = `
test_instance.bar: test_instance.bar:
ID = foo ID = foo
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
bar = value bar = value
foo = value foo = value
` `

View File

@ -10,7 +10,6 @@ import (
"github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/helper/copy" "github.com/hashicorp/terraform/helper/copy"
"github.com/hashicorp/terraform/states" "github.com/hashicorp/terraform/states"
"github.com/hashicorp/terraform/terraform"
) )
func TestTaint(t *testing.T) { func TestTaint(t *testing.T) {
@ -26,7 +25,7 @@ func TestTaint(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -64,7 +63,7 @@ func TestTaint_lockedState(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -103,22 +102,24 @@ func TestTaint_backup(t *testing.T) {
defer testFixCwd(t, tmp, cwd) defer testFixCwd(t, tmp, cwd)
// Write the temp state // Write the temp state
state := &terraform.State{ state := states.BuildState(func(s *states.SyncState) {
Modules: []*terraform.ModuleState{ s.SetResourceInstanceCurrent(
&terraform.ModuleState{ addrs.Resource{
Path: []string{"root"}, Mode: addrs.ManagedResourceMode,
Resources: map[string]*terraform.ResourceState{ Type: "test_instance",
"test_instance.foo": &terraform.ResourceState{ Name: "foo",
Type: "test_instance", }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
Primary: &terraform.InstanceState{ &states.ResourceInstanceObjectSrc{
ID: "bar", AttrsJSON: []byte(`{"id":"bar"}`),
}, Status: states.ObjectReady,
},
},
}, },
}, addrs.AbsProviderConfig{
} Provider: addrs.NewDefaultProvider("test"),
path := testStateFileDefault(t, state) Module: addrs.RootModule,
},
)
})
testStateFileDefault(t, state)
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TaintCommand{ c := &TaintCommand{
@ -134,8 +135,8 @@ func TestTaint_backup(t *testing.T) {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
} }
testStateOutput(t, path+".backup", testTaintDefaultStr) testStateOutput(t, DefaultStateFilename+".backup", testTaintDefaultStr)
testStateOutput(t, path, testTaintStr) testStateOutput(t, DefaultStateFilename, testTaintStr)
} }
func TestTaint_backupDisable(t *testing.T) { func TestTaint_backupDisable(t *testing.T) {
@ -144,22 +145,24 @@ func TestTaint_backupDisable(t *testing.T) {
defer testFixCwd(t, tmp, cwd) defer testFixCwd(t, tmp, cwd)
// Write the temp state // Write the temp state
state := &terraform.State{ state := states.BuildState(func(s *states.SyncState) {
Modules: []*terraform.ModuleState{ s.SetResourceInstanceCurrent(
&terraform.ModuleState{ addrs.Resource{
Path: []string{"root"}, Mode: addrs.ManagedResourceMode,
Resources: map[string]*terraform.ResourceState{ Type: "test_instance",
"test_instance.foo": &terraform.ResourceState{ Name: "foo",
Type: "test_instance", }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
Primary: &terraform.InstanceState{ &states.ResourceInstanceObjectSrc{
ID: "bar", AttrsJSON: []byte(`{"id":"bar"}`),
}, Status: states.ObjectReady,
},
},
}, },
}, addrs.AbsProviderConfig{
} Provider: addrs.NewDefaultProvider("test"),
path := testStateFileDefault(t, state) Module: addrs.RootModule,
},
)
})
testStateFileDefault(t, state)
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TaintCommand{ c := &TaintCommand{
@ -176,11 +179,11 @@ func TestTaint_backupDisable(t *testing.T) {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
} }
if _, err := os.Stat(path + ".backup"); err == nil { if _, err := os.Stat(DefaultStateFilename + ".backup"); err == nil {
t.Fatal("backup path should not exist") t.Fatal("backup path should not exist")
} }
testStateOutput(t, path, testTaintStr) testStateOutput(t, DefaultStateFilename, testTaintStr)
} }
func TestTaint_badState(t *testing.T) { func TestTaint_badState(t *testing.T) {
@ -206,22 +209,24 @@ func TestTaint_defaultState(t *testing.T) {
defer testFixCwd(t, tmp, cwd) defer testFixCwd(t, tmp, cwd)
// Write the temp state // Write the temp state
state := &terraform.State{ state := states.BuildState(func(s *states.SyncState) {
Modules: []*terraform.ModuleState{ s.SetResourceInstanceCurrent(
&terraform.ModuleState{ addrs.Resource{
Path: []string{"root"}, Mode: addrs.ManagedResourceMode,
Resources: map[string]*terraform.ResourceState{ Type: "test_instance",
"test_instance.foo": &terraform.ResourceState{ Name: "foo",
Type: "test_instance", }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
Primary: &terraform.InstanceState{ &states.ResourceInstanceObjectSrc{
ID: "bar", AttrsJSON: []byte(`{"id":"bar"}`),
}, Status: states.ObjectReady,
},
},
}, },
}, addrs.AbsProviderConfig{
} Provider: addrs.NewDefaultProvider("test"),
path := testStateFileDefault(t, state) Module: addrs.RootModule,
},
)
})
testStateFileDefault(t, state)
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TaintCommand{ c := &TaintCommand{
@ -237,7 +242,7 @@ func TestTaint_defaultState(t *testing.T) {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
} }
testStateOutput(t, path, testTaintStr) testStateOutput(t, DefaultStateFilename, testTaintStr)
} }
func TestTaint_defaultWorkspaceState(t *testing.T) { func TestTaint_defaultWorkspaceState(t *testing.T) {
@ -257,7 +262,7 @@ func TestTaint_defaultWorkspaceState(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -295,7 +300,7 @@ func TestTaint_missing(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -331,7 +336,7 @@ func TestTaint_missingAllow(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -361,22 +366,24 @@ func TestTaint_stateOut(t *testing.T) {
defer testFixCwd(t, tmp, cwd) defer testFixCwd(t, tmp, cwd)
// Write the temp state // Write the temp state
state := &terraform.State{ state := states.BuildState(func(s *states.SyncState) {
Modules: []*terraform.ModuleState{ s.SetResourceInstanceCurrent(
&terraform.ModuleState{ addrs.Resource{
Path: []string{"root"}, Mode: addrs.ManagedResourceMode,
Resources: map[string]*terraform.ResourceState{ Type: "test_instance",
"test_instance.foo": &terraform.ResourceState{ Name: "foo",
Type: "test_instance", }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
Primary: &terraform.InstanceState{ &states.ResourceInstanceObjectSrc{
ID: "bar", AttrsJSON: []byte(`{"id":"bar"}`),
}, Status: states.ObjectReady,
},
},
}, },
}, addrs.AbsProviderConfig{
} Provider: addrs.NewDefaultProvider("test"),
path := testStateFileDefault(t, state) Module: addrs.RootModule,
},
)
})
testStateFileDefault(t, state)
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TaintCommand{ c := &TaintCommand{
@ -393,7 +400,7 @@ func TestTaint_stateOut(t *testing.T) {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
} }
testStateOutput(t, path, testTaintDefaultStr) testStateOutput(t, DefaultStateFilename, testTaintDefaultStr)
testStateOutput(t, "foo", testTaintStr) testStateOutput(t, "foo", testTaintStr)
} }
@ -410,7 +417,7 @@ func TestTaint_module(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -425,7 +432,7 @@ func TestTaint_module(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -458,22 +465,24 @@ func TestTaint_checkRequiredVersion(t *testing.T) {
defer testChdir(t, td)() defer testChdir(t, td)()
// Write the temp state // Write the temp state
state := &terraform.State{ state := states.BuildState(func(s *states.SyncState) {
Modules: []*terraform.ModuleState{ s.SetResourceInstanceCurrent(
{ addrs.Resource{
Path: []string{"root"}, Mode: addrs.ManagedResourceMode,
Resources: map[string]*terraform.ResourceState{ Type: "test_instance",
"test_instance.foo": { Name: "foo",
Type: "test_instance", }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
Primary: &terraform.InstanceState{ &states.ResourceInstanceObjectSrc{
ID: "bar", AttrsJSON: []byte(`{"id":"bar"}`),
}, Status: states.ObjectReady,
},
},
}, },
}, addrs.AbsProviderConfig{
} Provider: addrs.NewDefaultProvider("test"),
path := testStateFileDefault(t, state) Module: addrs.RootModule,
},
)
})
path := testStateFile(t, state)
ui := cli.NewMockUi() ui := cli.NewMockUi()
c := &TaintCommand{ c := &TaintCommand{
@ -504,22 +513,22 @@ func TestTaint_checkRequiredVersion(t *testing.T) {
const testTaintStr = ` const testTaintStr = `
test_instance.foo: (tainted) test_instance.foo: (tainted)
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
` `
const testTaintDefaultStr = ` const testTaintDefaultStr = `
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
` `
const testTaintModuleStr = ` const testTaintModuleStr = `
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
module.child: module.child:
test_instance.blah: (tainted) test_instance.blah: (tainted)
ID = blah ID = blah
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
` `

View File

@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/states" "github.com/hashicorp/terraform/states"
"github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@ -24,7 +23,7 @@ func TestUntaint(t *testing.T) {
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -49,7 +48,7 @@ func TestUntaint(t *testing.T) {
expected := strings.TrimSpace(` expected := strings.TrimSpace(`
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
`) `)
testStateOutput(t, statePath, expected) testStateOutput(t, statePath, expected)
} }
@ -67,7 +66,7 @@ func TestUntaint_lockedState(t *testing.T) {
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -106,23 +105,24 @@ func TestUntaint_backup(t *testing.T) {
defer testFixCwd(t, tmp, cwd) defer testFixCwd(t, tmp, cwd)
// Write the temp state // Write the temp state
state := &terraform.State{ state := states.BuildState(func(s *states.SyncState) {
Modules: []*terraform.ModuleState{ s.SetResourceInstanceCurrent(
&terraform.ModuleState{ addrs.Resource{
Path: []string{"root"}, Mode: addrs.ManagedResourceMode,
Resources: map[string]*terraform.ResourceState{ Type: "test_instance",
"test_instance.foo": &terraform.ResourceState{ Name: "foo",
Type: "test_instance", }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
Primary: &terraform.InstanceState{ &states.ResourceInstanceObjectSrc{
ID: "bar", AttrsJSON: []byte(`{"id":"bar"}`),
Tainted: true, Status: states.ObjectTainted,
},
},
},
}, },
}, addrs.AbsProviderConfig{
} Provider: addrs.NewDefaultProvider("test"),
path := testStateFileDefault(t, state) Module: addrs.RootModule,
},
)
})
testStateFileDefault(t, state)
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &UntaintCommand{ c := &UntaintCommand{
@ -139,17 +139,17 @@ func TestUntaint_backup(t *testing.T) {
} }
// Backup is still tainted // Backup is still tainted
testStateOutput(t, path+".backup", strings.TrimSpace(` testStateOutput(t, DefaultStateFilename+".backup", strings.TrimSpace(`
test_instance.foo: (tainted) test_instance.foo: (tainted)
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
`)) `))
// State is untainted // State is untainted
testStateOutput(t, path, strings.TrimSpace(` testStateOutput(t, DefaultStateFilename, strings.TrimSpace(`
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
`)) `))
} }
@ -159,23 +159,24 @@ func TestUntaint_backupDisable(t *testing.T) {
defer testFixCwd(t, tmp, cwd) defer testFixCwd(t, tmp, cwd)
// Write the temp state // Write the temp state
state := &terraform.State{ state := states.BuildState(func(s *states.SyncState) {
Modules: []*terraform.ModuleState{ s.SetResourceInstanceCurrent(
&terraform.ModuleState{ addrs.Resource{
Path: []string{"root"}, Mode: addrs.ManagedResourceMode,
Resources: map[string]*terraform.ResourceState{ Type: "test_instance",
"test_instance.foo": &terraform.ResourceState{ Name: "foo",
Type: "test_instance", }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
Primary: &terraform.InstanceState{ &states.ResourceInstanceObjectSrc{
ID: "bar", AttrsJSON: []byte(`{"id":"bar"}`),
Tainted: true, Status: states.ObjectTainted,
},
},
},
}, },
}, addrs.AbsProviderConfig{
} Provider: addrs.NewDefaultProvider("test"),
path := testStateFileDefault(t, state) Module: addrs.RootModule,
},
)
})
testStateFileDefault(t, state)
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &UntaintCommand{ c := &UntaintCommand{
@ -192,14 +193,14 @@ func TestUntaint_backupDisable(t *testing.T) {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
} }
if _, err := os.Stat(path + ".backup"); err == nil { if _, err := os.Stat(DefaultStateFilename + ".backup"); err == nil {
t.Fatal("backup path should not exist") t.Fatal("backup path should not exist")
} }
testStateOutput(t, path, strings.TrimSpace(` testStateOutput(t, DefaultStateFilename, strings.TrimSpace(`
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
`)) `))
} }
@ -226,23 +227,24 @@ func TestUntaint_defaultState(t *testing.T) {
defer testFixCwd(t, tmp, cwd) defer testFixCwd(t, tmp, cwd)
// Write the temp state // Write the temp state
state := &terraform.State{ state := states.BuildState(func(s *states.SyncState) {
Modules: []*terraform.ModuleState{ s.SetResourceInstanceCurrent(
&terraform.ModuleState{ addrs.Resource{
Path: []string{"root"}, Mode: addrs.ManagedResourceMode,
Resources: map[string]*terraform.ResourceState{ Type: "test_instance",
"test_instance.foo": &terraform.ResourceState{ Name: "foo",
Type: "test_instance", }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
Primary: &terraform.InstanceState{ &states.ResourceInstanceObjectSrc{
ID: "bar", AttrsJSON: []byte(`{"id":"bar"}`),
Tainted: true, Status: states.ObjectTainted,
},
},
},
}, },
}, addrs.AbsProviderConfig{
} Provider: addrs.NewDefaultProvider("test"),
path := testStateFileDefault(t, state) Module: addrs.RootModule,
},
)
})
testStateFileDefault(t, state)
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &UntaintCommand{ c := &UntaintCommand{
@ -258,10 +260,10 @@ func TestUntaint_defaultState(t *testing.T) {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
} }
testStateOutput(t, path, strings.TrimSpace(` testStateOutput(t, DefaultStateFilename, strings.TrimSpace(`
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
`)) `))
} }
@ -283,7 +285,7 @@ func TestUntaint_defaultWorkspaceState(t *testing.T) {
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -308,7 +310,7 @@ func TestUntaint_defaultWorkspaceState(t *testing.T) {
testStateOutput(t, path, strings.TrimSpace(` testStateOutput(t, path, strings.TrimSpace(`
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
`)) `))
} }
@ -325,7 +327,7 @@ func TestUntaint_missing(t *testing.T) {
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -361,7 +363,7 @@ func TestUntaint_missingAllow(t *testing.T) {
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -391,23 +393,24 @@ func TestUntaint_stateOut(t *testing.T) {
defer testFixCwd(t, tmp, cwd) defer testFixCwd(t, tmp, cwd)
// Write the temp state // Write the temp state
state := &terraform.State{ state := states.BuildState(func(s *states.SyncState) {
Modules: []*terraform.ModuleState{ s.SetResourceInstanceCurrent(
&terraform.ModuleState{ addrs.Resource{
Path: []string{"root"}, Mode: addrs.ManagedResourceMode,
Resources: map[string]*terraform.ResourceState{ Type: "test_instance",
"test_instance.foo": &terraform.ResourceState{ Name: "foo",
Type: "test_instance", }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
Primary: &terraform.InstanceState{ &states.ResourceInstanceObjectSrc{
ID: "bar", AttrsJSON: []byte(`{"id":"bar"}`),
Tainted: true, Status: states.ObjectTainted,
},
},
},
}, },
}, addrs.AbsProviderConfig{
} Provider: addrs.NewDefaultProvider("test"),
path := testStateFileDefault(t, state) Module: addrs.RootModule,
},
)
})
testStateFileDefault(t, state)
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &UntaintCommand{ c := &UntaintCommand{
@ -424,15 +427,15 @@ func TestUntaint_stateOut(t *testing.T) {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
} }
testStateOutput(t, path, strings.TrimSpace(` testStateOutput(t, DefaultStateFilename, strings.TrimSpace(`
test_instance.foo: (tainted) test_instance.foo: (tainted)
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
`)) `))
testStateOutput(t, "foo", strings.TrimSpace(` testStateOutput(t, "foo", strings.TrimSpace(`
test_instance.foo: test_instance.foo:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
`)) `))
} }
@ -449,7 +452,7 @@ func TestUntaint_module(t *testing.T) {
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -464,7 +467,7 @@ func TestUntaint_module(t *testing.T) {
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )
@ -489,11 +492,11 @@ func TestUntaint_module(t *testing.T) {
testStateOutput(t, statePath, strings.TrimSpace(` testStateOutput(t, statePath, strings.TrimSpace(`
test_instance.foo: (tainted) test_instance.foo: (tainted)
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
module.child: module.child:
test_instance.blah: test_instance.blah:
ID = bar ID = bar
provider = provider["registry.terraform.io/-/test"] provider = provider["registry.terraform.io/hashicorp/test"]
`)) `))
} }

View File

@ -241,7 +241,7 @@ func TestWorkspace_createWithState(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule, Module: addrs.RootModule,
}, },
) )

View File

@ -74,7 +74,7 @@ func TestConfigResolveAbsProviderAddr(t *testing.T) {
t.Run("already absolute", func(t *testing.T) { t.Run("already absolute", func(t *testing.T) {
addr := addrs.AbsProviderConfig{ addr := addrs.AbsProviderConfig{
Module: addrs.RootModule, Module: addrs.RootModule,
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
Alias: "boop", Alias: "boop",
} }
got := cfg.ResolveAbsProviderAddr(addr, addrs.RootModule) got := cfg.ResolveAbsProviderAddr(addr, addrs.RootModule)

View File

@ -30,7 +30,7 @@ func TestNewModule_provider_local_name(t *testing.T) {
} }
// if there is not a local name for a provider, it should return the type name // if there is not a local name for a provider, it should return the type name
localName = mod.LocalNameForProvider(addrs.NewLegacyProvider("nonexist")) localName = mod.LocalNameForProvider(addrs.NewDefaultProvider("nonexist"))
if localName != "nonexist" { if localName != "nonexist" {
t.Error("wrong local name returned for a non-local provider") t.Error("wrong local name returned for a non-local provider")
} }

View File

@ -170,7 +170,7 @@ func (c *Config) ProviderDependencies() (*moduledeps.Module, tfdiags.Diagnostics
fqn = addr fqn = addr
} }
if fqn.IsZero() { if fqn.IsZero() {
fqn = addrs.NewLegacyProvider(name) fqn = addrs.NewDefaultProvider(name)
} }
var constraints version.Constraints var constraints version.Constraints
for _, reqStr := range reqs.VersionConstraints { for _, reqStr := range reqs.VersionConstraints {
@ -180,7 +180,7 @@ func (c *Config) ProviderDependencies() (*moduledeps.Module, tfdiags.Diagnostics
diags = diags.Append(wrapDiagnostic(tfconfig.Diagnostic{ diags = diags.Append(wrapDiagnostic(tfconfig.Diagnostic{
Severity: tfconfig.DiagError, Severity: tfconfig.DiagError,
Summary: "Invalid provider version constraint", Summary: "Invalid provider version constraint",
Detail: fmt.Sprintf("Invalid version constraint %q for provider %s.", reqStr, fqn.LegacyString()), Detail: fmt.Sprintf("Invalid version constraint %q for provider %s.", reqStr, fqn.String()),
})) }))
continue continue
} }

View File

@ -110,11 +110,11 @@ func (s sortModules) Swap(i, j int) {
func (m *Module) ProviderRequirements() discovery.PluginRequirements { func (m *Module) ProviderRequirements() discovery.PluginRequirements {
ret := make(discovery.PluginRequirements) ret := make(discovery.PluginRequirements)
for pFqn, dep := range m.Providers { for pFqn, dep := range m.Providers {
providerStr := pFqn.LegacyString() providerType := pFqn.Type
if existing, exists := ret[providerStr]; exists { if existing, exists := ret[providerType]; exists {
ret[providerStr].Versions = existing.Versions.Append(dep.Constraints) ret[providerType].Versions = existing.Versions.Append(dep.Constraints)
} else { } else {
ret[providerStr] = &discovery.PluginConstraints{ ret[providerType] = &discovery.PluginConstraints{
Versions: dep.Constraints, Versions: dep.Constraints,
} }
} }

View File

@ -192,10 +192,10 @@ func TestModuleProviderRequirements(t *testing.T) {
m := &Module{ m := &Module{
Name: "root", Name: "root",
Providers: Providers{ Providers: Providers{
addrs.NewLegacyProvider("foo"): ProviderDependency{ addrs.NewDefaultProvider("foo"): ProviderDependency{
Constraints: discovery.ConstraintStr(">=1.0.0").MustParse(), Constraints: discovery.ConstraintStr(">=1.0.0").MustParse(),
}, },
addrs.NewLegacyProvider("baz"): ProviderDependency{ addrs.NewDefaultProvider("baz"): ProviderDependency{
Constraints: discovery.ConstraintStr(">=3.0.0").MustParse(), Constraints: discovery.ConstraintStr(">=3.0.0").MustParse(),
}, },
}, },

View File

@ -22,7 +22,7 @@ func TestProviderAddrs(t *testing.T) {
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance), }.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.AbsProviderConfig{ ProviderAddr: addrs.AbsProviderConfig{
Module: addrs.RootModule, Module: addrs.RootModule,
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
}, },
}, },
{ {
@ -34,7 +34,7 @@ func TestProviderAddrs(t *testing.T) {
DeposedKey: "foodface", DeposedKey: "foodface",
ProviderAddr: addrs.AbsProviderConfig{ ProviderAddr: addrs.AbsProviderConfig{
Module: addrs.RootModule, Module: addrs.RootModule,
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
}, },
}, },
{ {
@ -45,7 +45,7 @@ func TestProviderAddrs(t *testing.T) {
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance), }.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.AbsProviderConfig{ ProviderAddr: addrs.AbsProviderConfig{
Module: addrs.RootModule.Child("foo"), Module: addrs.RootModule.Child("foo"),
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
}, },
}, },
}, },
@ -56,11 +56,11 @@ func TestProviderAddrs(t *testing.T) {
want := []addrs.AbsProviderConfig{ want := []addrs.AbsProviderConfig{
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Module: addrs.RootModule.Child("foo"), Module: addrs.RootModule.Child("foo"),
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Module: addrs.RootModule, Module: addrs.RootModule,
Provider: addrs.NewLegacyProvider("test"), Provider: addrs.NewDefaultProvider("test"),
}, },
} }

View File

@ -12,32 +12,32 @@ func TestAddressedTypesAbs(t *testing.T) {
providerAddrs := []addrs.AbsProviderConfig{ providerAddrs := []addrs.AbsProviderConfig{
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Module: addrs.RootModule, Module: addrs.RootModule,
Provider: addrs.NewLegacyProvider("aws"), Provider: addrs.NewDefaultProvider("aws"),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Module: addrs.RootModule, Module: addrs.RootModule,
Provider: addrs.NewLegacyProvider("aws"), Provider: addrs.NewDefaultProvider("aws"),
Alias: "foo", Alias: "foo",
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Module: addrs.RootModule, Module: addrs.RootModule,
Provider: addrs.NewLegacyProvider("azure"), Provider: addrs.NewDefaultProvider("azure"),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Module: addrs.RootModule, Module: addrs.RootModule,
Provider: addrs.NewLegacyProvider("null"), Provider: addrs.NewDefaultProvider("null"),
}, },
addrs.AbsProviderConfig{ addrs.AbsProviderConfig{
Module: addrs.RootModule, Module: addrs.RootModule,
Provider: addrs.NewLegacyProvider("null"), Provider: addrs.NewDefaultProvider("null"),
}, },
} }
got := AddressedTypesAbs(providerAddrs) got := AddressedTypesAbs(providerAddrs)
want := []addrs.Provider{ want := []addrs.Provider{
addrs.NewLegacyProvider("aws"), addrs.NewDefaultProvider("aws"),
addrs.NewLegacyProvider("azure"), addrs.NewDefaultProvider("azure"),
addrs.NewLegacyProvider("null"), addrs.NewDefaultProvider("null"),
} }
for _, problem := range deep.Equal(got, want) { for _, problem := range deep.Equal(got, want) {
t.Error(problem) t.Error(problem)

View File

@ -15,3 +15,12 @@ func Write(s *File, w io.Writer) error {
diags := writeStateV4(s, w) diags := writeStateV4(s, w)
return diags.Err() return diags.Err()
} }
// WriteForTest writes the given state to the given writer in the current state
// serialization format without recording the current terraform version. This is
// intended for use in tests that need to override the current terraform
// version.
func WriteForTest(s *File, w io.Writer) error {
diags := writeStateV4(s, w)
return diags.Err()
}

View File

@ -151,7 +151,7 @@ func TestFullInitialState() *states.State {
Name: "foo", Name: "foo",
} }
providerAddr := addrs.AbsProviderConfig{ providerAddr := addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider(rAddr.ImpliedProvider()), Provider: addrs.NewDefaultProvider(rAddr.ImpliedProvider()),
Module: addrs.RootModule, Module: addrs.RootModule,
} }
childMod.SetResourceProvider(rAddr, providerAddr) childMod.SetResourceProvider(rAddr, providerAddr)