swap ordering so PACKER_PLUGIN_PATH gets precedence

This commit is contained in:
Megan Marsh 2020-01-17 12:40:30 -08:00
parent 83ecebbf37
commit a163ff7388
1 changed files with 16 additions and 16 deletions

View File

@ -123,22 +123,6 @@ func (c *config) Discover() error {
return nil
}
// First, check whether there is a custom Plugin directory defined. This gets
// absolute preference.
if packerPluginPath := os.Getenv("PACKER_PLUGIN_PATH"); packerPluginPath != "" {
sep := ":"
if runtime.GOOS == "windows" {
// on windows, PATH is semicolon-separated
sep = ";"
}
plugPaths := strings.Split(packerPluginPath, sep)
for _, plugPath := range plugPaths {
if err := c.discoverExternalComponents(plugPath); err != nil {
return err
}
}
}
// Next, look in the same directory as the executable.
exePath, err := osext.Executable()
if err != nil {
@ -164,6 +148,22 @@ func (c *config) Discover() error {
return err
}
// Check whether there is a custom Plugin directory defined. This gets
// absolute preference.
if packerPluginPath := os.Getenv("PACKER_PLUGIN_PATH"); packerPluginPath != "" {
sep := ":"
if runtime.GOOS == "windows" {
// on windows, PATH is semicolon-separated
sep = ";"
}
plugPaths := strings.Split(packerPluginPath, sep)
for _, plugPath := range plugPaths {
if err := c.discoverExternalComponents(plugPath); err != nil {
return err
}
}
}
// Finally, try to use an internal plugin. Note that this will not override
// any previously-loaded plugins.
if err := c.discoverInternalComponents(); err != nil {