Merge pull request #8543 from TJM/fix_external

Fix permission denied for external plugins, path was empty
This commit is contained in:
Megan Marsh 2020-01-06 14:05:02 -08:00 committed by GitHub
commit 99caaf6cc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 18 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 := range pluginPaths { for pluginName, pluginPath := range pluginPaths {
plugin := plugin 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(pluginPaths[plugin]).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 := range pluginPaths { for pluginName, pluginPath := range pluginPaths {
plugin := plugin 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(pluginPaths[plugin]).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 := range pluginPaths { for pluginName, pluginPath := range pluginPaths {
plugin := plugin 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(pluginPaths[plugin]).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