mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
missingPlugins should not return internal plugins
Filter the internal plugins out beforehand, so we don't attempt to locate them at all during init.
This commit is contained in:
parent
5a975d9997
commit
fe3aff91f3
@ -306,7 +306,6 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade
|
|||||||
))
|
))
|
||||||
|
|
||||||
missing := c.missingPlugins(available, requirements)
|
missing := c.missingPlugins(available, requirements)
|
||||||
internal := c.internalProviders()
|
|
||||||
|
|
||||||
var errs error
|
var errs error
|
||||||
if c.getPlugins {
|
if c.getPlugins {
|
||||||
@ -316,12 +315,6 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade
|
|||||||
}
|
}
|
||||||
|
|
||||||
for provider, reqd := range missing {
|
for provider, reqd := range missing {
|
||||||
if _, isInternal := internal[provider]; isInternal {
|
|
||||||
// Ignore internal providers; they are not eligible for
|
|
||||||
// installation.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := c.providerInstaller.Get(provider, reqd.Versions)
|
_, err := c.providerInstaller.Get(provider, reqd.Versions)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -379,7 +372,10 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade
|
|||||||
// again. If anything changes, other commands that use providers will
|
// again. If anything changes, other commands that use providers will
|
||||||
// fail with an error instructing the user to re-run this command.
|
// fail with an error instructing the user to re-run this command.
|
||||||
available = c.providerPluginSet() // re-discover to see newly-installed plugins
|
available = c.providerPluginSet() // re-discover to see newly-installed plugins
|
||||||
chosen := choosePlugins(available, internal, requirements)
|
|
||||||
|
// internal providers were already filtered out, since we don't need to get them.
|
||||||
|
chosen := choosePlugins(available, nil, requirements)
|
||||||
|
|
||||||
digests := map[string][]byte{}
|
digests := map[string][]byte{}
|
||||||
for name, meta := range chosen {
|
for name, meta := range chosen {
|
||||||
digest, err := meta.SHA256()
|
digest, err := meta.SHA256()
|
||||||
|
@ -272,13 +272,16 @@ func (m *Meta) internalProviders() map[string]terraform.ResourceProviderFactory
|
|||||||
func (m *Meta) missingPlugins(avail discovery.PluginMetaSet, reqd discovery.PluginRequirements) discovery.PluginRequirements {
|
func (m *Meta) missingPlugins(avail discovery.PluginMetaSet, reqd discovery.PluginRequirements) discovery.PluginRequirements {
|
||||||
missing := make(discovery.PluginRequirements)
|
missing := make(discovery.PluginRequirements)
|
||||||
|
|
||||||
for n, r := range reqd {
|
|
||||||
log.Printf("[DEBUG] plugin requirements: %q=%q", n, r.Versions)
|
|
||||||
}
|
|
||||||
|
|
||||||
candidates := avail.ConstrainVersions(reqd)
|
candidates := avail.ConstrainVersions(reqd)
|
||||||
|
internal := m.internalProviders()
|
||||||
|
|
||||||
for name, versionSet := range reqd {
|
for name, versionSet := range reqd {
|
||||||
|
// internal providers can't be missing
|
||||||
|
if _, ok := internal[name]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] plugin requirements: %q=%q", name, versionSet.Versions)
|
||||||
if metas := candidates[name]; metas.Count() == 0 {
|
if metas := candidates[name]; metas.Count() == 0 {
|
||||||
missing[name] = versionSet
|
missing[name] = versionSet
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user