terraform: ProviderTransform gets provider fqn from module
Added configs.Module.ProviderForLocalProviderConfig which allows terraform.ProviderTransformer to get the provider FQN from the module, instead of assuming NewLegacyProvider.
This commit is contained in:
parent
c02a898994
commit
6e2618d9be
|
@ -457,3 +457,11 @@ func (m *Module) LocalNameForProvider(p addrs.Provider) string {
|
||||||
return p.Type
|
return p.Type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ProviderForLocalConfig returns the provider FQN for a given LocalProviderConfig
|
||||||
|
func (m *Module) ProviderForLocalConfig(pc addrs.LocalProviderConfig) addrs.Provider {
|
||||||
|
if provider, exists := m.ProviderRequirements[pc.String()]; exists {
|
||||||
|
return provider.Type
|
||||||
|
}
|
||||||
|
return addrs.NewLegacyProvider(pc.LocalName)
|
||||||
|
}
|
||||||
|
|
|
@ -587,12 +587,7 @@ func (t *ProviderConfigTransformer) transformSingle(g *Graph, c *configs.Config)
|
||||||
|
|
||||||
// add all providers from the configuration
|
// add all providers from the configuration
|
||||||
for _, p := range mod.ProviderConfigs {
|
for _, p := range mod.ProviderConfigs {
|
||||||
relAddr := p.Addr()
|
fqn := mod.ProviderForLocalConfig(p.Addr())
|
||||||
|
|
||||||
// FIXME: This relies on the assumption that all providers are
|
|
||||||
// LegacyProviders, and will instead need to lookup the FQN in the
|
|
||||||
// config from the provider local name when that is supported.
|
|
||||||
fqn := addrs.NewLegacyProvider(relAddr.LocalName)
|
|
||||||
addr := addrs.AbsProviderConfig{
|
addr := addrs.AbsProviderConfig{
|
||||||
Provider: fqn,
|
Provider: fqn,
|
||||||
Alias: p.Alias,
|
Alias: p.Alias,
|
||||||
|
|
Loading…
Reference in New Issue