Merge pull request #24346 from hashicorp/jbardin/module-expansion-another-part
Continue pushing the Path calls out of the Resource and Provider types
This commit is contained in:
commit
33464568e8
|
@ -2,6 +2,7 @@ package addrs
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform/tfdiags"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
|
@ -86,7 +87,7 @@ func (pc LocalProviderConfig) StringCompact() string {
|
|||
// AbsProviderConfig is the absolute address of a provider configuration
|
||||
// within a particular module instance.
|
||||
type AbsProviderConfig struct {
|
||||
Module ModuleInstance
|
||||
Module Module
|
||||
Provider Provider
|
||||
Alias string
|
||||
}
|
||||
|
@ -101,7 +102,6 @@ var _ ProviderConfig = AbsProviderConfig{}
|
|||
// provider["registry.terraform.io/hashicorp/aws"].foo
|
||||
// module.bar.provider["registry.terraform.io/hashicorp/aws"]
|
||||
// module.bar.module.baz.provider["registry.terraform.io/hashicorp/aws"].foo
|
||||
// module.foo[1].provider["registry.terraform.io/hashicorp/aws"].foo
|
||||
//
|
||||
// This type of address is used, for example, to record the relationships
|
||||
// between resources and provider configurations in the state structure.
|
||||
|
@ -109,9 +109,23 @@ var _ ProviderConfig = AbsProviderConfig{}
|
|||
// messages that refer to provider configurations.
|
||||
func ParseAbsProviderConfig(traversal hcl.Traversal) (AbsProviderConfig, tfdiags.Diagnostics) {
|
||||
modInst, remain, diags := parseModuleInstancePrefix(traversal)
|
||||
ret := AbsProviderConfig{
|
||||
Module: modInst,
|
||||
var ret AbsProviderConfig
|
||||
|
||||
// Providers cannot resolve within module instances, so verify that there
|
||||
// are no instance keys in the module path before converting to a Module.
|
||||
for _, step := range modInst {
|
||||
if step.InstanceKey != NoKey {
|
||||
diags = diags.Append(&hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
Summary: "Invalid provider configuration address",
|
||||
Detail: "Provider address cannot contain module indexes",
|
||||
Subject: remain.SourceRange().Ptr(),
|
||||
})
|
||||
return ret, diags
|
||||
}
|
||||
}
|
||||
ret.Module = modInst.Module()
|
||||
|
||||
if len(remain) < 2 || remain.RootName() != "provider" {
|
||||
diags = diags.Append(&hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
|
@ -223,16 +237,28 @@ func ParseLegacyAbsProviderConfigStr(str string) (AbsProviderConfig, tfdiags.Dia
|
|||
// provider.aws.foo
|
||||
// module.bar.provider.aws
|
||||
// module.bar.module.baz.provider.aws.foo
|
||||
// module.foo[1].provider.aws.foo
|
||||
//
|
||||
// This type of address is used in legacy state and may appear in state v4 if
|
||||
// the provider config addresses have not been normalized to include provider
|
||||
// FQN.
|
||||
func ParseLegacyAbsProviderConfig(traversal hcl.Traversal) (AbsProviderConfig, tfdiags.Diagnostics) {
|
||||
modInst, remain, diags := parseModuleInstancePrefix(traversal)
|
||||
ret := AbsProviderConfig{
|
||||
Module: modInst,
|
||||
var ret AbsProviderConfig
|
||||
|
||||
// Providers cannot resolve within module instances, so verify that there
|
||||
// are no instance keys in the module path before converting to a Module.
|
||||
for _, step := range modInst {
|
||||
if step.InstanceKey != NoKey {
|
||||
diags = diags.Append(&hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
Summary: "Invalid provider configuration address",
|
||||
Detail: "Provider address cannot contain module indexes",
|
||||
Subject: remain.SourceRange().Ptr(),
|
||||
})
|
||||
return ret, diags
|
||||
}
|
||||
}
|
||||
ret.Module = modInst.Module()
|
||||
|
||||
if len(remain) < 2 || remain.RootName() != "provider" {
|
||||
diags = diags.Append(&hcl.Diagnostic{
|
||||
|
@ -287,7 +313,7 @@ func ParseLegacyAbsProviderConfig(traversal hcl.Traversal) (AbsProviderConfig, t
|
|||
// the given type inside the recieving module instance.
|
||||
func (m ModuleInstance) ProviderConfigDefault(provider Provider) AbsProviderConfig {
|
||||
return AbsProviderConfig{
|
||||
Module: m,
|
||||
Module: m.Module(),
|
||||
Provider: provider,
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +322,7 @@ func (m ModuleInstance) ProviderConfigDefault(provider Provider) AbsProviderConf
|
|||
// the given type and alias inside the recieving module instance.
|
||||
func (m ModuleInstance) ProviderConfigAliased(provider Provider, alias string) AbsProviderConfig {
|
||||
return AbsProviderConfig{
|
||||
Module: m,
|
||||
Module: m.Module(),
|
||||
Provider: provider,
|
||||
Alias: alias,
|
||||
}
|
||||
|
@ -359,16 +385,16 @@ func (pc AbsProviderConfig) LegacyString() string {
|
|||
// module.module-name.provider["example.com/namespace/name"]
|
||||
// module.module-name.provider["example.com/namespace/name"].alias
|
||||
func (pc AbsProviderConfig) String() string {
|
||||
if pc.Alias != "" {
|
||||
if len(pc.Module) == 0 {
|
||||
return fmt.Sprintf("%s[%q].%s", "provider", pc.Provider.String(), pc.Alias)
|
||||
} else {
|
||||
return fmt.Sprintf("%s.%s[%q].%s", pc.Module.String(), "provider", pc.Provider.String(), pc.Alias)
|
||||
}
|
||||
}
|
||||
if len(pc.Module) == 0 {
|
||||
return fmt.Sprintf("%s[%q]", "provider", pc.Provider.String())
|
||||
var parts []string
|
||||
if len(pc.Module) > 0 {
|
||||
parts = append(parts, pc.Module.String())
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s.%s[%q]", pc.Module.String(), "provider", pc.Provider.String())
|
||||
parts = append(parts, fmt.Sprintf("provider[%q]", pc.Provider))
|
||||
|
||||
if pc.Alias != "" {
|
||||
parts = append(parts, pc.Alias)
|
||||
}
|
||||
|
||||
return strings.Join(parts, ".")
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
|
|||
{
|
||||
`provider["registry.terraform.io/hashicorp/aws"]`,
|
||||
AbsProviderConfig{
|
||||
Module: RootModuleInstance,
|
||||
Module: RootModule,
|
||||
Provider: Provider{
|
||||
Type: "aws",
|
||||
Namespace: "hashicorp",
|
||||
|
@ -30,7 +30,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
|
|||
{
|
||||
`provider["registry.terraform.io/hashicorp/aws"].foo`,
|
||||
AbsProviderConfig{
|
||||
Module: RootModuleInstance,
|
||||
Module: RootModule,
|
||||
Provider: Provider{
|
||||
Type: "aws",
|
||||
Namespace: "hashicorp",
|
||||
|
@ -43,11 +43,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
|
|||
{
|
||||
`module.baz.provider["registry.terraform.io/hashicorp/aws"]`,
|
||||
AbsProviderConfig{
|
||||
Module: ModuleInstance{
|
||||
{
|
||||
Name: "baz",
|
||||
},
|
||||
},
|
||||
Module: Module{"baz"},
|
||||
Provider: Provider{
|
||||
Type: "aws",
|
||||
Namespace: "hashicorp",
|
||||
|
@ -59,11 +55,7 @@ func TestParseAbsProviderConfig(t *testing.T) {
|
|||
{
|
||||
`module.baz.provider["registry.terraform.io/hashicorp/aws"].foo`,
|
||||
AbsProviderConfig{
|
||||
Module: ModuleInstance{
|
||||
{
|
||||
Name: "baz",
|
||||
},
|
||||
},
|
||||
Module: Module{"baz"},
|
||||
Provider: Provider{
|
||||
Type: "aws",
|
||||
Namespace: "hashicorp",
|
||||
|
@ -75,57 +67,18 @@ func TestParseAbsProviderConfig(t *testing.T) {
|
|||
},
|
||||
{
|
||||
`module.baz["foo"].provider["registry.terraform.io/hashicorp/aws"]`,
|
||||
AbsProviderConfig{
|
||||
Module: ModuleInstance{
|
||||
{
|
||||
Name: "baz",
|
||||
InstanceKey: StringKey("foo"),
|
||||
},
|
||||
},
|
||||
Provider: Provider{
|
||||
Type: "aws",
|
||||
Namespace: "hashicorp",
|
||||
Hostname: "registry.terraform.io",
|
||||
},
|
||||
},
|
||||
``,
|
||||
AbsProviderConfig{},
|
||||
`Provider address cannot contain module indexes`,
|
||||
},
|
||||
{
|
||||
`module.baz[1].provider["registry.terraform.io/hashicorp/aws"]`,
|
||||
AbsProviderConfig{
|
||||
Module: ModuleInstance{
|
||||
{
|
||||
Name: "baz",
|
||||
InstanceKey: IntKey(1),
|
||||
},
|
||||
},
|
||||
Provider: Provider{
|
||||
Type: "aws",
|
||||
Namespace: "hashicorp",
|
||||
Hostname: "registry.terraform.io",
|
||||
},
|
||||
},
|
||||
``,
|
||||
AbsProviderConfig{},
|
||||
`Provider address cannot contain module indexes`,
|
||||
},
|
||||
{
|
||||
`module.baz[1].module.bar.provider["registry.terraform.io/hashicorp/aws"]`,
|
||||
AbsProviderConfig{
|
||||
Module: ModuleInstance{
|
||||
{
|
||||
Name: "baz",
|
||||
InstanceKey: IntKey(1),
|
||||
},
|
||||
{
|
||||
Name: "bar",
|
||||
},
|
||||
},
|
||||
Provider: Provider{
|
||||
Type: "aws",
|
||||
Namespace: "hashicorp",
|
||||
Hostname: "registry.terraform.io",
|
||||
},
|
||||
},
|
||||
``,
|
||||
AbsProviderConfig{},
|
||||
`Provider address cannot contain module indexes`,
|
||||
},
|
||||
{
|
||||
`aws`,
|
||||
|
@ -206,21 +159,21 @@ func TestAbsProviderConfigString(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
AbsProviderConfig{
|
||||
Module: RootModuleInstance,
|
||||
Module: RootModule,
|
||||
Provider: NewLegacyProvider("foo"),
|
||||
},
|
||||
`provider["registry.terraform.io/-/foo"]`,
|
||||
},
|
||||
{
|
||||
AbsProviderConfig{
|
||||
Module: RootModuleInstance.Child("child_module", NoKey),
|
||||
Module: RootModule.Child("child_module"),
|
||||
Provider: NewLegacyProvider("foo"),
|
||||
},
|
||||
`module.child_module.provider["registry.terraform.io/-/foo"]`,
|
||||
},
|
||||
{
|
||||
AbsProviderConfig{
|
||||
Module: RootModuleInstance,
|
||||
Module: RootModule,
|
||||
Alias: "bar",
|
||||
Provider: NewLegacyProvider("foo"),
|
||||
},
|
||||
|
@ -228,7 +181,7 @@ func TestAbsProviderConfigString(t *testing.T) {
|
|||
},
|
||||
{
|
||||
AbsProviderConfig{
|
||||
Module: RootModuleInstance.Child("child_module", NoKey),
|
||||
Module: RootModule.Child("child_module"),
|
||||
Alias: "bar",
|
||||
Provider: NewLegacyProvider("foo"),
|
||||
},
|
||||
|
@ -251,21 +204,21 @@ func TestAbsProviderConfigLegacyString(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
AbsProviderConfig{
|
||||
Module: RootModuleInstance,
|
||||
Module: RootModule,
|
||||
Provider: NewLegacyProvider("foo"),
|
||||
},
|
||||
`provider.foo`,
|
||||
},
|
||||
{
|
||||
AbsProviderConfig{
|
||||
Module: RootModuleInstance.Child("child_module", NoKey),
|
||||
Module: RootModule.Child("child_module"),
|
||||
Provider: NewLegacyProvider("foo"),
|
||||
},
|
||||
`module.child_module.provider.foo`,
|
||||
},
|
||||
{
|
||||
AbsProviderConfig{
|
||||
Module: RootModuleInstance,
|
||||
Module: RootModule,
|
||||
Alias: "bar",
|
||||
Provider: NewLegacyProvider("foo"),
|
||||
},
|
||||
|
@ -273,7 +226,7 @@ func TestAbsProviderConfigLegacyString(t *testing.T) {
|
|||
},
|
||||
{
|
||||
AbsProviderConfig{
|
||||
Module: RootModuleInstance.Child("child_module", NoKey),
|
||||
Module: RootModule.Child("child_module"),
|
||||
Alias: "bar",
|
||||
Provider: NewLegacyProvider("foo"),
|
||||
},
|
||||
|
|
|
@ -217,7 +217,7 @@ func TestLocal_planDeposedOnly(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
}))
|
||||
|
@ -661,7 +661,7 @@ func testPlanState() *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
return state
|
||||
|
@ -688,7 +688,7 @@ func testPlanState_withDataSource() *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
rootModule.SetResourceInstanceCurrent(
|
||||
|
@ -705,7 +705,7 @@ func testPlanState_withDataSource() *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
return state
|
||||
|
@ -732,7 +732,7 @@ func testPlanState_tainted() *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
return state
|
||||
|
|
|
@ -152,7 +152,7 @@ func TestBackendStates(t *testing.T, b Backend) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ func TestApply_destroy(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -127,7 +127,7 @@ func TestApply_destroyLockedState(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -202,7 +202,7 @@ func TestApply_destroyTargeted(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -218,7 +218,7 @@ func TestApply_destroyTargeted(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -835,7 +835,7 @@ func TestApply_refresh(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -992,7 +992,7 @@ func TestApply_state(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -1359,7 +1359,7 @@ func TestApply_backup(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -1663,7 +1663,7 @@ func applyFixturePlanFile(t *testing.T) string {
|
|||
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: plans.Create,
|
||||
|
|
|
@ -273,7 +273,7 @@ func testState() *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
// DeepCopy is used here to ensure our synthetic state matches exactly
|
||||
|
|
|
@ -3159,7 +3159,7 @@ func runTestCases(t *testing.T, testCases map[string]testCase) {
|
|||
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: tc.Action,
|
||||
|
|
|
@ -245,7 +245,7 @@ func basicState(t *testing.T) *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
rootModule.SetResourceInstanceCurrent(
|
||||
|
@ -261,7 +261,7 @@ func basicState(t *testing.T) *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
return state
|
||||
|
@ -297,7 +297,7 @@ func stateWithMoreOutputs(t *testing.T) *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
return state
|
||||
|
@ -324,7 +324,7 @@ func nestedState(t *testing.T) *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
return state
|
||||
|
@ -347,7 +347,7 @@ func deposedState(t *testing.T) *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
return state
|
||||
|
@ -376,7 +376,7 @@ func onlyDeposedState(t *testing.T) *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
rootModule.SetResourceInstanceDeposed(
|
||||
|
@ -393,7 +393,7 @@ func onlyDeposedState(t *testing.T) *states.State {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
return state
|
||||
|
|
|
@ -127,7 +127,7 @@ func TestGraph_plan(t *testing.T) {
|
|||
},
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
})
|
||||
emptyConfig, err := plans.NewDynamicValue(cty.EmptyObjectVal, cty.EmptyObject)
|
||||
|
|
|
@ -260,7 +260,7 @@ func TestMarshalPlanResources(t *testing.T) {
|
|||
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: test.Action,
|
||||
|
|
|
@ -203,7 +203,7 @@ func TestMarshalResources(t *testing.T) {
|
|||
},
|
||||
ProviderConfig: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -245,7 +245,7 @@ func TestMarshalResources(t *testing.T) {
|
|||
},
|
||||
ProviderConfig: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -287,7 +287,7 @@ func TestMarshalResources(t *testing.T) {
|
|||
},
|
||||
ProviderConfig: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -331,7 +331,7 @@ func TestMarshalResources(t *testing.T) {
|
|||
},
|
||||
ProviderConfig: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -380,7 +380,7 @@ func TestMarshalResources(t *testing.T) {
|
|||
},
|
||||
ProviderConfig: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -452,7 +452,7 @@ func TestMarshalModules_basic(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -467,7 +467,7 @@ func TestMarshalModules_basic(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: childModule,
|
||||
Module: childModule.Module(),
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -482,7 +482,7 @@ func TestMarshalModules_basic(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: subModule,
|
||||
Module: subModule.Module(),
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -521,7 +521,7 @@ func TestMarshalModules_nested(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -536,7 +536,7 @@ func TestMarshalModules_nested(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: childModule,
|
||||
Module: childModule.Module(),
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -551,7 +551,7 @@ func TestMarshalModules_nested(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: subModule,
|
||||
Module: subModule.Module(),
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -126,7 +126,7 @@ func TestPlan_destroy(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -245,7 +245,7 @@ func TestPlan_outPathNoChange(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -487,7 +487,7 @@ func showFixturePlanFile(t *testing.T, action plans.Action) string {
|
|||
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: action,
|
||||
|
|
|
@ -29,7 +29,7 @@ func TestStateMv(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -45,7 +45,7 @@ func TestStateMv(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -160,7 +160,7 @@ func TestStateMv_resourceToInstance(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -176,7 +176,7 @@ func TestStateMv_resourceToInstance(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceMeta(
|
||||
|
@ -188,7 +188,7 @@ func TestStateMv_resourceToInstance(t *testing.T) {
|
|||
states.EachList,
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -250,7 +250,7 @@ func TestStateMv_instanceToResource(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -265,7 +265,7 @@ func TestStateMv_instanceToResource(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -338,7 +338,7 @@ func TestStateMv_instanceToNewResource(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -409,7 +409,7 @@ func TestStateMv_differentResourceTypes(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -462,7 +462,7 @@ func TestStateMv_explicitWithBackend(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -477,7 +477,7 @@ func TestStateMv_explicitWithBackend(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -537,7 +537,7 @@ func TestStateMv_backupExplicit(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -553,7 +553,7 @@ func TestStateMv_backupExplicit(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -602,7 +602,7 @@ func TestStateMv_stateOutNew(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -656,7 +656,7 @@ func TestStateMv_stateOutExisting(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -675,7 +675,7 @@ func TestStateMv_stateOutExisting(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -755,7 +755,7 @@ func TestStateMv_stateOutNew_count(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -770,7 +770,7 @@ func TestStateMv_stateOutNew_count(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -785,7 +785,7 @@ func TestStateMv_stateOutNew_count(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -843,7 +843,7 @@ func TestStateMv_stateOutNew_largeCount(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -859,7 +859,7 @@ func TestStateMv_stateOutNew_largeCount(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -913,7 +913,7 @@ func TestStateMv_stateOutNew_nestedModule(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -928,7 +928,7 @@ func TestStateMv_stateOutNew_nestedModule(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -983,7 +983,7 @@ func TestStateMv_toNewModule(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -1056,7 +1056,7 @@ func TestStateMv_withinBackend(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -1072,7 +1072,7 @@ func TestStateMv_withinBackend(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestStateRm(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -42,7 +42,7 @@ func TestStateRm(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -92,7 +92,7 @@ func TestStateRmNotChildModule(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
// This second instance has the same local address as the first but
|
||||
|
@ -110,7 +110,7 @@ func TestStateRmNotChildModule(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -181,7 +181,7 @@ func TestStateRmNoArgs(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -196,7 +196,7 @@ func TestStateRmNoArgs(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -240,7 +240,7 @@ func TestStateRmNonExist(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -255,7 +255,7 @@ func TestStateRmNonExist(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -300,7 +300,7 @@ func TestStateRm_backupExplicit(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -315,7 +315,7 @@ func TestStateRm_backupExplicit(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -416,7 +416,7 @@ func TestStateRm_backendState(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -431,7 +431,7 @@ func TestStateRm_backendState(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -120,7 +120,7 @@ func (c *StateShowCommand) Run(args []string) int {
|
|||
absPc := addrs.AbsProviderConfig{
|
||||
Provider: rs.ProviderConfig.Provider,
|
||||
Alias: rs.ProviderConfig.Alias,
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
}
|
||||
singleInstance := states.NewState()
|
||||
singleInstance.EnsureModule(addr.Module).SetResourceInstanceCurrent(
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestStateShow(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -85,7 +85,7 @@ func TestStateShow_multi(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -100,7 +100,7 @@ func TestStateShow_multi(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: submod,
|
||||
Module: submod.Module(),
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -206,7 +206,7 @@ func TestStateShow_configured_provider(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test-beta"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestTaint(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -64,7 +64,7 @@ func TestTaint_lockedState(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -253,7 +253,7 @@ func TestTaint_missing(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -289,7 +289,7 @@ func TestTaint_missingAllow(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -368,7 +368,7 @@ func TestTaint_module(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -383,7 +383,7 @@ func TestTaint_module(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -25,7 +25,7 @@ func TestUntaint(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -68,7 +68,7 @@ func TestUntaint_lockedState(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -279,7 +279,7 @@ func TestUntaint_missing(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -315,7 +315,7 @@ func TestUntaint_missingAllow(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -403,7 +403,7 @@ func TestUntaint_module(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -418,7 +418,7 @@ func TestUntaint_module(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -243,7 +243,7 @@ func TestWorkspace_createWithState(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -222,7 +222,7 @@ func (c *Config) gatherProviderTypes(m map[addrs.Provider]struct{}) {
|
|||
// The module address to resolve local addresses in must be given in the second
|
||||
// argument, and must refer to a module that exists under the receiver or
|
||||
// else this method will panic.
|
||||
func (c *Config) ResolveAbsProviderAddr(addr addrs.ProviderConfig, inModule addrs.ModuleInstance) addrs.AbsProviderConfig {
|
||||
func (c *Config) ResolveAbsProviderAddr(addr addrs.ProviderConfig, inModule addrs.Module) addrs.AbsProviderConfig {
|
||||
switch addr := addr.(type) {
|
||||
|
||||
case addrs.AbsProviderConfig:
|
||||
|
@ -231,7 +231,7 @@ func (c *Config) ResolveAbsProviderAddr(addr addrs.ProviderConfig, inModule addr
|
|||
case addrs.LocalProviderConfig:
|
||||
// Find the descendent Config that contains the module that this
|
||||
// local config belongs to.
|
||||
mc := c.DescendentForInstance(inModule)
|
||||
mc := c.Descendent(inModule)
|
||||
if mc == nil {
|
||||
panic(fmt.Sprintf("ResolveAbsProviderAddr with non-existent module %s", inModule.String()))
|
||||
}
|
||||
|
@ -265,5 +265,5 @@ func (c *Config) ProviderForConfigAddr(addr addrs.LocalProviderConfig) addrs.Pro
|
|||
if provider, exists := c.Module.ProviderRequirements[addr.LocalName]; exists {
|
||||
return provider.Type
|
||||
}
|
||||
return c.ResolveAbsProviderAddr(addr, addrs.RootModuleInstance).Provider
|
||||
return c.ResolveAbsProviderAddr(addr, addrs.RootModule).Provider
|
||||
}
|
||||
|
|
|
@ -43,11 +43,11 @@ func TestConfigResolveAbsProviderAddr(t *testing.T) {
|
|||
|
||||
t.Run("already absolute", func(t *testing.T) {
|
||||
addr := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Alias: "boop",
|
||||
}
|
||||
got := cfg.ResolveAbsProviderAddr(addr, addrs.RootModuleInstance)
|
||||
got := cfg.ResolveAbsProviderAddr(addr, addrs.RootModule)
|
||||
if got, want := got.String(), addr.String(); got != want {
|
||||
t.Errorf("wrong result\ngot: %s\nwant: %s", got, want)
|
||||
}
|
||||
|
@ -57,9 +57,9 @@ func TestConfigResolveAbsProviderAddr(t *testing.T) {
|
|||
LocalName: "implied",
|
||||
Alias: "boop",
|
||||
}
|
||||
got := cfg.ResolveAbsProviderAddr(addr, addrs.RootModuleInstance)
|
||||
got := cfg.ResolveAbsProviderAddr(addr, addrs.RootModule)
|
||||
want := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
// FIXME: At the time of writing we still have LocalProviderConfig
|
||||
// nested inside AbsProviderConfig, but a future change will
|
||||
// stop tis embedding and just have an addrs.Provider and an alias
|
||||
|
@ -78,9 +78,9 @@ func TestConfigResolveAbsProviderAddr(t *testing.T) {
|
|||
LocalName: "foo-test", // this is explicitly set in the config
|
||||
Alias: "boop",
|
||||
}
|
||||
got := cfg.ResolveAbsProviderAddr(addr, addrs.RootModuleInstance)
|
||||
got := cfg.ResolveAbsProviderAddr(addr, addrs.RootModule)
|
||||
want := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewProvider(addrs.DefaultRegistryHost, "foo", "test"),
|
||||
Alias: "boop",
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ func TestStateShim(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
rootModule.SetResourceInstanceCurrent(
|
||||
|
@ -59,7 +59,7 @@ func TestStateShim(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -78,7 +78,7 @@ func TestStateShim(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: childInstance,
|
||||
Module: childInstance.Module(),
|
||||
},
|
||||
)
|
||||
childModule.SetResourceInstanceCurrent(
|
||||
|
@ -102,7 +102,7 @@ func TestStateShim(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: childInstance,
|
||||
Module: childInstance.Module(),
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -128,7 +128,7 @@ func TestStateShim(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: childInstance,
|
||||
Module: childInstance.Module(),
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -145,7 +145,7 @@ func TestStateShim(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: childInstance,
|
||||
Module: childInstance.Module(),
|
||||
},
|
||||
)
|
||||
childModule.SetResourceInstanceCurrent(
|
||||
|
@ -161,7 +161,7 @@ func TestStateShim(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: childInstance,
|
||||
Module: childInstance.Module(),
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -178,7 +178,7 @@ func TestStateShim(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: childInstance,
|
||||
Module: childInstance.Module(),
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -729,7 +729,7 @@ func testIDOnlyRefresh(c TestCase, opts terraform.ContextOpts, step TestStep, r
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewDefaultProvider("placeholder"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestProviderAddrs(t *testing.T) {
|
|||
Name: "woot",
|
||||
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
},
|
||||
},
|
||||
|
@ -33,7 +33,7 @@ func TestProviderAddrs(t *testing.T) {
|
|||
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
|
||||
DeposedKey: "foodface",
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
},
|
||||
},
|
||||
|
@ -44,7 +44,7 @@ func TestProviderAddrs(t *testing.T) {
|
|||
Name: "what",
|
||||
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance.Child("foo", addrs.NoKey),
|
||||
Module: addrs.RootModule.Child("foo"),
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
},
|
||||
},
|
||||
|
@ -55,11 +55,11 @@ func TestProviderAddrs(t *testing.T) {
|
|||
got := plan.ProviderAddrs()
|
||||
want := []addrs.AbsProviderConfig{
|
||||
addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance.Child("foo", addrs.NoKey),
|
||||
Module: addrs.RootModule.Child("foo"),
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
},
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestTFPlanRoundTrip(t *testing.T) {
|
|||
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewDefaultProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: plans.DeleteThenCreate,
|
||||
|
@ -79,7 +79,7 @@ func TestTFPlanRoundTrip(t *testing.T) {
|
|||
DeposedKey: "foodface",
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewDefaultProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: plans.Delete,
|
||||
|
@ -198,7 +198,7 @@ func TestTFPlanRoundTripDestroy(t *testing.T) {
|
|||
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewDefaultProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: plans.Delete,
|
||||
|
|
|
@ -11,24 +11,24 @@ import (
|
|||
func TestAddressedTypesAbs(t *testing.T) {
|
||||
providerAddrs := []addrs.AbsProviderConfig{
|
||||
addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Alias: "foo",
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("azure"),
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("null"),
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("null"),
|
||||
},
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ func TestSession_basicState(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -62,7 +62,7 @@ func TestSession_basicState(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -37,7 +37,7 @@ func TestState(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewDefaultProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -81,7 +81,7 @@ func TestState(t *testing.T) {
|
|||
},
|
||||
ProviderConfig: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewDefaultProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -144,7 +144,7 @@ func TestStateDeepCopy(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewDefaultProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
rootModule.SetResourceInstanceCurrent(
|
||||
|
@ -171,7 +171,7 @@ func TestStateDeepCopy(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewDefaultProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -136,13 +136,13 @@ func upgradeStateV3ToV4(old *stateV3) (*stateV4, error) {
|
|||
return nil, fmt.Errorf("invalid legacy provider config reference %q for %s: %s", oldProviderAddr, instAddr, diags.Err())
|
||||
}
|
||||
providerAddr = addrs.AbsProviderConfig{
|
||||
Module: moduleAddr,
|
||||
Module: moduleAddr.Module(),
|
||||
Provider: addrs.NewLegacyProvider(localAddr.LocalName),
|
||||
Alias: localAddr.Alias,
|
||||
}
|
||||
} else {
|
||||
providerAddr = addrs.AbsProviderConfig{
|
||||
Module: moduleAddr,
|
||||
Module: moduleAddr.Module(),
|
||||
Provider: resAddr.DefaultProvider(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ func TestFullInitialState() *states.State {
|
|||
}
|
||||
providerAddr := addrs.AbsProviderConfig{
|
||||
Provider: rAddr.DefaultProvider(),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
}
|
||||
childMod.SetResourceMeta(rAddr, states.EachList, providerAddr)
|
||||
return state
|
||||
|
|
|
@ -1333,7 +1333,7 @@ func TestContext2Apply_destroyDependsOnStateOnly(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -1358,7 +1358,7 @@ func TestContext2Apply_destroyDependsOnStateOnly(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -1431,7 +1431,7 @@ func TestContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
child.SetResourceInstanceCurrent(
|
||||
|
@ -1456,7 +1456,7 @@ func TestContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -2828,7 +2828,7 @@ func TestContext2Apply_orphanResource(t *testing.T) {
|
|||
want := states.BuildState(func(s *states.SyncState) {
|
||||
providerAddr := addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
}
|
||||
zeroAddr := addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
|
@ -7051,7 +7051,7 @@ func TestContext2Apply_errorDestroy(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
}),
|
||||
|
@ -7191,7 +7191,7 @@ func TestContext2Apply_errorUpdateNullNew(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
}),
|
||||
|
@ -8618,7 +8618,7 @@ func TestContext2Apply_createBefore_depends(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -8644,7 +8644,7 @@ func TestContext2Apply_createBefore_depends(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -8751,7 +8751,7 @@ func TestContext2Apply_singleDestroy(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -8777,7 +8777,7 @@ func TestContext2Apply_singleDestroy(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -9684,7 +9684,7 @@ func TestContext2Apply_destroyWithProviders(t *testing.T) {
|
|||
state.Modules["module.mod.module.removed"].Resources["aws_instance.child"].ProviderConfig = addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Alias: "bar",
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
}
|
||||
|
||||
if _, diags := ctx.Plan(); diags.HasErrors() {
|
||||
|
@ -10108,7 +10108,7 @@ func TestContext2Apply_issue19908(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
}),
|
||||
|
@ -10236,7 +10236,7 @@ func TestContext2Apply_moduleReplaceCycle(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -10253,7 +10253,7 @@ func TestContext2Apply_moduleReplaceCycle(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -10296,7 +10296,7 @@ func TestContext2Apply_moduleReplaceCycle(t *testing.T) {
|
|||
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance.Child("a", addrs.NoKey)),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: aAction,
|
||||
|
@ -10312,7 +10312,7 @@ func TestContext2Apply_moduleReplaceCycle(t *testing.T) {
|
|||
}.Instance(addrs.IntKey(0)).Absolute(addrs.RootModuleInstance.Child("b", addrs.NoKey)),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: plans.DeleteThenCreate,
|
||||
|
@ -10363,7 +10363,7 @@ func TestContext2Apply_destroyDataCycle(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("null"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -10378,7 +10378,7 @@ func TestContext2Apply_destroyDataCycle(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("null"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -10453,7 +10453,7 @@ func TestContext2Apply_taintedDestroyFailure(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -10468,7 +10468,7 @@ func TestContext2Apply_taintedDestroyFailure(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -10483,7 +10483,7 @@ func TestContext2Apply_taintedDestroyFailure(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -10660,7 +10660,7 @@ func TestContext2Apply_cbdCycle(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -10685,7 +10685,7 @@ func TestContext2Apply_cbdCycle(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -10700,7 +10700,7 @@ func TestContext2Apply_cbdCycle(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ func TestContextImport_collision(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
}),
|
||||
|
@ -606,7 +606,7 @@ func TestContextImport_moduleDiff(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
}),
|
||||
|
@ -667,7 +667,7 @@ func TestContextImport_moduleExisting(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
}),
|
||||
|
|
|
@ -160,7 +160,7 @@ func (c *Context) Input(mode InputMode) tfdiags.Diagnostics {
|
|||
absConfigAddr := addrs.AbsProviderConfig{
|
||||
Provider: providerFqn,
|
||||
Alias: pa.Alias,
|
||||
Module: c.Config().Path.UnkeyedInstanceShim(),
|
||||
Module: c.Config().Path,
|
||||
}
|
||||
c.providerInputConfig[absConfigAddr.String()] = vals
|
||||
|
||||
|
|
|
@ -480,7 +480,7 @@ func TestContext2Input_dataSourceRequiresRefresh(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("null"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -5052,7 +5052,7 @@ func TestContext2Plan_ignoreChangesInMap(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -105,7 +105,7 @@ func TestContext2Refresh_dynamicAttr(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -1742,7 +1742,7 @@ func TestContext2Refresh_schemaUpgradeFlatmap(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -1828,7 +1828,7 @@ func TestContext2Refresh_schemaUpgradeJSON(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -1999,7 +1999,7 @@ func TestRefresh_updateDependencies(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -2014,7 +2014,7 @@ func TestRefresh_updateDependencies(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ func (ctx *BuiltinEvalContext) Input() UIInput {
|
|||
func (ctx *BuiltinEvalContext) InitProvider(addr addrs.AbsProviderConfig) (providers.Interface, error) {
|
||||
ctx.once.Do(ctx.init)
|
||||
absAddr := addr
|
||||
if !absAddr.Module.Equal(ctx.Path()) {
|
||||
if !absAddr.Module.Equal(ctx.Path().Module()) {
|
||||
// This indicates incorrect use of InitProvider: it should be used
|
||||
// only from the module that the provider configuration belongs to.
|
||||
panic(fmt.Sprintf("%s initialized by wrong module %s", absAddr, ctx.Path()))
|
||||
|
@ -153,7 +153,7 @@ func (ctx *BuiltinEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) *Pro
|
|||
|
||||
func (ctx *BuiltinEvalContext) CloseProvider(addr addrs.AbsProviderConfig) error {
|
||||
ctx.once.Do(ctx.init)
|
||||
if !addr.Module.Equal(ctx.Path()) {
|
||||
if !addr.Module.Equal(ctx.Path().Module()) {
|
||||
// This indicates incorrect use of CloseProvider: it should be used
|
||||
// only from the module that the provider configuration belongs to.
|
||||
panic(fmt.Sprintf("%s closed by wrong module %s", addr, ctx.Path()))
|
||||
|
@ -175,7 +175,7 @@ func (ctx *BuiltinEvalContext) CloseProvider(addr addrs.AbsProviderConfig) error
|
|||
func (ctx *BuiltinEvalContext) ConfigureProvider(addr addrs.AbsProviderConfig, cfg cty.Value) tfdiags.Diagnostics {
|
||||
var diags tfdiags.Diagnostics
|
||||
absAddr := addr
|
||||
if !absAddr.Module.Equal(ctx.Path()) {
|
||||
if !absAddr.Module.Equal(ctx.Path().Module()) {
|
||||
// This indicates incorrect use of ConfigureProvider: it should be used
|
||||
// only from the module that the provider configuration belongs to.
|
||||
panic(fmt.Sprintf("%s configured by wrong module %s", absAddr, ctx.Path()))
|
||||
|
@ -206,7 +206,7 @@ func (ctx *BuiltinEvalContext) ProviderInput(pc addrs.AbsProviderConfig) map[str
|
|||
ctx.ProviderLock.Lock()
|
||||
defer ctx.ProviderLock.Unlock()
|
||||
|
||||
if !pc.Module.Equal(ctx.Path()) {
|
||||
if !pc.Module.Equal(ctx.Path().Module()) {
|
||||
// This indicates incorrect use of InitProvider: it should be used
|
||||
// only from the module that the provider configuration belongs to.
|
||||
panic(fmt.Sprintf("%s initialized by wrong module %s", pc, ctx.Path()))
|
||||
|
@ -222,7 +222,7 @@ func (ctx *BuiltinEvalContext) ProviderInput(pc addrs.AbsProviderConfig) map[str
|
|||
|
||||
func (ctx *BuiltinEvalContext) SetProviderInput(pc addrs.AbsProviderConfig, c map[string]cty.Value) {
|
||||
absProvider := pc
|
||||
if !absProvider.Module.Equal(ctx.Path()) {
|
||||
if !absProvider.Module.Equal(ctx.Path().Module()) {
|
||||
// This indicates incorrect use of InitProvider: it should be used
|
||||
// only from the module that the provider configuration belongs to.
|
||||
panic(fmt.Sprintf("%s initialized by wrong module %s", absProvider, ctx.Path()))
|
||||
|
|
|
@ -25,11 +25,11 @@ func TestBuiltinEvalContextProviderInput(t *testing.T) {
|
|||
ctx2.ProviderLock = &lock
|
||||
|
||||
providerAddr1 := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("foo"),
|
||||
}
|
||||
providerAddr2 := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance.Child("child", addrs.NoKey),
|
||||
Module: addrs.RootModule.Child("child"),
|
||||
Provider: addrs.NewLegacyProvider("foo"),
|
||||
}
|
||||
|
||||
|
@ -65,11 +65,11 @@ func TestBuildingEvalContextInitProvider(t *testing.T) {
|
|||
}
|
||||
|
||||
providerAddrDefault := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
}
|
||||
providerAddrAlias := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Alias: "foo",
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestBuildProviderConfig(t *testing.T) {
|
|||
"set_in_config": cty.StringVal("config"),
|
||||
})
|
||||
providerAddr := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("foo"),
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ func TestEvalConfigProvider(t *testing.T) {
|
|||
provider := mockProviderWithConfigSchema(simpleTestSchema())
|
||||
rp := providers.Interface(provider)
|
||||
providerAddr := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("foo"),
|
||||
}
|
||||
n := &EvalConfigProvider{
|
||||
|
@ -103,7 +103,7 @@ func TestEvalInitProvider_impl(t *testing.T) {
|
|||
|
||||
func TestEvalInitProvider(t *testing.T) {
|
||||
providerAddr := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("foo"),
|
||||
}
|
||||
n := &EvalInitProvider{
|
||||
|
@ -125,7 +125,7 @@ func TestEvalInitProvider(t *testing.T) {
|
|||
|
||||
func TestEvalCloseProvider(t *testing.T) {
|
||||
providerAddr := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: addrs.NewLegacyProvider("foo"),
|
||||
}
|
||||
n := &EvalCloseProvider{
|
||||
|
|
|
@ -453,6 +453,7 @@ func (n *EvalMaybeRestoreDeposedObject) Eval(ctx EvalContext) (interface{}, erro
|
|||
// list rather than as not set at all.
|
||||
type EvalWriteResourceState struct {
|
||||
Addr addrs.Resource
|
||||
Module addrs.Module
|
||||
Config *configs.Resource
|
||||
ProviderAddr addrs.AbsProviderConfig
|
||||
}
|
||||
|
@ -460,7 +461,6 @@ type EvalWriteResourceState struct {
|
|||
// TODO: test
|
||||
func (n *EvalWriteResourceState) Eval(ctx EvalContext) (interface{}, error) {
|
||||
var diags tfdiags.Diagnostics
|
||||
absAddr := n.Addr.Absolute(ctx.Path())
|
||||
state := ctx.State()
|
||||
|
||||
count, countDiags := evaluateResourceCountExpression(n.Config.Count, ctx)
|
||||
|
@ -484,16 +484,16 @@ func (n *EvalWriteResourceState) Eval(ctx EvalContext) (interface{}, error) {
|
|||
eachMode = states.EachMap
|
||||
}
|
||||
|
||||
// This method takes care of all of the business logic of updating this
|
||||
// while ensuring that any existing instances are preserved, etc.
|
||||
state.SetResourceMeta(absAddr, eachMode, n.ProviderAddr)
|
||||
|
||||
// We'll record our expansion decision in the shared "expander" object
|
||||
// so that later operations (i.e. DynamicExpand and expression evaluation)
|
||||
// can refer to it. Since this node represents the abstract module, we need
|
||||
// to expand the module here to create all resources.
|
||||
expander := ctx.InstanceExpander()
|
||||
for _, module := range expander.ExpandModule(ctx.Path().Module()) {
|
||||
for _, module := range expander.ExpandModule(n.Module) {
|
||||
// This method takes care of all of the business logic of updating this
|
||||
// while ensuring that any existing instances are preserved, etc.
|
||||
state.SetResourceMeta(n.Addr.Absolute(module), eachMode, n.ProviderAddr)
|
||||
|
||||
switch eachMode {
|
||||
case states.EachList:
|
||||
expander.SetResourceCount(module, n.Addr, count)
|
||||
|
|
|
@ -554,7 +554,7 @@ func TestApplyGraphBuilder_updateFromOrphan(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -579,7 +579,7 @@ func TestApplyGraphBuilder_updateFromOrphan(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package terraform
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/dag"
|
||||
"github.com/hashicorp/terraform/plans"
|
||||
"github.com/hashicorp/terraform/providers"
|
||||
|
@ -15,7 +16,6 @@ type NodeRefreshableDataResource struct {
|
|||
}
|
||||
|
||||
var (
|
||||
_ GraphNodeModuleInstance = (*NodeRefreshableDataResource)(nil)
|
||||
_ GraphNodeDynamicExpandable = (*NodeRefreshableDataResource)(nil)
|
||||
_ GraphNodeReferenceable = (*NodeRefreshableDataResource)(nil)
|
||||
_ GraphNodeReferencer = (*NodeRefreshableDataResource)(nil)
|
||||
|
@ -54,18 +54,22 @@ func (n *NodeRefreshableDataResource) DynamicExpand(ctx EvalContext) (*Graph, er
|
|||
// if we're transitioning whether "count" is set at all.
|
||||
fixResourceCountSetTransition(ctx, n.ResourceAddr(), count != -1)
|
||||
|
||||
var instanceAddrs []addrs.AbsResourceInstance
|
||||
|
||||
// Inform our instance expander about our expansion results above,
|
||||
// and then use it to calculate the instance addresses we'll expand for.
|
||||
expander := ctx.InstanceExpander()
|
||||
switch {
|
||||
case count >= 0:
|
||||
expander.SetResourceCount(ctx.Path(), n.ResourceAddr().Resource, count)
|
||||
case forEachMap != nil:
|
||||
expander.SetResourceForEach(ctx.Path(), n.ResourceAddr().Resource, forEachMap)
|
||||
default:
|
||||
expander.SetResourceSingle(ctx.Path(), n.ResourceAddr().Resource)
|
||||
for _, path := range expander.ExpandModule(n.Module) {
|
||||
switch {
|
||||
case count >= 0:
|
||||
expander.SetResourceCount(path, n.ResourceAddr().Resource, count)
|
||||
case forEachMap != nil:
|
||||
expander.SetResourceForEach(path, n.ResourceAddr().Resource, forEachMap)
|
||||
default:
|
||||
expander.SetResourceSingle(path, n.ResourceAddr().Resource)
|
||||
}
|
||||
instanceAddrs = append(instanceAddrs, expander.ExpandResource(path.Module(), n.ResourceAddr().Resource)...)
|
||||
}
|
||||
instanceAddrs := expander.ExpandResource(ctx.Path().Module(), n.ResourceAddr().Resource)
|
||||
|
||||
// Our graph transformers require access to the full state, so we'll
|
||||
// temporarily lock it while we work on this.
|
||||
|
@ -135,7 +139,7 @@ func (n *NodeRefreshableDataResource) DynamicExpand(ctx EvalContext) (*Graph, er
|
|||
Name: "NodeRefreshableDataResource",
|
||||
}
|
||||
|
||||
graph, diags := b.Build(ctx.Path())
|
||||
graph, diags := b.Build(nil)
|
||||
return graph, diags.ErrWithWarnings()
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ func TestNodeRefreshableDataResourceDynamicExpand_scaleIn(t *testing.T) {
|
|||
Config: m.Module.DataResources["data.aws_instance.foo"],
|
||||
ResolvedProvider: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ type NodeAbstractProvider struct {
|
|||
}
|
||||
|
||||
var (
|
||||
_ GraphNodeModuleInstance = (*NodeAbstractProvider)(nil)
|
||||
_ GraphNodeModulePath = (*NodeAbstractProvider)(nil)
|
||||
_ RemovableIfNotTargeted = (*NodeAbstractProvider)(nil)
|
||||
_ GraphNodeReferencer = (*NodeAbstractProvider)(nil)
|
||||
_ GraphNodeProvider = (*NodeAbstractProvider)(nil)
|
||||
|
@ -41,12 +41,12 @@ func (n *NodeAbstractProvider) Name() string {
|
|||
|
||||
// GraphNodeModuleInstance
|
||||
func (n *NodeAbstractProvider) Path() addrs.ModuleInstance {
|
||||
return n.Addr.Module
|
||||
return n.Addr.Module.UnkeyedInstanceShim()
|
||||
}
|
||||
|
||||
// GraphNodeModulePath
|
||||
func (n *NodeAbstractProvider) ModulePath() addrs.Module {
|
||||
return n.Addr.Module.Module()
|
||||
return n.Addr.Module
|
||||
}
|
||||
|
||||
// RemovableIfNotTargeted
|
||||
|
|
|
@ -99,7 +99,8 @@ func NewNodeAbstractResource(addr addrs.AbsResource) *NodeAbstractResource {
|
|||
// the "count" or "for_each" arguments.
|
||||
type NodeAbstractResourceInstance struct {
|
||||
NodeAbstractResource
|
||||
InstanceKey addrs.InstanceKey
|
||||
ModuleInstance addrs.ModuleInstance
|
||||
InstanceKey addrs.InstanceKey
|
||||
|
||||
// The fields below will be automatically set using the Attach
|
||||
// interfaces if you're running those transforms, but also be explicitly
|
||||
|
@ -138,7 +139,8 @@ func NewNodeAbstractResourceInstance(addr addrs.AbsResourceInstance) *NodeAbstra
|
|||
Addr: addr.Resource.Resource,
|
||||
Module: addr.Module.Module(),
|
||||
},
|
||||
InstanceKey: addr.Resource.Key,
|
||||
ModuleInstance: addr.Module,
|
||||
InstanceKey: addr.Resource.Key,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,6 +157,10 @@ func (n *NodeAbstractResource) Path() addrs.ModuleInstance {
|
|||
return n.Module.UnkeyedInstanceShim()
|
||||
}
|
||||
|
||||
func (n *NodeAbstractResourceInstance) Path() addrs.ModuleInstance {
|
||||
return n.ModuleInstance
|
||||
}
|
||||
|
||||
// GraphNodeModulePath
|
||||
func (n *NodeAbstractResource) ModulePath() addrs.Module {
|
||||
return n.Module
|
||||
|
|
|
@ -53,19 +53,16 @@ func (n *NodeApplyableResource) References() []*addrs.Reference {
|
|||
|
||||
// GraphNodeEvalable
|
||||
func (n *NodeApplyableResource) EvalTree() EvalNode {
|
||||
addr := n.ResourceAddr()
|
||||
config := n.Config
|
||||
providerAddr := n.ResolvedProvider
|
||||
|
||||
if config == nil {
|
||||
if n.Config == nil {
|
||||
// Nothing to do, then.
|
||||
log.Printf("[TRACE] NodeApplyableResource: no configuration present for %s", addr)
|
||||
log.Printf("[TRACE] NodeApplyableResource: no configuration present for %s", n.Name())
|
||||
return &EvalNoop{}
|
||||
}
|
||||
|
||||
return &EvalWriteResourceState{
|
||||
Addr: addr.Resource,
|
||||
Config: config,
|
||||
ProviderAddr: providerAddr,
|
||||
Addr: n.Addr,
|
||||
Module: n.Module,
|
||||
Config: n.Config,
|
||||
ProviderAddr: n.ResolvedProvider,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -288,6 +288,7 @@ func (n *NodeDestroyResourceInstance) EvalTree() EvalNode {
|
|||
// all been destroyed.
|
||||
type NodeDestroyResource struct {
|
||||
*NodeAbstractResource
|
||||
Addr addrs.AbsResource
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -342,11 +343,6 @@ func (n *NodeDestroyResource) ResourceAddr() addrs.AbsResource {
|
|||
return n.NodeAbstractResource.ResourceAddr()
|
||||
}
|
||||
|
||||
// GraphNodeSubpath
|
||||
func (n *NodeDestroyResource) Path() addrs.ModuleInstance {
|
||||
return n.NodeAbstractResource.Path()
|
||||
}
|
||||
|
||||
// GraphNodeNoProvider
|
||||
// FIXME: this should be removed once the node can be separated from the
|
||||
// Internal NodeAbstractResource behavior.
|
||||
|
|
|
@ -19,7 +19,6 @@ type NodePlannableResource struct {
|
|||
}
|
||||
|
||||
var (
|
||||
_ GraphNodeModuleInstance = (*NodePlannableResource)(nil)
|
||||
_ GraphNodeDestroyerCBD = (*NodePlannableResource)(nil)
|
||||
_ GraphNodeDynamicExpandable = (*NodePlannableResource)(nil)
|
||||
_ GraphNodeReferenceable = (*NodePlannableResource)(nil)
|
||||
|
@ -30,19 +29,17 @@ var (
|
|||
|
||||
// GraphNodeEvalable
|
||||
func (n *NodePlannableResource) EvalTree() EvalNode {
|
||||
addr := n.ResourceAddr()
|
||||
config := n.Config
|
||||
|
||||
if config == nil {
|
||||
if n.Config == nil {
|
||||
// Nothing to do, then.
|
||||
log.Printf("[TRACE] NodeApplyableResource: no configuration present for %s", addr)
|
||||
log.Printf("[TRACE] NodeApplyableResource: no configuration present for %s", n.Name())
|
||||
return &EvalNoop{}
|
||||
}
|
||||
|
||||
// this ensures we can reference the resource even if the count is 0
|
||||
return &EvalWriteResourceState{
|
||||
Addr: addr.Resource,
|
||||
Config: config,
|
||||
Addr: n.Addr,
|
||||
Module: n.Module,
|
||||
Config: n.Config,
|
||||
ProviderAddr: n.ResolvedProvider,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ type NodeRefreshableManagedResource struct {
|
|||
}
|
||||
|
||||
var (
|
||||
_ GraphNodeModuleInstance = (*NodeRefreshableManagedResource)(nil)
|
||||
_ GraphNodeDynamicExpandable = (*NodeRefreshableManagedResource)(nil)
|
||||
_ GraphNodeReferenceable = (*NodeRefreshableManagedResource)(nil)
|
||||
_ GraphNodeReferencer = (*NodeRefreshableManagedResource)(nil)
|
||||
|
@ -61,8 +60,7 @@ func (n *NodeRefreshableManagedResource) DynamicExpand(ctx EvalContext) (*Graph,
|
|||
// Inform our instance expander about our expansion results above,
|
||||
// and then use it to calculate the instance addresses we'll expand for.
|
||||
expander := ctx.InstanceExpander()
|
||||
|
||||
for _, module := range expander.ExpandModule(ctx.Path().Module()) {
|
||||
for _, module := range expander.ExpandModule(n.Module) {
|
||||
switch {
|
||||
case count >= 0:
|
||||
expander.SetResourceCount(module, n.ResourceAddr().Resource, count)
|
||||
|
@ -72,7 +70,7 @@ func (n *NodeRefreshableManagedResource) DynamicExpand(ctx EvalContext) (*Graph,
|
|||
expander.SetResourceSingle(module, n.ResourceAddr().Resource)
|
||||
}
|
||||
}
|
||||
instanceAddrs := expander.ExpandResource(ctx.Path().Module(), n.ResourceAddr().Resource)
|
||||
instanceAddrs := expander.ExpandResource(n.Module, n.ResourceAddr().Resource)
|
||||
|
||||
// Our graph transformers require access to the full state, so we'll
|
||||
// temporarily lock it while we work on this.
|
||||
|
@ -131,7 +129,7 @@ func (n *NodeRefreshableManagedResource) DynamicExpand(ctx EvalContext) (*Graph,
|
|||
Name: "NodeRefreshableManagedResource",
|
||||
}
|
||||
|
||||
graph, diags := b.Build(ctx.Path())
|
||||
graph, diags := b.Build(nil)
|
||||
return graph, diags.ErrWithWarnings()
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ type NodeValidatableResource struct {
|
|||
}
|
||||
|
||||
var (
|
||||
_ GraphNodeModuleInstance = (*NodeValidatableResource)(nil)
|
||||
_ GraphNodeEvalable = (*NodeValidatableResource)(nil)
|
||||
_ GraphNodeReferenceable = (*NodeValidatableResource)(nil)
|
||||
_ GraphNodeReferencer = (*NodeValidatableResource)(nil)
|
||||
|
|
|
@ -69,7 +69,7 @@ func (t *AttachSchemaTransformer) Transform(g *Graph) error {
|
|||
if t.Config == nil {
|
||||
providerFqn = addrs.NewLegacyProvider(p.LocalName)
|
||||
} else {
|
||||
modConfig := t.Config.DescendentForInstance(tv.Path())
|
||||
modConfig := t.Config.Descendent(tv.ModulePath())
|
||||
if modConfig == nil {
|
||||
providerFqn = addrs.NewLegacyProvider(p.LocalName)
|
||||
} else {
|
||||
|
|
|
@ -45,7 +45,7 @@ func TestDiffTransformer(t *testing.T) {
|
|||
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: plans.Update,
|
||||
|
|
|
@ -24,7 +24,7 @@ func (t *ImportStateTransformer) Transform(g *Graph) error {
|
|||
defaultFQN := target.Addr.Resource.Resource.DefaultProvider()
|
||||
providerAddr = addrs.AbsProviderConfig{
|
||||
Provider: defaultFQN,
|
||||
Module: target.Addr.Module,
|
||||
Module: target.Addr.Module.Module(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ type graphNodeImportState struct {
|
|||
}
|
||||
|
||||
var (
|
||||
_ GraphNodeModuleInstance = (*graphNodeImportState)(nil)
|
||||
_ GraphNodeModulePath = (*graphNodeImportState)(nil)
|
||||
_ GraphNodeEvalable = (*graphNodeImportState)(nil)
|
||||
_ GraphNodeProviderConsumer = (*graphNodeImportState)(nil)
|
||||
_ GraphNodeDynamicExpandable = (*graphNodeImportState)(nil)
|
||||
|
@ -88,6 +88,11 @@ func (n *graphNodeImportState) Path() addrs.ModuleInstance {
|
|||
return n.Addr.Module
|
||||
}
|
||||
|
||||
// GraphNodeModulePath
|
||||
func (n *graphNodeImportState) ModulePath() addrs.Module {
|
||||
return n.Addr.Module.Module()
|
||||
}
|
||||
|
||||
// GraphNodeEvalable impl.
|
||||
func (n *graphNodeImportState) EvalTree() EvalNode {
|
||||
var provider providers.Interface
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestOrphanResourceInstanceTransformer(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -47,7 +47,7 @@ func TestOrphanResourceInstanceTransformer(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -96,7 +96,7 @@ func TestOrphanResourceInstanceTransformer_countGood(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -113,7 +113,7 @@ func TestOrphanResourceInstanceTransformer_countGood(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -161,7 +161,7 @@ func TestOrphanResourceInstanceTransformer_countBad(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -178,7 +178,7 @@ func TestOrphanResourceInstanceTransformer_countBad(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -226,7 +226,7 @@ func TestOrphanResourceInstanceTransformer_modules(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -243,7 +243,7 @@ func TestOrphanResourceInstanceTransformer_modules(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -44,7 +44,7 @@ func TransformProviders(providers []string, concrete ConcreteProviderNodeFunc, c
|
|||
//
|
||||
// Name returns the full name of the provider in the config.
|
||||
type GraphNodeProvider interface {
|
||||
GraphNodeModuleInstance
|
||||
GraphNodeModulePath
|
||||
ProviderAddr() addrs.AbsProviderConfig
|
||||
Name() string
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ type GraphNodeProvider interface {
|
|||
// provider must implement. The CloseProviderName returned is the name of
|
||||
// the provider they satisfy.
|
||||
type GraphNodeCloseProvider interface {
|
||||
GraphNodeModuleInstance
|
||||
GraphNodeModulePath
|
||||
CloseProviderAddr() addrs.AbsProviderConfig
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ type GraphNodeCloseProvider interface {
|
|||
// or in an ancestor module, with the resulting absolute address passed to
|
||||
// SetProvider.
|
||||
type GraphNodeProviderConsumer interface {
|
||||
GraphNodeModuleInstance
|
||||
GraphNodeModulePath
|
||||
// ProvidedBy returns the address of the provider configuration the node
|
||||
// refers to, if available. The following value types may be returned:
|
||||
//
|
||||
|
@ -139,7 +139,7 @@ func (t *ProviderTransformer) Transform(g *Graph) error {
|
|||
case addrs.LocalProviderConfig:
|
||||
// ProvidedBy() return a LocalProviderConfig when the resource
|
||||
// contains a `provider` attribute
|
||||
modPath := pv.Path()
|
||||
modPath := pv.ModulePath()
|
||||
if t.Config == nil {
|
||||
absPc.Provider = addrs.NewLegacyProvider(p.LocalName)
|
||||
absPc.Module = modPath
|
||||
|
@ -147,7 +147,7 @@ func (t *ProviderTransformer) Transform(g *Graph) error {
|
|||
break
|
||||
}
|
||||
|
||||
modConfig := t.Config.DescendentForInstance(modPath)
|
||||
modConfig := t.Config.Descendent(modPath)
|
||||
if modConfig == nil {
|
||||
absPc.Provider = addrs.NewLegacyProvider(p.LocalName)
|
||||
} else {
|
||||
|
@ -159,7 +159,7 @@ func (t *ProviderTransformer) Transform(g *Graph) error {
|
|||
case nil:
|
||||
// No provider found in config or state; fall back to implied default provider.
|
||||
absPc.Provider = pv.ImpliedProvider()
|
||||
absPc.Module = pv.Path()
|
||||
absPc.Module = pv.ModulePath()
|
||||
log.Printf("[TRACE] ProviderTransformer: %s is provided by %s or inherited equivalent", dag.VertexName(v), absPc)
|
||||
|
||||
default:
|
||||
|
@ -216,7 +216,7 @@ func (t *ProviderTransformer) Transform(g *Graph) error {
|
|||
// start up the provider and fetch its schema.
|
||||
if _, exists := needConfigured[key]; target == nil && !exists {
|
||||
stubAddr := addrs.AbsProviderConfig{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Provider: p.Provider,
|
||||
}
|
||||
stub := &NodeEvalableProvider{
|
||||
|
@ -364,7 +364,7 @@ func (t *MissingProviderTransformer) Transform(g *Graph) error {
|
|||
log.Println("[TRACE] MissingProviderTransformer: skipping implication of aliased config", p)
|
||||
continue
|
||||
}
|
||||
modConfig := t.Config.DescendentForInstance(pv.Path())
|
||||
modConfig := t.Config.Descendent(pv.ModulePath())
|
||||
if modConfig == nil {
|
||||
providerFqn = addrs.NewLegacyProvider(p.LocalName)
|
||||
} else {
|
||||
|
@ -427,7 +427,7 @@ func (t *ParentProviderTransformer) Transform(g *Graph) error {
|
|||
|
||||
// Also require non-empty path, since otherwise we're in the root
|
||||
// module and so cannot have a parent.
|
||||
if len(pn.Path()) <= 1 {
|
||||
if len(pn.ModulePath()) <= 1 {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -513,6 +513,11 @@ func (n *graphNodeCloseProvider) Name() string {
|
|||
|
||||
// GraphNodeModuleInstance impl.
|
||||
func (n *graphNodeCloseProvider) Path() addrs.ModuleInstance {
|
||||
return n.Addr.Module.UnkeyedInstanceShim()
|
||||
}
|
||||
|
||||
// GraphNodeModulePath
|
||||
func (n *graphNodeCloseProvider) ModulePath() addrs.Module {
|
||||
return n.Addr.Module
|
||||
}
|
||||
|
||||
|
@ -562,7 +567,8 @@ type graphNodeProxyProvider struct {
|
|||
}
|
||||
|
||||
var (
|
||||
_ GraphNodeProvider = (*graphNodeProxyProvider)(nil)
|
||||
_ GraphNodeModulePath = (*graphNodeProxyProvider)(nil)
|
||||
_ GraphNodeProvider = (*graphNodeProxyProvider)(nil)
|
||||
)
|
||||
|
||||
func (n *graphNodeProxyProvider) ProviderAddr() addrs.AbsProviderConfig {
|
||||
|
@ -570,6 +576,10 @@ func (n *graphNodeProxyProvider) ProviderAddr() addrs.AbsProviderConfig {
|
|||
}
|
||||
|
||||
func (n *graphNodeProxyProvider) Path() addrs.ModuleInstance {
|
||||
return n.addr.Module.UnkeyedInstanceShim()
|
||||
}
|
||||
|
||||
func (n *graphNodeProxyProvider) ModulePath() addrs.Module {
|
||||
return n.addr.Module
|
||||
}
|
||||
|
||||
|
@ -644,19 +654,7 @@ func (t *ProviderConfigTransformer) transform(g *Graph, c *configs.Config) error
|
|||
func (t *ProviderConfigTransformer) transformSingle(g *Graph, c *configs.Config) error {
|
||||
// Get the module associated with this configuration tree node
|
||||
mod := c.Module
|
||||
staticPath := c.Path
|
||||
|
||||
// We actually need a dynamic module path here, but we've not yet updated
|
||||
// our graph builders enough to support expansion of module calls with
|
||||
// "count" and "for_each" set, so for now we'll shim this by converting to
|
||||
// a dynamic path with no keys. At the time of writing this is the only
|
||||
// possible kind of dynamic path anyway.
|
||||
path := make(addrs.ModuleInstance, len(staticPath))
|
||||
for i, name := range staticPath {
|
||||
path[i] = addrs.ModuleInstanceStep{
|
||||
Name: name,
|
||||
}
|
||||
}
|
||||
path := c.Path
|
||||
|
||||
// add all providers from the configuration
|
||||
for _, p := range mod.ProviderConfigs {
|
||||
|
@ -720,19 +718,6 @@ func (t *ProviderConfigTransformer) addProxyProviders(g *Graph, c *configs.Confi
|
|||
}
|
||||
}
|
||||
|
||||
// We currently don't support count/for_each for modules and so we must
|
||||
// shim our path and parentPath into module instances here so that the
|
||||
// rest of Terraform can behave as if we do. This shimming should be
|
||||
// removed later as part of implementing count/for_each for modules.
|
||||
instPath := make(addrs.ModuleInstance, len(path))
|
||||
for i, name := range path {
|
||||
instPath[i] = addrs.ModuleInstanceStep{Name: name}
|
||||
}
|
||||
parentInstPath := make(addrs.ModuleInstance, len(parentPath))
|
||||
for i, name := range parentPath {
|
||||
parentInstPath[i] = addrs.ModuleInstanceStep{Name: name}
|
||||
}
|
||||
|
||||
if parentCfg == nil {
|
||||
// this can't really happen during normal execution.
|
||||
return fmt.Errorf("parent module config not found for %s", c.Path.String())
|
||||
|
@ -744,13 +729,13 @@ func (t *ProviderConfigTransformer) addProxyProviders(g *Graph, c *configs.Confi
|
|||
fqn := c.Module.ProviderForLocalConfig(pair.InChild.Addr())
|
||||
fullAddr := addrs.AbsProviderConfig{
|
||||
Provider: fqn,
|
||||
Module: instPath,
|
||||
Module: path,
|
||||
Alias: pair.InChild.Addr().Alias,
|
||||
}
|
||||
|
||||
fullParentAddr := addrs.AbsProviderConfig{
|
||||
Provider: fqn,
|
||||
Module: parentInstPath,
|
||||
Module: parentPath,
|
||||
Alias: pair.InParent.Addr().Alias,
|
||||
}
|
||||
|
||||
|
@ -802,7 +787,7 @@ func (t *ProviderConfigTransformer) attachProviderConfigs(g *Graph) error {
|
|||
addr := apn.ProviderAddr()
|
||||
|
||||
// Get the configuration.
|
||||
mc := t.Config.DescendentForInstance(addr.Module)
|
||||
mc := t.Config.Descendent(addr.Module)
|
||||
if mc == nil {
|
||||
log.Printf("[TRACE] ProviderConfigTransformer: no configuration available for %s", addr.String())
|
||||
continue
|
||||
|
|
|
@ -72,7 +72,7 @@ func TestMissingProvisionerTransformer_module(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -89,7 +89,7 @@ func TestMissingProvisionerTransformer_module(t *testing.T) {
|
|||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue