terraform: replace addrs.NewLegacyProvider with lookups when the
configs.Module is accessible. Continuing the work of removing all calls to addrs.NewLegacyProvider, this commit uses configs.Module.ProviderForLocalConfig wherever the caller has access to that Module.
This commit is contained in:
parent
228d881722
commit
ac56d12c5c
|
@ -96,12 +96,7 @@ func (c *Context) Input(mode InputMode) tfdiags.Diagnostics {
|
|||
UIInput: c.uiInput,
|
||||
}
|
||||
|
||||
var providerFqn addrs.Provider
|
||||
if existing, exists := c.config.Module.ProviderRequirements[pa.LocalName]; exists {
|
||||
providerFqn = existing.Type
|
||||
} else {
|
||||
providerFqn = addrs.NewLegacyProvider(pa.LocalName)
|
||||
}
|
||||
providerFqn := c.config.Module.ProviderForLocalConfig(pa)
|
||||
schema := c.schemas.ProviderConfig(providerFqn)
|
||||
if schema == nil {
|
||||
// Could either be an incorrect config or just an incomplete
|
||||
|
|
|
@ -212,12 +212,7 @@ func (d *evaluationStateData) staticValidateResourceReference(modCfg *configs.Co
|
|||
return diags
|
||||
}
|
||||
|
||||
var providerFqn addrs.Provider
|
||||
if existing, exists := modCfg.Module.ProviderRequirements[cfg.ProviderConfigAddr().LocalName]; exists {
|
||||
providerFqn = existing.Type
|
||||
} else {
|
||||
providerFqn = addrs.NewLegacyProvider(cfg.ProviderConfigAddr().LocalName)
|
||||
}
|
||||
providerFqn := modCfg.Module.ProviderForLocalConfig(cfg.ProviderConfigAddr())
|
||||
schema, _ := d.Evaluator.Schemas.ResourceTypeConfig(providerFqn, addr.Mode, addr.Type)
|
||||
|
||||
if schema == nil {
|
||||
|
|
|
@ -82,13 +82,7 @@ func configTreeConfigDependencies(root *configs.Config, inheritProviders map[str
|
|||
// allowing for more terse declaration in situations where both a
|
||||
// configuration and a constraint are defined in the same module.
|
||||
for _, pCfg := range module.ProviderConfigs {
|
||||
var fqn addrs.Provider
|
||||
if existing, exists := module.ProviderRequirements[pCfg.Name]; exists {
|
||||
fqn = existing.Type
|
||||
} else {
|
||||
fqn = addrs.NewLegacyProvider(pCfg.Name)
|
||||
}
|
||||
|
||||
fqn := module.ProviderForLocalConfig(pCfg.Addr())
|
||||
discoConstraints := discovery.AllVersions
|
||||
if pCfg.Version.Required != nil {
|
||||
discoConstraints = discovery.NewConstraints(pCfg.Version.Required)
|
||||
|
@ -112,15 +106,7 @@ func configTreeConfigDependencies(root *configs.Config, inheritProviders map[str
|
|||
// an explicit dependency on the same provider.
|
||||
for _, rc := range module.ManagedResources {
|
||||
addr := rc.ProviderConfigAddr()
|
||||
//look up the provider localname in the provider requirements map and see if
|
||||
//there is a non-default FQN associated
|
||||
var fqn addrs.Provider
|
||||
if existing, exists := module.ProviderRequirements[addr.LocalName]; exists {
|
||||
fqn = existing.Type
|
||||
} else {
|
||||
fqn = addrs.NewLegacyProvider(addr.LocalName)
|
||||
}
|
||||
|
||||
fqn := module.ProviderForLocalConfig(addr)
|
||||
if _, exists := providers[fqn]; exists {
|
||||
// Explicit dependency already present
|
||||
continue
|
||||
|
@ -138,14 +124,7 @@ func configTreeConfigDependencies(root *configs.Config, inheritProviders map[str
|
|||
}
|
||||
for _, rc := range module.DataResources {
|
||||
addr := rc.ProviderConfigAddr()
|
||||
//look up the provider localname in the provider requirements map and see if
|
||||
//there is a non-default FQN associated
|
||||
var fqn addrs.Provider
|
||||
if existing, exists := module.ProviderRequirements[addr.LocalName]; exists {
|
||||
fqn = existing.Type
|
||||
} else {
|
||||
fqn = addrs.NewLegacyProvider(addr.LocalName)
|
||||
}
|
||||
fqn := module.ProviderForLocalConfig(addr)
|
||||
if _, exists := providers[fqn]; exists {
|
||||
// Explicit dependency already present
|
||||
continue
|
||||
|
|
|
@ -673,14 +673,15 @@ func (t *ProviderConfigTransformer) addProxyProviders(g *Graph, c *configs.Confi
|
|||
// legacy-style providers, and will instead need to lookup fqns from the
|
||||
// config when that information is available.
|
||||
//fullAddr := pair.InChild.Addr().Absolute(instPath)
|
||||
fqn := c.Module.ProviderForLocalConfig(pair.InChild.Addr())
|
||||
fullAddr := addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider(pair.InChild.Addr().LocalName),
|
||||
Provider: fqn,
|
||||
Module: instPath,
|
||||
Alias: pair.InChild.Addr().Alias,
|
||||
}
|
||||
|
||||
fullParentAddr := addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider(pair.InParent.Addr().LocalName),
|
||||
Provider: fqn,
|
||||
Module: parentInstPath,
|
||||
Alias: pair.InParent.Addr().Alias,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue