Fix names of range variables to reduce confusion and remove overriden plugin name

This commit is contained in:
Tommy McNeely 2020-01-06 13:12:23 -07:00
parent 72112ccae2
commit 469a4d2a11
1 changed files with 15 additions and 15 deletions

View File

@ -131,12 +131,12 @@ func (c *config) discoverExternalComponents(path string) error {
if err != nil { if err != nil {
return err return err
} }
for plugin, path := range pluginPaths { for pluginName, pluginPath := range pluginPaths {
newPath := path // this needs to be stored in a new variable for the func below newPath := pluginPath // this needs to be stored in a new variable for the func below
c.Builders[plugin] = func() (packer.Builder, error) { c.Builders[pluginName] = func() (packer.Builder, error) {
return c.pluginClient(newPath).Builder() return c.pluginClient(newPath).Builder()
} }
externallyUsed = append(externallyUsed, plugin) externallyUsed = append(externallyUsed, pluginName)
} }
if len(externallyUsed) > 0 { if len(externallyUsed) > 0 {
sort.Strings(externallyUsed) sort.Strings(externallyUsed)
@ -148,12 +148,12 @@ func (c *config) discoverExternalComponents(path string) error {
if err != nil { if err != nil {
return err return err
} }
for plugin, path := range pluginPaths { for pluginName, pluginPath := range pluginPaths {
newPath := path // this needs to be stored in a new variable for the func below newPath := pluginPath // this needs to be stored in a new variable for the func below
c.PostProcessors[plugin] = func() (packer.PostProcessor, error) { c.PostProcessors[pluginName] = func() (packer.PostProcessor, error) {
return c.pluginClient(newPath).PostProcessor() return c.pluginClient(newPath).PostProcessor()
} }
externallyUsed = append(externallyUsed, plugin) externallyUsed = append(externallyUsed, pluginName)
} }
if len(externallyUsed) > 0 { if len(externallyUsed) > 0 {
sort.Strings(externallyUsed) sort.Strings(externallyUsed)
@ -165,12 +165,12 @@ func (c *config) discoverExternalComponents(path string) error {
if err != nil { if err != nil {
return err return err
} }
for plugin, path := range pluginPaths { for pluginName, pluginPath := range pluginPaths {
newPath := path // this needs to be stored in a new variable for the func below newPath := pluginPath // this needs to be stored in a new variable for the func below
c.Provisioners[plugin] = func() (packer.Provisioner, error) { c.Provisioners[pluginName] = func() (packer.Provisioner, error) {
return c.pluginClient(newPath).Provisioner() return c.pluginClient(newPath).Provisioner()
} }
externallyUsed = append(externallyUsed, plugin) externallyUsed = append(externallyUsed, pluginName)
} }
if len(externallyUsed) > 0 { if len(externallyUsed) > 0 {
sort.Strings(externallyUsed) sort.Strings(externallyUsed)
@ -209,9 +209,9 @@ func (c *config) discoverSingle(glob string) (map[string]string, error) {
} }
// Look for foo-bar-baz. The plugin name is "baz" // Look for foo-bar-baz. The plugin name is "baz"
plugin := file[len(prefix):] pluginName := file[len(prefix):]
log.Printf("[DEBUG] Discovered plugin: %s = %s", plugin, match) log.Printf("[DEBUG] Discovered plugin: %s = %s", pluginName, match)
res[plugin] = match res[pluginName] = match
} }
return res, nil return res, nil