addrs: roll back change to Type field in ProviderConfig (#23937)

This commit is contained in:
Kristin Laemmert 2020-01-28 08:13:30 -05:00 committed by GitHub
parent e9d0822b2a
commit 6541775ce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 241 additions and 229 deletions

View File

@ -11,7 +11,7 @@ import (
// ProviderConfig is the address of a provider configuration. // ProviderConfig is the address of a provider configuration.
type ProviderConfig struct { type ProviderConfig struct {
Type Provider Type string
// If not empty, Alias identifies which non-default (aliased) provider // If not empty, Alias identifies which non-default (aliased) provider
// configuration this address refers to. // configuration this address refers to.
@ -22,7 +22,7 @@ type ProviderConfig struct {
// configuration for the provider with the given type name. // configuration for the provider with the given type name.
func NewDefaultProviderConfig(typeName string) ProviderConfig { func NewDefaultProviderConfig(typeName string) ProviderConfig {
return ProviderConfig{ return ProviderConfig{
Type: NewLegacyProvider(typeName), Type: typeName,
} }
} }
@ -36,25 +36,25 @@ func (pc ProviderConfig) Absolute(module ModuleInstance) AbsProviderConfig {
} }
func (pc ProviderConfig) String() string { func (pc ProviderConfig) String() string {
if pc.Type.LegacyString() == "" { if pc.Type == "" {
// Should never happen; always indicates a bug // Should never happen; always indicates a bug
return "provider.<invalid>" return "provider.<invalid>"
} }
if pc.Alias != "" { if pc.Alias != "" {
return fmt.Sprintf("provider.%s.%s", pc.Type.LegacyString(), pc.Alias) return fmt.Sprintf("provider.%s.%s", pc.Type, pc.Alias)
} }
return "provider." + pc.Type.LegacyString() return "provider." + pc.Type
} }
// StringCompact is an alternative to String that returns the form that can // StringCompact is an alternative to String that returns the form that can
// be parsed by ParseProviderConfigCompact, without the "provider." prefix. // be parsed by ParseProviderConfigCompact, without the "provider." prefix.
func (pc ProviderConfig) StringCompact() string { func (pc ProviderConfig) StringCompact() string {
if pc.Alias != "" { if pc.Alias != "" {
return fmt.Sprintf("%s.%s", pc.Type.LegacyString(), pc.Alias) return fmt.Sprintf("%s.%s", pc.Type, pc.Alias)
} }
return pc.Type.LegacyString() return pc.Type
} }
// AbsProviderConfig is the absolute address of a provider configuration // AbsProviderConfig is the absolute address of a provider configuration
@ -103,7 +103,7 @@ func ParseAbsProviderConfig(traversal hcl.Traversal) (AbsProviderConfig, tfdiags
} }
if tt, ok := remain[1].(hcl.TraverseAttr); ok { if tt, ok := remain[1].(hcl.TraverseAttr); ok {
ret.ProviderConfig.Type = NewLegacyProvider(tt.Name) ret.ProviderConfig.Type = tt.Name
} else { } else {
diags = diags.Append(&hcl.Diagnostic{ diags = diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError, Severity: hcl.DiagError,
@ -166,7 +166,7 @@ func (m ModuleInstance) ProviderConfigDefault(name string) AbsProviderConfig {
return AbsProviderConfig{ return AbsProviderConfig{
Module: m, Module: m,
ProviderConfig: ProviderConfig{ ProviderConfig: ProviderConfig{
Type: NewLegacyProvider(name), Type: name,
}, },
} }
} }
@ -177,7 +177,7 @@ func (m ModuleInstance) ProviderConfigAliased(name, alias string) AbsProviderCon
return AbsProviderConfig{ return AbsProviderConfig{
Module: m, Module: m,
ProviderConfig: ProviderConfig{ ProviderConfig: ProviderConfig{
Type: NewLegacyProvider(name), Type: name,
Alias: alias, Alias: alias,
}, },
} }

View File

@ -20,7 +20,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
AbsProviderConfig{ AbsProviderConfig{
Module: RootModuleInstance, Module: RootModuleInstance,
ProviderConfig: ProviderConfig{ ProviderConfig: ProviderConfig{
Type: NewLegacyProvider("aws"), Type: "aws",
}, },
}, },
``, ``,
@ -30,7 +30,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
AbsProviderConfig{ AbsProviderConfig{
Module: RootModuleInstance, Module: RootModuleInstance,
ProviderConfig: ProviderConfig{ ProviderConfig: ProviderConfig{
Type: NewLegacyProvider("aws"), Type: "aws",
Alias: "foo", Alias: "foo",
}, },
}, },
@ -45,7 +45,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
}, },
}, },
ProviderConfig: ProviderConfig{ ProviderConfig: ProviderConfig{
Type: NewLegacyProvider("aws"), Type: "aws",
}, },
}, },
``, ``,
@ -59,7 +59,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
}, },
}, },
ProviderConfig: ProviderConfig{ ProviderConfig: ProviderConfig{
Type: NewLegacyProvider("aws"), Type: "aws",
Alias: "foo", Alias: "foo",
}, },
}, },
@ -75,7 +75,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
}, },
}, },
ProviderConfig: ProviderConfig{ ProviderConfig: ProviderConfig{
Type: NewLegacyProvider("aws"), Type: "aws",
}, },
}, },
``, ``,
@ -90,7 +90,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
}, },
}, },
ProviderConfig: ProviderConfig{ ProviderConfig: ProviderConfig{
Type: NewLegacyProvider("aws"), Type: "aws",
}, },
}, },
``, ``,
@ -108,7 +108,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
}, },
}, },
ProviderConfig: ProviderConfig{ ProviderConfig: ProviderConfig{
Type: NewLegacyProvider("aws"), Type: "aws",
}, },
}, },
``, ``,

View File

@ -67,7 +67,7 @@ func (r Resource) DefaultProviderConfig() ProviderConfig {
} }
return ProviderConfig{ return ProviderConfig{
Type: NewLegacyProvider(typeName), Type: typeName,
} }
} }

View File

