simplify the use of configuration_aliases

Now that the possibility of extra provider nodes being added is gone, we
can skip the separate handling of configuration_aliases in the
ProviderConfigTransformer. Instead of adding concrete provider nodes for
configuration_aliases (which could be surprising later as the code
evolves), we implicitly add them based on the providers being passed in
by the parent module, using the same mechanism as non-aliased providers.

We can know that the `providers` map will be populated, because the
provider structures are validated while loading the configuration.
This commit is contained in:
James Bardin 2021-02-18 12:43:31 -05:00
parent b1d8d856ca
commit 8c1703d8df
1 changed files with 0 additions and 42 deletions

View File

@ -567,43 +567,6 @@ func (t *ProviderConfigTransformer) transformSingle(g *Graph, c *configs.Config)
t.proxiable[key] = !diags.HasErrors() t.proxiable[key] = !diags.HasErrors()
} }
if mod.ProviderRequirements != nil {
// Add implied provider configs from the required_providers
// Since we're still treating empty configs as proxies, we can just add
// these as empty configs too. We'll ensure that these are given a
// configuration during validation to prevent them from becoming
// fully-fledged config instances.
for _, p := range mod.ProviderRequirements.RequiredProviders {
for _, aliasAddr := range p.Aliases {
addr := addrs.AbsProviderConfig{
Provider: mod.ProviderForLocalConfig(aliasAddr),
Module: path,
Alias: aliasAddr.Alias,
}
key := addr.String()
if _, ok := t.providers[key]; ok {
continue
}
abstract := &NodeAbstractProvider{
Addr: addr,
}
var v dag.Vertex
if t.Concrete != nil {
v = t.Concrete(abstract)
} else {
v = abstract
}
// Add it to the graph
g.Add(v)
t.providers[key] = v.(GraphNodeProvider)
t.proxiable[key] = true
}
}
}
// Now replace the provider nodes with proxy nodes if a provider was being // Now replace the provider nodes with proxy nodes if a provider was being
// passed in, and create implicit proxies if there was no config. Any extra // passed in, and create implicit proxies if there was no config. Any extra
// proxies will be removed in the prune step. // proxies will be removed in the prune step.
@ -680,11 +643,6 @@ func (t *ProviderConfigTransformer) addProxyProviders(g *Graph, c *configs.Confi
continue continue
} }
// aliased configurations can't be implicitly passed in
if fullAddr.Alias != "" {
continue
}
// There was no concrete provider, so add this as an implicit provider. // There was no concrete provider, so add this as an implicit provider.
// The extra proxy will be pruned later if it's unused. // The extra proxy will be pruned later if it's unused.
g.Add(proxy) g.Add(proxy)