From fe3aff91f355622e216f0d835df28985572aeb77 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 5 Jan 2018 11:52:11 -0500 Subject: [PATCH] missingPlugins should not return internal plugins Filter the internal plugins out beforehand, so we don't attempt to locate them at all during init. --- command/init.go | 12 ++++-------- command/plugins.go | 11 +++++++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/command/init.go b/command/init.go index 66b1c7028a..839d27e2db 100644 --- a/command/init.go +++ b/command/init.go @@ -306,7 +306,6 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade )) missing := c.missingPlugins(available, requirements) - internal := c.internalProviders() var errs error if c.getPlugins { @@ -316,12 +315,6 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade } 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) 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 // fail with an error instructing the user to re-run this command. 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{} for name, meta := range chosen { digest, err := meta.SHA256() diff --git a/command/plugins.go b/command/plugins.go index 5eba6b6988..7306473135 100644 --- a/command/plugins.go +++ b/command/plugins.go @@ -272,13 +272,16 @@ func (m *Meta) internalProviders() map[string]terraform.ResourceProviderFactory func (m *Meta) missingPlugins(avail discovery.PluginMetaSet, reqd discovery.PluginRequirements) 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) + internal := m.internalProviders() 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 { missing[name] = versionSet }