@ -262,7 +262,7 @@ func RenderPlan(plan *plans.Plan, state *states.State, schemas *terraform.Schema
if rcs.Action == plans.NoOp { if rcs.Action == plans.NoOp {
continue continue
} }
providerSchema := schemas.ProviderSchema(rcs.ProviderAddr.ProviderConfig.Type.LegacyString()) providerSchema := schemas.ProviderSchema(rcs.ProviderAddr.ProviderConfig.Type)
if providerSchema == nil { if providerSchema == nil {
// Should never happen // Should never happen
ui.Output(fmt.Sprintf("(schema missing for %s)\n", rcs.ProviderAddr)) ui.Output(fmt.Sprintf("(schema missing for %s)\n", rcs.ProviderAddr))

View File

@ -216,7 +216,7 @@ func TestLocal_planDeposedOnly(t *testing.T) {
}`), }`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
})) }))
@ -659,7 +659,7 @@ func testPlanState() *states.State {
}`), }`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
return state return state
@ -685,7 +685,7 @@ func testPlanState_withDataSource() *states.State {
}`), }`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
rootModule.SetResourceInstanceCurrent( rootModule.SetResourceInstanceCurrent(
@ -701,7 +701,7 @@ func testPlanState_withDataSource() *states.State {
}`), }`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
return state return state
@ -727,7 +727,7 @@ func testPlanState_tainted() *states.State {
}`), }`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
return state return state

View File

@ -151,7 +151,7 @@ func TestBackendStates(t *testing.T, b Backend) {
SchemaVersion: 0, SchemaVersion: 0,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )

View File

@ -29,7 +29,7 @@ func TestApply_destroy(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, originalState) statePath := testStateFile(t, originalState)
@ -122,7 +122,7 @@ func TestApply_destroyLockedState(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, originalState) statePath := testStateFile(t, originalState)
@ -194,7 +194,7 @@ func TestApply_destroyTargeted(t *testing.T) {
AttrsJSON: []byte(`{"id":"i-ab123"}`), AttrsJSON: []byte(`{"id":"i-ab123"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -206,7 +206,7 @@ func TestApply_destroyTargeted(t *testing.T) {
AttrsJSON: []byte(`{"id":"i-abc123"}`), AttrsJSON: []byte(`{"id":"i-abc123"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, originalState) statePath := testStateFile(t, originalState)

View File

@ -833,7 +833,7 @@ func TestApply_refresh(t *testing.T) {
AttrsJSON: []byte(`{"ami":"bar"}`), AttrsJSON: []byte(`{"ami":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, originalState) statePath := testStateFile(t, originalState)
@ -987,7 +987,7 @@ func TestApply_state(t *testing.T) {
AttrsJSON: []byte(`{"ami":"foo"}`), AttrsJSON: []byte(`{"ami":"foo"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, originalState) statePath := testStateFile(t, originalState)
@ -1351,7 +1351,7 @@ func TestApply_backup(t *testing.T) {
AttrsJSON: []byte("{\n \"id\": \"bar\"\n }"), AttrsJSON: []byte("{\n \"id\": \"bar\"\n }"),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, originalState) statePath := testStateFile(t, originalState)
@ -1652,7 +1652,7 @@ func applyFixturePlanFile(t *testing.T) string {
Type: "test_instance", Type: "test_instance",
Name: "foo", Name: "foo",
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance), }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), ProviderAddr: addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{
Action: plans.Create, Action: plans.Create,
Before: priorValRaw, Before: priorValRaw,

View File

@ -272,7 +272,7 @@ func testState() *states.State {
DependsOn: []addrs.Referenceable{}, DependsOn: []addrs.Referenceable{},
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
// DeepCopy is used here to ensure our synthetic state matches exactly // DeepCopy is used here to ensure our synthetic state matches exactly

View File

@ -3157,7 +3157,7 @@ func runTestCases(t *testing.T, testCases map[string]testCase) {
Type: "test_instance", Type: "test_instance",
Name: "example", Name: "example",
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance), }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), ProviderAddr: addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{
Action: tc.Action, Action: tc.Action,
Before: before, Before: before,

View File

@ -244,7 +244,7 @@ func basicState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles"}`), AttrsJSON: []byte(`{"woozles":"confuzles"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
rootModule.SetResourceInstanceCurrent( rootModule.SetResourceInstanceCurrent(
@ -259,7 +259,7 @@ func basicState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"compute":"sure"}`), AttrsJSON: []byte(`{"compute":"sure"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
return state return state
@ -294,7 +294,7 @@ func stateWithMoreOutputs(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles"}`), AttrsJSON: []byte(`{"woozles":"confuzles"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
return state return state
@ -320,7 +320,7 @@ func nestedState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`), AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
return state return state
@ -342,7 +342,7 @@ func deposedState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`), AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
return state return state
@ -370,7 +370,7 @@ func onlyDeposedState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`), AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
rootModule.SetResourceInstanceDeposed( rootModule.SetResourceInstanceDeposed(
@ -386,7 +386,7 @@ func onlyDeposedState(t *testing.T) *states.State {
AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`), AttrsJSON: []byte(`{"woozles":"confuzles","nested": [{"value": "42"}]}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
return state return state

View File

@ -125,7 +125,7 @@ func TestGraph_plan(t *testing.T) {
Before: plans.DynamicValue(`{}`), Before: plans.DynamicValue(`{}`),
After: plans.DynamicValue(`null`), After: plans.DynamicValue(`null`),
}, },
ProviderAddr: addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), ProviderAddr: addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
}) })
emptyConfig, err := plans.NewDynamicValue(cty.EmptyObjectVal, cty.EmptyObject) emptyConfig, err := plans.NewDynamicValue(cty.EmptyObjectVal, cty.EmptyObject)
if err != nil { if err != nil {

View File

@ -302,7 +302,7 @@ func marshalResources(resources map[string]*configs.Resource, schemas *terraform
} }
schema, schemaVer := schemas.ResourceTypeConfig( schema, schemaVer := schemas.ResourceTypeConfig(
v.ProviderConfigAddr().Type.LegacyString(), v.ProviderConfigAddr().Type,
v.Mode, v.Mode,
v.Type, v.Type,
) )

View File

@ -178,7 +178,7 @@ func (p *plan) marshalResourceChanges(changes *plans.Changes, schemas *terraform
} }
schema, _ := schemas.ResourceTypeConfig( schema, _ := schemas.ResourceTypeConfig(
rc.ProviderAddr.ProviderConfig.Type.LegacyString(), rc.ProviderAddr.ProviderConfig.Type,
addr.Resource.Resource.Mode, addr.Resource.Resource.Mode,
addr.Resource.Resource.Type, addr.Resource.Resource.Type,
) )

View File

@ -181,7 +181,7 @@ func marshalPlanResources(changes *plans.Changes, ris []addrs.AbsResourceInstanc
} }
schema, schemaVer := schemas.ResourceTypeConfig( schema, schemaVer := schemas.ResourceTypeConfig(
r.ProviderAddr.ProviderConfig.Type.LegacyString(), r.ProviderAddr.ProviderConfig.Type,
r.Addr.Resource.Resource.Mode, r.Addr.Resource.Resource.Mode,
resource.Type, resource.Type,
) )

View File

@ -258,7 +258,7 @@ func TestMarshalPlanResources(t *testing.T) {
Type: "test_thing", Type: "test_thing",
Name: "example", Name: "example",
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance), }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), ProviderAddr: addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{
Action: test.Action, Action: test.Action,
Before: before, Before: before,

View File

@ -274,7 +274,7 @@ func marshalResources(resources map[string]*states.Resource, schemas *terraform.
} }
schema, _ := schemas.ResourceTypeConfig( schema, _ := schemas.ResourceTypeConfig(
r.ProviderConfig.ProviderConfig.Type.LegacyString(), r.ProviderConfig.ProviderConfig.Type,
r.Addr.Mode, r.Addr.Mode,
r.Addr.Type, r.Addr.Type,
) )

View File

@ -202,7 +202,7 @@ func TestMarshalResources(t *testing.T) {
}, },
}, },
ProviderConfig: addrs.ProviderConfig{ ProviderConfig: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
}, },
}, },
@ -245,7 +245,7 @@ func TestMarshalResources(t *testing.T) {
}, },
}, },
ProviderConfig: addrs.ProviderConfig{ ProviderConfig: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
}, },
}, },
@ -293,7 +293,7 @@ func TestMarshalResources(t *testing.T) {
}, },
}, },
ProviderConfig: addrs.ProviderConfig{ ProviderConfig: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
}, },
}, },

View File

@ -124,7 +124,7 @@ func TestPlan_destroy(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
outPath := testTempFile(t) outPath := testTempFile(t)
@ -240,7 +240,7 @@ func TestPlan_outPathNoChange(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","ami":"bar","network_interface":[{"description":"Main network interface","device_index":"0"}]}`), AttrsJSON: []byte(`{"id":"bar","ami":"bar","network_interface":[{"description":"Main network interface","device_index":"0"}]}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, originalState) statePath := testStateFile(t, originalState)

View File

@ -489,7 +489,7 @@ func showFixturePlanFile(t *testing.T, action plans.Action) string {
Type: "test_instance", Type: "test_instance",
Name: "foo", Name: "foo",
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance), }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), ProviderAddr: addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{
Action: action, Action: action,
Before: priorValRaw, Before: priorValRaw,

View File

@ -27,7 +27,7 @@ func TestStateMv(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -40,7 +40,7 @@ func TestStateMv(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")}, Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")},
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -88,7 +88,7 @@ func TestStateMv_resourceToInstance(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -101,7 +101,7 @@ func TestStateMv_resourceToInstance(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")}, Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")},
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceMeta( s.SetResourceMeta(
addrs.Resource{ addrs.Resource{
@ -110,7 +110,7 @@ func TestStateMv_resourceToInstance(t *testing.T) {
Name: "bar", Name: "bar",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
states.EachList, states.EachList,
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -169,7 +169,7 @@ func TestStateMv_instanceToResource(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -181,7 +181,7 @@ func TestStateMv_instanceToResource(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -251,7 +251,7 @@ func TestStateMv_instanceToNewResource(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -319,7 +319,7 @@ func TestStateMv_differentResourceTypes(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -369,7 +369,7 @@ func TestStateMv_explicitWithBackend(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -381,7 +381,7 @@ func TestStateMv_explicitWithBackend(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -438,7 +438,7 @@ func TestStateMv_backupExplicit(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -451,7 +451,7 @@ func TestStateMv_backupExplicit(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")}, Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")},
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -497,7 +497,7 @@ func TestStateMv_stateOutNew(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -548,7 +548,7 @@ func TestStateMv_stateOutExisting(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, stateSrc) statePath := testStateFile(t, stateSrc)
@ -564,7 +564,7 @@ func TestStateMv_stateOutExisting(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
stateOutPath := testStateFile(t, stateDst) stateOutPath := testStateFile(t, stateDst)
@ -641,7 +641,7 @@ func TestStateMv_stateOutNew_count(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -653,7 +653,7 @@ func TestStateMv_stateOutNew_count(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -665,7 +665,7 @@ func TestStateMv_stateOutNew_count(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -720,7 +720,7 @@ func TestStateMv_stateOutNew_largeCount(t *testing.T) {
AttrsJSON: []byte(fmt.Sprintf(`{"id":"foo%d","foo":"value","bar":"value"}`, i)), AttrsJSON: []byte(fmt.Sprintf(`{"id":"foo%d","foo":"value","bar":"value"}`, i)),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
} }
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
@ -733,7 +733,7 @@ func TestStateMv_stateOutNew_largeCount(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -784,7 +784,7 @@ func TestStateMv_stateOutNew_nestedModule(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -796,7 +796,7 @@ func TestStateMv_stateOutNew_nestedModule(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
@ -848,7 +848,7 @@ func TestStateMv_toNewModule(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
@ -918,7 +918,7 @@ func TestStateMv_withinBackend(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -931,7 +931,7 @@ func TestStateMv_withinBackend(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")}, Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")},
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })

View File

@ -25,7 +25,7 @@ func TestStateRm(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -37,7 +37,7 @@ func TestStateRm(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -84,7 +84,7 @@ func TestStateRmNotChildModule(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
// This second instance has the same local address as the first but // This second instance has the same local address as the first but
// is in a child module. Older versions of Terraform would incorrectly // is in a child module. Older versions of Terraform would incorrectly
@ -99,7 +99,7 @@ func TestStateRmNotChildModule(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -167,7 +167,7 @@ func TestStateRmNoArgs(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -179,7 +179,7 @@ func TestStateRmNoArgs(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -220,7 +220,7 @@ func TestStateRmNonExist(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -232,7 +232,7 @@ func TestStateRmNonExist(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -274,7 +274,7 @@ func TestStateRm_backupExplicit(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -286,7 +286,7 @@ func TestStateRm_backupExplicit(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -384,7 +384,7 @@ func TestStateRm_backendState(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -396,7 +396,7 @@ func TestStateRm_backendState(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })

View File

@ -24,7 +24,7 @@ func TestStateShow(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -79,7 +79,7 @@ func TestStateShow_multi(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"bar","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -91,7 +91,7 @@ func TestStateShow_multi(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`), AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(submod), addrs.ProviderConfig{Type: "test"}.Absolute(submod),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)

View File

@ -24,7 +24,7 @@ func TestTaint(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -59,7 +59,7 @@ func TestTaint_lockedState(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -245,7 +245,7 @@ func TestTaint_missing(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -278,7 +278,7 @@ func TestTaint_missingAllow(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -354,7 +354,7 @@ func TestTaint_module(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -366,7 +366,7 @@ func TestTaint_module(t *testing.T) {
AttrsJSON: []byte(`{"id":"blah"}`), AttrsJSON: []byte(`{"id":"blah"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)

View File

@ -23,7 +23,7 @@ func TestUntaint(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -63,7 +63,7 @@ func TestUntaint_lockedState(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -271,7 +271,7 @@ func TestUntaint_missing(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -304,7 +304,7 @@ func TestUntaint_missingAllow(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)
@ -389,7 +389,7 @@ func TestUntaint_module(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
addrs.Resource{ addrs.Resource{
@ -401,7 +401,7 @@ func TestUntaint_module(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectTainted, Status: states.ObjectTainted,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
statePath := testStateFile(t, state) statePath := testStateFile(t, state)

View File

@ -241,7 +241,7 @@ func TestWorkspace_createWithState(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })

View File

@ -191,11 +191,11 @@ func (c *Config) gatherProviderTypes(m map[string]struct{}) {
} }
for _, rc := range c.Module.ManagedResources { for _, rc := range c.Module.ManagedResources {
providerAddr := rc.ProviderConfigAddr() providerAddr := rc.ProviderConfigAddr()
m[providerAddr.Type.LegacyString()] = struct{}{} m[providerAddr.Type] = struct{}{}
} }
for _, rc := range c.Module.DataResources { for _, rc := range c.Module.DataResources {
providerAddr := rc.ProviderConfigAddr() providerAddr := rc.ProviderConfigAddr()
m[providerAddr.Type.LegacyString()] = struct{}{} m[providerAddr.Type] = struct{}{}
} }
// Must also visit our child modules, recursively. // Must also visit our child modules, recursively.
@ -203,3 +203,15 @@ func (c *Config) gatherProviderTypes(m map[string]struct{}) {
cc.gatherProviderTypes(m) cc.gatherProviderTypes(m)
} }
} }
// ProviderForConfigAddr returns the FQN for a given addrs.ProviderConfig, first
// by checking for the provider in module.ProviderRequirements and falling
// back to addrs.NewLegacyProvider if it is not found.
//
// TODO: update to addrs.NewDefaultProvider in 0.13
func (c *Config) ProviderForConfigAddr(addr addrs.ProviderConfig) addrs.Provider {
if provider, exists := c.Module.ProviderRequirements[addr.Type]; exists {
return provider.Type
}
return addrs.NewLegacyProvider(addr.Type)
}

View File

@ -96,7 +96,7 @@ func decodeProviderBlock(block *hcl.Block) (*Provider, hcl.Diagnostics) {
// to its containing module. // to its containing module.
func (p *Provider) Addr() addrs.ProviderConfig { func (p *Provider) Addr() addrs.ProviderConfig {
return addrs.ProviderConfig{ return addrs.ProviderConfig{
Type: addrs.NewLegacyProvider(p.Name), Type: p.Name,
Alias: p.Alias, Alias: p.Alias,
} }
} }
@ -123,7 +123,7 @@ func (p *Provider) moduleUniqueKey() string {
func ParseProviderConfigCompact(traversal hcl.Traversal) (addrs.ProviderConfig, tfdiags.Diagnostics) { func ParseProviderConfigCompact(traversal hcl.Traversal) (addrs.ProviderConfig, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics var diags tfdiags.Diagnostics
ret := addrs.ProviderConfig{ ret := addrs.ProviderConfig{
Type: addrs.NewLegacyProvider(traversal.RootName()), Type: traversal.RootName(),
} }
if len(traversal) < 2 { if len(traversal) < 2 {

View File

@ -39,14 +39,14 @@ func TestParseProviderConfigCompact(t *testing.T) {
{ {
`aws`, `aws`,
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}, },
``, ``,
}, },
{ {
`aws.foo`, `aws.foo`,
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
Alias: "foo", Alias: "foo",
}, },
``, ``,

View File

@ -70,7 +70,7 @@ func (r *Resource) ProviderConfigAddr() addrs.ProviderConfig {
} }
return addrs.ProviderConfig{ return addrs.ProviderConfig{
Type: addrs.NewLegacyProvider(r.ProviderConfigRef.Name), Type: r.ProviderConfigRef.Name,
Alias: r.ProviderConfigRef.Alias, Alias: r.ProviderConfigRef.Alias,
} }
} }
@ -447,7 +447,7 @@ func decodeProviderConfigRef(expr hcl.Expression, argName string) (*ProviderConf
// location information and keeping just the addressing information. // location information and keeping just the addressing information.
func (r *ProviderConfigRef) Addr() addrs.ProviderConfig { func (r *ProviderConfigRef) Addr() addrs.ProviderConfig {
return addrs.ProviderConfig{ return addrs.ProviderConfig{
Type: addrs.NewLegacyProvider(r.Name), Type: r.Name,
Alias: r.Alias, Alias: r.Alias,
} }
} }

View File

@ -50,7 +50,7 @@ func shimNewState(newState *states.State, providers map[string]terraform.Resourc
resType := res.Addr.Type resType := res.Addr.Type
providerType := res.ProviderConfig.ProviderConfig.Type providerType := res.ProviderConfig.ProviderConfig.Type
resource := getResource(providers, providerType.LegacyString(), res.Addr) resource := getResource(providers, providerType, res.Addr)
for key, i := range res.Instances { for key, i := range res.Instances {
resState := &terraform.ResourceState{ resState := &terraform.ResourceState{

View File

@ -42,7 +42,7 @@ func TestStateShim(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
rootModule.SetResourceInstanceCurrent( rootModule.SetResourceInstanceCurrent(
@ -57,7 +57,7 @@ func TestStateShim(t *testing.T) {
DependsOn: []addrs.Referenceable{}, DependsOn: []addrs.Referenceable{},
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -75,7 +75,7 @@ func TestStateShim(t *testing.T) {
DependsOn: []addrs.Referenceable{}, DependsOn: []addrs.Referenceable{},
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(childInstance), }.Absolute(childInstance),
) )
childModule.SetResourceInstanceCurrent( childModule.SetResourceInstanceCurrent(
@ -98,7 +98,7 @@ func TestStateShim(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(childInstance), }.Absolute(childInstance),
) )
@ -123,7 +123,7 @@ func TestStateShim(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(childInstance), }.Absolute(childInstance),
) )
@ -139,7 +139,7 @@ func TestStateShim(t *testing.T) {
DependsOn: []addrs.Referenceable{}, DependsOn: []addrs.Referenceable{},
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(childInstance), }.Absolute(childInstance),
) )
childModule.SetResourceInstanceCurrent( childModule.SetResourceInstanceCurrent(
@ -154,7 +154,7 @@ func TestStateShim(t *testing.T) {
DependsOn: []addrs.Referenceable{}, DependsOn: []addrs.Referenceable{},
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(childInstance), }.Absolute(childInstance),
) )
@ -170,7 +170,7 @@ func TestStateShim(t *testing.T) {
DependsOn: []addrs.Referenceable{}, DependsOn: []addrs.Referenceable{},
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(childInstance), }.Absolute(childInstance),
) )

View File

@ -727,7 +727,7 @@ func testIDOnlyRefresh(c TestCase, opts terraform.ContextOpts, step TestStep, r
AttrsFlat: r.Primary.Attributes, AttrsFlat: r.Primary.Attributes,
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("placeholder")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "placeholder"}.Absolute(addrs.RootModuleInstance),
) )
// Create the config module. We use the full config because Refresh // Create the config module. We use the full config because Refresh

View File

@ -137,7 +137,7 @@ func testStepImportState(
// this shouldn't happen in any reasonable case. // this shouldn't happen in any reasonable case.
var rsrcSchema *schema.Resource var rsrcSchema *schema.Resource
if providerAddr, diags := addrs.ParseAbsProviderConfigStr(r.Provider); !diags.HasErrors() { if providerAddr, diags := addrs.ParseAbsProviderConfigStr(r.Provider); !diags.HasErrors() {
providerType := providerAddr.ProviderConfig.Type.LegacyString() providerType := providerAddr.ProviderConfig.Type
if provider, ok := step.providers[providerType]; ok { if provider, ok := step.providers[providerType]; ok {
if provider, ok := provider.(*schema.Provider); ok { if provider, ok := provider.(*schema.Provider); ok {
rsrcSchema = provider.ResourcesMap[r.Type] rsrcSchema = provider.ResourcesMap[r.Type]

View File

@ -21,7 +21,7 @@ func TestProviderAddrs(t *testing.T) {
Name: "woot", Name: "woot",
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance), }.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.ProviderConfig{ ProviderAddr: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
}, },
{ {
@ -32,7 +32,7 @@ func TestProviderAddrs(t *testing.T) {
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance), }.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
DeposedKey: "foodface", DeposedKey: "foodface",
ProviderAddr: addrs.ProviderConfig{ ProviderAddr: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
}, },
{ {
@ -42,7 +42,7 @@ func TestProviderAddrs(t *testing.T) {
Name: "what", Name: "what",
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance), }.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.ProviderConfig{ ProviderAddr: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance.Child("foo", addrs.NoKey)), }.Absolute(addrs.RootModuleInstance.Child("foo", addrs.NoKey)),
}, },
}, },
@ -52,10 +52,10 @@ func TestProviderAddrs(t *testing.T) {
got := plan.ProviderAddrs() got := plan.ProviderAddrs()
want := []addrs.AbsProviderConfig{ want := []addrs.AbsProviderConfig{
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance.Child("foo", addrs.NoKey)), }.Absolute(addrs.RootModuleInstance.Child("foo", addrs.NoKey)),
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
} }

View File

@ -57,7 +57,7 @@ func TestTFPlanRoundTrip(t *testing.T) {
Name: "woot", Name: "woot",
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance), }.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.ProviderConfig{ ProviderAddr: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{
Action: plans.DeleteThenCreate, Action: plans.DeleteThenCreate,
@ -77,7 +77,7 @@ func TestTFPlanRoundTrip(t *testing.T) {
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance), }.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
DeposedKey: "foodface", DeposedKey: "foodface",
ProviderAddr: addrs.ProviderConfig{ ProviderAddr: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{
Action: plans.Delete, Action: plans.Delete,
@ -195,7 +195,7 @@ func TestTFPlanRoundTripDestroy(t *testing.T) {
Name: "woot", Name: "woot",
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance), }.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.ProviderConfig{ ProviderAddr: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{
Action: plans.Delete, Action: plans.Delete,

View File

@ -14,7 +14,7 @@ func AddressedTypes(providerAddrs []addrs.ProviderConfig) []string {
} }
m := map[string]struct{}{} m := map[string]struct{}{}
for _, addr := range providerAddrs { for _, addr := range providerAddrs {
m[addr.Type.LegacyString()] = struct{}{} m[addr.Type] = struct{}{}
} }
names := make([]string, 0, len(m)) names := make([]string, 0, len(m))
@ -34,7 +34,7 @@ func AddressedTypesAbs(providerAddrs []addrs.AbsProviderConfig) []string {
} }
m := map[string]struct{}{} m := map[string]struct{}{}
for _, addr := range providerAddrs { for _, addr := range providerAddrs {
m[addr.ProviderConfig.Type.LegacyString()] = struct{}{} m[addr.ProviderConfig.Type] = struct{}{}
} }
names := make([]string, 0, len(m)) names := make([]string, 0, len(m))

View File

@ -10,11 +10,11 @@ import (
func TestAddressedTypes(t *testing.T) { func TestAddressedTypes(t *testing.T) {
providerAddrs := []addrs.ProviderConfig{ providerAddrs := []addrs.ProviderConfig{
{Type: addrs.NewLegacyProvider("aws")}, {Type: "aws"},
{Type: addrs.NewLegacyProvider("aws"), Alias: "foo"}, {Type: "aws", Alias: "foo"},
{Type: addrs.NewLegacyProvider("azure")}, {Type: "azure"},
{Type: addrs.NewLegacyProvider("null")}, {Type: "null"},
{Type: addrs.NewLegacyProvider("null")}, {Type: "null"},
} }
got := AddressedTypes(providerAddrs) got := AddressedTypes(providerAddrs)
@ -30,11 +30,11 @@ func TestAddressedTypes(t *testing.T) {
func TestAddressedTypesAbs(t *testing.T) { func TestAddressedTypesAbs(t *testing.T) {
providerAddrs := []addrs.AbsProviderConfig{ providerAddrs := []addrs.AbsProviderConfig{
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("aws")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "aws"}.Absolute(addrs.RootModuleInstance),
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("aws"), Alias: "foo"}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "aws", Alias: "foo"}.Absolute(addrs.RootModuleInstance),
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("azure")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "azure"}.Absolute(addrs.RootModuleInstance),
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("null")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "null"}.Absolute(addrs.RootModuleInstance),
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("null")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "null"}.Absolute(addrs.RootModuleInstance),
} }
got := AddressedTypesAbs(providerAddrs) got := AddressedTypesAbs(providerAddrs)

View File

@ -46,7 +46,7 @@ func TestSession_basicState(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
@ -60,7 +60,7 @@ func TestSession_basicState(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`), AttrsJSON: []byte(`{"id":"bar"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}) })

View File

@ -36,7 +36,7 @@ func TestState(t *testing.T) {
AttrsJSON: []byte(`{"woozles":"confuzles"}`), AttrsJSON: []byte(`{"woozles":"confuzles"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -79,7 +79,7 @@ func TestState(t *testing.T) {
}, },
}, },
ProviderConfig: addrs.ProviderConfig{ ProviderConfig: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
}, },
}, },
@ -141,7 +141,7 @@ func TestStateDeepCopy(t *testing.T) {
Dependencies: []addrs.AbsResource{}, Dependencies: []addrs.AbsResource{},
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
rootModule.SetResourceInstanceCurrent( rootModule.SetResourceInstanceCurrent(
@ -167,7 +167,7 @@ func TestStateDeepCopy(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )

View File

@ -1371,7 +1371,7 @@ func TestContext2Apply_destroyDependsOnStateOnly(t *testing.T) {
Dependencies: []addrs.AbsResource{}, Dependencies: []addrs.AbsResource{},
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
root.SetResourceInstanceCurrent( root.SetResourceInstanceCurrent(
@ -1395,7 +1395,7 @@ func TestContext2Apply_destroyDependsOnStateOnly(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -1498,7 +1498,7 @@ func TestContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) {
Dependencies: []addrs.AbsResource{}, Dependencies: []addrs.AbsResource{},
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
child.SetResourceInstanceCurrent( child.SetResourceInstanceCurrent(
@ -1522,7 +1522,7 @@ func TestContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -2145,7 +2145,7 @@ func TestContext2Apply_provisionerDestroyForEach(t *testing.T) {
}, },
ProviderConfig: addrs.AbsProviderConfig{ ProviderConfig: addrs.AbsProviderConfig{
Module: addrs.ModuleInstance(nil), Module: addrs.ModuleInstance(nil),
ProviderConfig: addrs.ProviderConfig{Type: addrs.NewLegacyProvider("aws"), Alias: ""}, ProviderConfig: addrs.ProviderConfig{Type: "aws", Alias: ""},
}, },
}, },
}, },
@ -2966,7 +2966,7 @@ func TestContext2Apply_orphanResource(t *testing.T) {
// with the single instance associated with test_thing.one. // with the single instance associated with test_thing.one.
want := states.BuildState(func(s *states.SyncState) { want := states.BuildState(func(s *states.SyncState) {
providerAddr := addrs.ProviderConfig{ providerAddr := addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance) }.Absolute(addrs.RootModuleInstance)
zeroAddr := addrs.Resource{ zeroAddr := addrs.Resource{
Mode: addrs.ManagedResourceMode, Mode: addrs.ManagedResourceMode,
@ -7391,7 +7391,7 @@ func TestContext2Apply_errorDestroy(t *testing.T) {
AttrsJSON: []byte(`{"id":"baz"}`), AttrsJSON: []byte(`{"id":"baz"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}), }),
@ -7530,7 +7530,7 @@ func TestContext2Apply_errorUpdateNullNew(t *testing.T) {
AttrsJSON: []byte(`{"value":"old"}`), AttrsJSON: []byte(`{"value":"old"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}), }),
@ -9193,7 +9193,7 @@ func TestContext2Apply_createBefore_depends(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","require_new":"ami-old"}`), AttrsJSON: []byte(`{"id":"bar","require_new":"ami-old"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -9218,7 +9218,7 @@ func TestContext2Apply_createBefore_depends(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -9324,7 +9324,7 @@ func TestContext2Apply_singleDestroy(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","require_new":"ami-old"}`), AttrsJSON: []byte(`{"id":"bar","require_new":"ami-old"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -9349,7 +9349,7 @@ func TestContext2Apply_singleDestroy(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -10267,7 +10267,7 @@ func TestContext2Apply_destroyWithProviders(t *testing.T) {
// correct the state // correct the state
s.Modules["module.mod.module.removed"].Resources["aws_instance.child"].ProviderConfig = addrs.ProviderConfig{ s.Modules["module.mod.module.removed"].Resources["aws_instance.child"].ProviderConfig = addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
Alias: "bar", Alias: "bar",
}.Absolute(addrs.RootModuleInstance) }.Absolute(addrs.RootModuleInstance)
@ -10691,7 +10691,7 @@ func TestContext2Apply_issue19908(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}), }),
@ -10818,7 +10818,7 @@ func TestContext2Apply_moduleReplaceCycle(t *testing.T) {
AttrsJSON: []byte(`{"id":"a","require_new":"old"}`), AttrsJSON: []byte(`{"id":"a","require_new":"old"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -10834,7 +10834,7 @@ func TestContext2Apply_moduleReplaceCycle(t *testing.T) {
AttrsJSON: []byte(`{"id":"b","require_new":"old"}`), AttrsJSON: []byte(`{"id":"b","require_new":"old"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -10876,7 +10876,7 @@ func TestContext2Apply_moduleReplaceCycle(t *testing.T) {
Name: "a", Name: "a",
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance.Child("a", addrs.NoKey)), }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance.Child("a", addrs.NoKey)),
ProviderAddr: addrs.ProviderConfig{ ProviderAddr: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{
Action: aAction, Action: aAction,
@ -10891,7 +10891,7 @@ func TestContext2Apply_moduleReplaceCycle(t *testing.T) {
Name: "b", Name: "b",
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance.Child("b", addrs.NoKey)), }.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance.Child("b", addrs.NoKey)),
ProviderAddr: addrs.ProviderConfig{ ProviderAddr: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{
Action: plans.DeleteThenCreate, Action: plans.DeleteThenCreate,
@ -10941,7 +10941,7 @@ func TestContext2Apply_destroyDataCycle(t *testing.T) {
AttrsJSON: []byte(`{"id":"a"}`), AttrsJSON: []byte(`{"id":"a"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("null"), Type: "null",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
root.SetResourceInstanceCurrent( root.SetResourceInstanceCurrent(
@ -10955,7 +10955,7 @@ func TestContext2Apply_destroyDataCycle(t *testing.T) {
AttrsJSON: []byte(`{"id":"data"}`), AttrsJSON: []byte(`{"id":"data"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("null"), Type: "null",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -11029,7 +11029,7 @@ func TestContext2Apply_taintedDestroyFailure(t *testing.T) {
AttrsJSON: []byte(`{"id":"a","foo":"a"}`), AttrsJSON: []byte(`{"id":"a","foo":"a"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
root.SetResourceInstanceCurrent( root.SetResourceInstanceCurrent(
@ -11043,7 +11043,7 @@ func TestContext2Apply_taintedDestroyFailure(t *testing.T) {
AttrsJSON: []byte(`{"id":"b","foo":"b"}`), AttrsJSON: []byte(`{"id":"b","foo":"b"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
root.SetResourceInstanceCurrent( root.SetResourceInstanceCurrent(
@ -11057,7 +11057,7 @@ func TestContext2Apply_taintedDestroyFailure(t *testing.T) {
AttrsJSON: []byte(`{"id":"c","foo":"old"}`), AttrsJSON: []byte(`{"id":"c","foo":"old"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -11233,7 +11233,7 @@ func TestContext2Apply_cbdCycle(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
root.SetResourceInstanceCurrent( root.SetResourceInstanceCurrent(
@ -11257,7 +11257,7 @@ func TestContext2Apply_cbdCycle(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
root.SetResourceInstanceCurrent( root.SetResourceInstanceCurrent(
@ -11271,7 +11271,7 @@ func TestContext2Apply_cbdCycle(t *testing.T) {
AttrsJSON: []byte(`{"id":"c","require_new":"old"}`), AttrsJSON: []byte(`{"id":"c","require_new":"old"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )

View File

@ -115,7 +115,7 @@ func TestContextImport_collision(t *testing.T) {
}, },
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("aws")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "aws"}.Absolute(addrs.RootModuleInstance),
) )
}), }),
}) })
@ -601,7 +601,7 @@ func TestContextImport_moduleDiff(t *testing.T) {
}, },
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("aws")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "aws"}.Absolute(addrs.RootModuleInstance),
) )
}), }),
}) })
@ -659,7 +659,7 @@ func TestContextImport_moduleExisting(t *testing.T) {
}, },
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("aws")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "aws"}.Absolute(addrs.RootModuleInstance),
) )
}), }),
}) })

