backport of commit 172fab6ddd

This commit is contained in:
Wilken Rivera
2023-06-22 19:43:06 +00:00
parent 2b0ba10121
commit 1d3e5d060e
3 changed files with 6 additions and 7 deletions
+1 -2
View File
@@ -6,7 +6,6 @@ package packer
import (
"crypto/sha256"
"encoding/json"
"errors"
"fmt"
"log"
"os"
@@ -81,7 +80,7 @@ func (c *PluginConfig) Discover() error {
}
if len(c.KnownPluginFolders) == 0 {
return errors.New("no known plugin folders defined")
c.KnownPluginFolders = PluginFolders()
}
// TODO after JSON is deprecated remove support for legacy component plugins.
-1
View File
@@ -24,7 +24,6 @@ func newPluginConfig() PluginConfig {
var conf PluginConfig
conf.PluginMinPort = 10000
conf.PluginMaxPort = 25000
conf.KnownPluginFolders = []string{os.TempDir()}
return conf
}
+5 -4
View File
@@ -16,6 +16,11 @@ import (
func PluginFolders(dirs ...string) []string {
res := []string{}
if packerPluginPath := os.Getenv("PACKER_PLUGIN_PATH"); packerPluginPath != "" {
res = append(res, strings.Split(packerPluginPath, string(os.PathListSeparator))...)
return res
}
if path, err := os.Executable(); err != nil {
log.Printf("[ERR] Error finding executable: %v", err)
} else {
@@ -30,9 +35,5 @@ func PluginFolders(dirs ...string) []string {
res = append(res, filepath.Join(cd, "plugins"))
}
if packerPluginPath := os.Getenv("PACKER_PLUGIN_PATH"); packerPluginPath != "" {
res = append(res, strings.Split(packerPluginPath, string(os.PathListSeparator))...)
}
return res
}