View File

@ -96,7 +96,7 @@ func (c *Context) Input(mode InputMode) tfdiags.Diagnostics {
UIInput: c.uiInput, UIInput: c.uiInput,
} }
schema := c.schemas.ProviderConfig(pa.Type.LegacyString()) schema := c.schemas.ProviderConfig(pa.Type)
if schema == nil { if schema == nil {
// Could either be an incorrect config or just an incomplete // Could either be an incorrect config or just an incomplete
// mock in tests. We'll let a later pass decide, and just // mock in tests. We'll let a later pass decide, and just

View File

@ -478,7 +478,7 @@ func TestContext2Input_dataSourceRequiresRefresh(t *testing.T) {
}, },
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("null")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "null"}.Absolute(addrs.RootModuleInstance),
) )
}) })

View File

@ -4976,7 +4976,7 @@ func TestContext2Plan_ignoreChangesInMap(t *testing.T) {
AttrsJSON: []byte(`{"tags":{"ignored":"from state","other":"from state"}}`), AttrsJSON: []byte(`{"tags":{"ignored":"from state","other":"from state"}}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}) })

View File

@ -104,7 +104,7 @@ func TestContext2Refresh_dynamicAttr(t *testing.T) {
AttrsJSON: []byte(`{"dynamic":{"type":"string","value":"hello"}}`), AttrsJSON: []byte(`{"dynamic":{"type":"string","value":"hello"}}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}) })
@ -1739,7 +1739,7 @@ func TestContext2Refresh_schemaUpgradeFlatmap(t *testing.T) {
"id": "foo", "id": "foo",
}, },
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
@ -1822,7 +1822,7 @@ func TestContext2Refresh_schemaUpgradeJSON(t *testing.T) {
SchemaVersion: 3, SchemaVersion: 3,
AttrsJSON: []byte(`{"id":"foo"}`), AttrsJSON: []byte(`{"id":"foo"}`),
}, },
addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")}.Absolute(addrs.RootModuleInstance), addrs.ProviderConfig{Type: "test"}.Absolute(addrs.RootModuleInstance),
) )
}) })
@ -1991,7 +1991,7 @@ func TestRefresh_updateDependencies(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
root.SetResourceInstanceCurrent( root.SetResourceInstanceCurrent(
@ -2005,7 +2005,7 @@ func TestRefresh_updateDependencies(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar","foo":"foo"}`), AttrsJSON: []byte(`{"id":"bar","foo":"foo"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )

View File

@ -142,7 +142,7 @@ func (ctx *BuiltinEvalContext) Provider(addr addrs.AbsProviderConfig) providers.
func (ctx *BuiltinEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) *ProviderSchema { func (ctx *BuiltinEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) *ProviderSchema {
ctx.once.Do(ctx.init) ctx.once.Do(ctx.init)
return ctx.Schemas.ProviderSchema(addr.ProviderConfig.Type.LegacyString()) return ctx.Schemas.ProviderSchema(addr.ProviderConfig.Type)
} }
func (ctx *BuiltinEvalContext) CloseProvider(addr addrs.ProviderConfig) error { func (ctx *BuiltinEvalContext) CloseProvider(addr addrs.ProviderConfig) error {

View File

@ -24,7 +24,7 @@ func TestBuiltinEvalContextProviderInput(t *testing.T) {
ctx2.ProviderInputConfig = cache ctx2.ProviderInputConfig = cache
ctx2.ProviderLock = &lock ctx2.ProviderLock = &lock
providerAddr := addrs.ProviderConfig{Type: addrs.NewLegacyProvider("foo")} providerAddr := addrs.ProviderConfig{Type: "foo"}
expected1 := map[string]cty.Value{"value": cty.StringVal("foo")} expected1 := map[string]cty.Value{"value": cty.StringVal("foo")}
ctx1.SetProviderInput(providerAddr, expected1) ctx1.SetProviderInput(providerAddr, expected1)
@ -57,8 +57,8 @@ func TestBuildingEvalContextInitProvider(t *testing.T) {
}, },
} }
providerAddrDefault := addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test")} providerAddrDefault := addrs.ProviderConfig{Type: "test"}
providerAddrAlias := addrs.ProviderConfig{Type: addrs.NewLegacyProvider("test"), Alias: "foo"} providerAddrAlias := addrs.ProviderConfig{Type: "test", Alias: "foo"}
_, err := ctx.InitProvider("test", providerAddrDefault) _, err := ctx.InitProvider("test", providerAddrDefault)
if err != nil { if err != nil {

View File

@ -120,7 +120,7 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) {
if providerSchema == nil { if providerSchema == nil {
return nil, fmt.Errorf("provider schema is unavailable for %s", n.Addr) return nil, fmt.Errorf("provider schema is unavailable for %s", n.Addr)
} }
if n.ProviderAddr.ProviderConfig.Type.LegacyString() == "" { if n.ProviderAddr.ProviderConfig.Type == "" {
panic(fmt.Sprintf("EvalDiff for %s does not have ProviderAddr set", n.Addr.Absolute(ctx.Path()))) panic(fmt.Sprintf("EvalDiff for %s does not have ProviderAddr set", n.Addr.Absolute(ctx.Path())))
} }
@ -603,7 +603,7 @@ func (n *EvalDiffDestroy) Eval(ctx EvalContext) (interface{}, error) {
absAddr := n.Addr.Absolute(ctx.Path()) absAddr := n.Addr.Absolute(ctx.Path())
state := *n.State state := *n.State
if n.ProviderAddr.ProviderConfig.Type.LegacyString() == "" { if n.ProviderAddr.ProviderConfig.Type == "" {
if n.DeposedKey == "" { if n.DeposedKey == "" {
panic(fmt.Sprintf("EvalDiffDestroy for %s does not have ProviderAddr set", absAddr)) panic(fmt.Sprintf("EvalDiffDestroy for %s does not have ProviderAddr set", absAddr))
} else { } else {

View File

@ -125,7 +125,7 @@ type EvalGetProvider struct {
} }
func (n *EvalGetProvider) Eval(ctx EvalContext) (interface{}, error) { func (n *EvalGetProvider) Eval(ctx EvalContext) (interface{}, error) {
if n.Addr.ProviderConfig.Type.LegacyString() == "" { if n.Addr.ProviderConfig.Type == "" {
// Should never happen // Should never happen
panic("EvalGetProvider used with uninitialized provider configuration address") panic("EvalGetProvider used with uninitialized provider configuration address")
} }

View File

@ -17,7 +17,7 @@ func TestBuildProviderConfig(t *testing.T) {
"set_in_config": cty.StringVal("config"), "set_in_config": cty.StringVal("config"),
}) })
providerAddr := addrs.ProviderConfig{ providerAddr := addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("foo"), Type: "foo",
} }
ctx := &MockEvalContext{ ctx := &MockEvalContext{
@ -68,7 +68,7 @@ func TestEvalConfigProvider(t *testing.T) {
provider := mockProviderWithConfigSchema(simpleTestSchema()) provider := mockProviderWithConfigSchema(simpleTestSchema())
rp := providers.Interface(provider) rp := providers.Interface(provider)
n := &EvalConfigProvider{ n := &EvalConfigProvider{
Addr: addrs.ProviderConfig{Type: addrs.NewLegacyProvider("foo")}, Addr: addrs.ProviderConfig{Type: "foo"},
Config: config, Config: config,
Provider: &rp, Provider: &rp,
} }
@ -98,7 +98,7 @@ func TestEvalInitProvider_impl(t *testing.T) {
func TestEvalInitProvider(t *testing.T) { func TestEvalInitProvider(t *testing.T) {
n := &EvalInitProvider{ n := &EvalInitProvider{
Addr: addrs.ProviderConfig{Type: addrs.NewLegacyProvider("foo")}, Addr: addrs.ProviderConfig{Type: "foo"},
} }
provider := &MockProvider{} provider := &MockProvider{}
ctx := &MockEvalContext{InitProviderProvider: provider} ctx := &MockEvalContext{InitProviderProvider: provider}
@ -116,7 +116,7 @@ func TestEvalInitProvider(t *testing.T) {
func TestEvalCloseProvider(t *testing.T) { func TestEvalCloseProvider(t *testing.T) {
n := &EvalCloseProvider{ n := &EvalCloseProvider{
Addr: addrs.ProviderConfig{Type: addrs.NewLegacyProvider("foo")}, Addr: addrs.ProviderConfig{Type: "foo"},
} }
provider := &MockProvider{} provider := &MockProvider{}
ctx := &MockEvalContext{CloseProviderProvider: provider} ctx := &MockEvalContext{CloseProviderProvider: provider}

View File

@ -218,7 +218,7 @@ func (n *EvalWriteState) Eval(ctx EvalContext) (interface{}, error) {
absAddr := n.Addr.Absolute(ctx.Path()) absAddr := n.Addr.Absolute(ctx.Path())
state := ctx.State() state := ctx.State()
if n.ProviderAddr.ProviderConfig.Type.LegacyString() == "" { if n.ProviderAddr.ProviderConfig.Type == "" {
return nil, fmt.Errorf("failed to write state for %s, missing provider type", absAddr) return nil, fmt.Errorf("failed to write state for %s, missing provider type", absAddr)
} }
obj := *n.State obj := *n.State

View File

@ -16,7 +16,7 @@ func ProviderEvalTree(n *NodeApplyableProvider, config *configs.Provider) EvalNo
seq := make([]EvalNode, 0, 5) seq := make([]EvalNode, 0, 5)
seq = append(seq, &EvalInitProvider{ seq = append(seq, &EvalInitProvider{
TypeName: relAddr.Type.LegacyString(), TypeName: relAddr.Type,
Addr: addr.ProviderConfig, Addr: addr.ProviderConfig,
}) })

View File

@ -779,7 +779,7 @@ func (d *evaluationStateData) getResourceInstancesAll(addr addrs.Resource, rng t
} }
func (d *evaluationStateData) getResourceSchema(addr addrs.Resource, providerAddr addrs.AbsProviderConfig) *configschema.Block { func (d *evaluationStateData) getResourceSchema(addr addrs.Resource, providerAddr addrs.AbsProviderConfig) *configschema.Block {
providerType := providerAddr.ProviderConfig.Type.LegacyString() providerType := providerAddr.ProviderConfig.Type
schemas := d.Evaluator.Schemas schemas := d.Evaluator.Schemas
schema, _ := schemas.ResourceTypeConfig(providerType, addr.Mode, addr.Type) schema, _ := schemas.ResourceTypeConfig(providerType, addr.Mode, addr.Type)
return schema return schema

View File

@ -215,7 +215,7 @@ func (d *evaluationStateData) staticValidateResourceReference(modCfg *configs.Co
// Normally accessing this directly is wrong because it doesn't take into // Normally accessing this directly is wrong because it doesn't take into
// account provider inheritance, etc but it's okay here because we're only // account provider inheritance, etc but it's okay here because we're only
// paying attention to the type anyway. // paying attention to the type anyway.
providerType := cfg.ProviderConfigAddr().Type.LegacyString() providerType := cfg.ProviderConfigAddr().Type
schema, _ := d.Evaluator.Schemas.ResourceTypeConfig(providerType, addr.Mode, addr.Type) schema, _ := d.Evaluator.Schemas.ResourceTypeConfig(providerType, addr.Mode, addr.Type)
if schema == nil { if schema == nil {

View File

@ -545,7 +545,7 @@ func TestApplyGraphBuilder_updateFromOrphan(t *testing.T) {
AttrsJSON: []byte(`{"id":"a_id"}`), AttrsJSON: []byte(`{"id":"a_id"}`),
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
root.SetResourceInstanceCurrent( root.SetResourceInstanceCurrent(
@ -569,7 +569,7 @@ func TestApplyGraphBuilder_updateFromOrphan(t *testing.T) {
}, },
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("test"), Type: "test",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )

View File

@ -130,7 +130,7 @@ func TestNodeRefreshableDataResourceDynamicExpand_scaleIn(t *testing.T) {
Config: m.Module.DataResources["data.aws_instance.foo"], Config: m.Module.DataResources["data.aws_instance.foo"],
ResolvedProvider: addrs.AbsProviderConfig{ ResolvedProvider: addrs.AbsProviderConfig{
ProviderConfig: addrs.ProviderConfig{ ProviderConfig: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}, },
}, },
}, },
@ -174,7 +174,7 @@ root - terraform.graphNodeRoot
t.Fatal("failed to find a destroyableDataResource") t.Fatal("failed to find a destroyableDataResource")
} }
if destroyableDataResource.ResolvedProvider.ProviderConfig.Type.LegacyString() == "" { if destroyableDataResource.ResolvedProvider.ProviderConfig.Type == "" {
t.Fatal("NodeDestroyableDataResourceInstance missing provider config") t.Fatal("NodeDestroyableDataResourceInstance missing provider config")
} }
} }

View File

@ -14,7 +14,7 @@ func (n *NodeEvalableProvider) EvalTree() EvalNode {
relAddr := addr.ProviderConfig relAddr := addr.ProviderConfig
return &EvalInitProvider{ return &EvalInitProvider{
TypeName: relAddr.Type.LegacyString(), TypeName: relAddr.Type,
Addr: addr.ProviderConfig, Addr: addr.ProviderConfig,
} }
} }

View File

@ -47,7 +47,7 @@ func (n *NodePlanDestroyableResourceInstance) EvalTree() EvalNode {
var change *plans.ResourceInstanceChange var change *plans.ResourceInstanceChange
var state *states.ResourceInstanceObject var state *states.ResourceInstanceObject
if n.ResolvedProvider.ProviderConfig.Type.String() == "" { if n.ResolvedProvider.ProviderConfig.Type == "" {
// Should never happen; indicates that the graph was not constructed // Should never happen; indicates that the graph was not constructed
// correctly since we didn't get our provider attached. // correctly since we didn't get our provider attached.
panic(fmt.Sprintf("%T %q was not assigned a resolved provider", n, dag.VertexName(n))) panic(fmt.Sprintf("%T %q was not assigned a resolved provider", n, dag.VertexName(n)))

View File

@ -59,7 +59,7 @@ func (t *AttachSchemaTransformer) Transform(g *Graph) error {
mode := addr.Resource.Mode mode := addr.Resource.Mode
typeName := addr.Resource.Type typeName := addr.Resource.Type
providerAddr, _ := tv.ProvidedBy() providerAddr, _ := tv.ProvidedBy()
providerType := providerAddr.ProviderConfig.Type.LegacyString() providerType := providerAddr.ProviderConfig.Type
schema, version := t.Schemas.ResourceTypeConfig(providerType, mode, typeName) schema, version := t.Schemas.ResourceTypeConfig(providerType, mode, typeName)
if schema == nil { if schema == nil {
@ -72,7 +72,7 @@ func (t *AttachSchemaTransformer) Transform(g *Graph) error {
if tv, ok := v.(GraphNodeAttachProviderConfigSchema); ok { if tv, ok := v.(GraphNodeAttachProviderConfigSchema); ok {
providerAddr := tv.ProviderAddr() providerAddr := tv.ProviderAddr()
schema := t.Schemas.ProviderConfig(providerAddr.ProviderConfig.Type.LegacyString()) schema := t.Schemas.ProviderConfig(providerAddr.ProviderConfig.Type)
if schema == nil { if schema == nil {
log.Printf("[ERROR] AttachSchemaTransformer: No provider config schema available for %s", providerAddr) log.Printf("[ERROR] AttachSchemaTransformer: No provider config schema available for %s", providerAddr)
continue continue

View File

@ -44,7 +44,7 @@ func TestDiffTransformer(t *testing.T) {
Name: "foo", Name: "foo",
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance), }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
ProviderAddr: addrs.ProviderConfig{ ProviderAddr: addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{ ChangeSrc: plans.ChangeSrc{
Action: plans.Update, Action: plans.Update,

View File

@ -20,7 +20,7 @@ func (t *ImportStateTransformer) Transform(g *Graph) error {
// This will be populated if the targets come from the cli, but tests // This will be populated if the targets come from the cli, but tests
// may not specify implied provider addresses. // may not specify implied provider addresses.
providerAddr := target.ProviderAddr providerAddr := target.ProviderAddr
if providerAddr.ProviderConfig.Type.Type == "" { if providerAddr.ProviderConfig.Type == "" {
providerAddr = target.Addr.Resource.Resource.DefaultProviderConfig().Absolute(target.Addr.Module) providerAddr = target.Addr.Resource.Resource.DefaultProviderConfig().Absolute(target.Addr.Module)
} }

View File

@ -353,7 +353,7 @@ func TestOrphanResourceCountTransformer_ForEachEdgesAdded(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -371,7 +371,7 @@ func TestOrphanResourceCountTransformer_ForEachEdgesAdded(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}) })

View File

@ -27,7 +27,7 @@ func TestOrphanResourceInstanceTransformer(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
@ -45,7 +45,7 @@ func TestOrphanResourceInstanceTransformer(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}) })
@ -93,7 +93,7 @@ func TestOrphanResourceInstanceTransformer_countGood(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
@ -109,7 +109,7 @@ func TestOrphanResourceInstanceTransformer_countGood(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}) })
@ -156,7 +156,7 @@ func TestOrphanResourceInstanceTransformer_countBad(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
@ -172,7 +172,7 @@ func TestOrphanResourceInstanceTransformer_countBad(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}) })
@ -219,7 +219,7 @@ func TestOrphanResourceInstanceTransformer_modules(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
@ -235,7 +235,7 @@ func TestOrphanResourceInstanceTransformer_modules(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}) })

View File

@ -309,7 +309,7 @@ func (t *MissingProviderTransformer) Transform(g *Graph) error {
// We're going to create an implicit _default_ configuration for the // We're going to create an implicit _default_ configuration for the
// referenced provider type in the _root_ module, ignoring all other // referenced provider type in the _root_ module, ignoring all other
// aspects of the resource's declared provider address. // aspects of the resource's declared provider address.
defaultAddr := addrs.RootModuleInstance.ProviderConfigDefault(p.ProviderConfig.Type.LegacyString()) defaultAddr := addrs.RootModuleInstance.ProviderConfigDefault(p.ProviderConfig.Type)
key := defaultAddr.String() key := defaultAddr.String()
provider := m[key] provider := m[key]
@ -719,7 +719,7 @@ func (t *ProviderConfigTransformer) attachProviderConfigs(g *Graph) error {
// Go through the provider configs to find the matching config // Go through the provider configs to find the matching config
for _, p := range mc.Module.ProviderConfigs { for _, p := range mc.Module.ProviderConfigs {
if p.Name == addr.ProviderConfig.Type.LegacyString() && p.Alias == addr.ProviderConfig.Alias { if p.Name == addr.ProviderConfig.Type && p.Alias == addr.ProviderConfig.Alias {
log.Printf("[TRACE] ProviderConfigTransformer: attaching to %q provider configuration from %s", dag.VertexName(v), p.DeclRange) log.Printf("[TRACE] ProviderConfigTransformer: attaching to %q provider configuration from %s", dag.VertexName(v), p.DeclRange)
apn.AttachProvider(p) apn.AttachProvider(p)
break break

View File

@ -71,7 +71,7 @@ func TestMissingProvisionerTransformer_module(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
s.SetResourceInstanceCurrent( s.SetResourceInstanceCurrent(
@ -87,7 +87,7 @@ func TestMissingProvisionerTransformer_module(t *testing.T) {
Status: states.ObjectReady, Status: states.ObjectReady,
}, },
addrs.ProviderConfig{ addrs.ProviderConfig{
Type: addrs.NewLegacyProvider("aws"), Type: "aws",
}.Absolute(addrs.RootModuleInstance), }.Absolute(addrs.RootModuleInstance),
) )
}) })