Skip to content

Commit

Permalink
packer: error multiple paths in PACKER_PLUGIN_PATH
Browse files Browse the repository at this point in the history
When a user defines PACKER_PLUGIN_PATH in their environment, we need to
error if their path defines multiple directories separated by `:`.

This used to be supported, but this is removed with 1.11 as we're
simplifying the loading process for plugins, so we opted to fall-back to
only one plugin directory supported.
  • Loading branch information
lbajolet-hashicorp committed May 10, 2024
1 parent 5ced785 commit f80ba28
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packer/plugin_folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@
package packer

import (
"fmt"
"log"
"os"
"path/filepath"
"strings"

"github.com/hashicorp/packer-plugin-sdk/pathing"
)

// PluginFolder returns the known plugin folder based on system.
func PluginFolder() (string, error) {
if packerPluginPath := os.Getenv("PACKER_PLUGIN_PATH"); packerPluginPath != "" {
if strings.ContainsRune(packerPluginPath, os.PathListSeparator) {
return "", fmt.Errorf("Multiple paths are no longer supported for PACKER_PLUGIN_PATH.\n"+
"This should be defined as one of the following options for your environment:"+
"\n* PACKER_PLUGIN_PATH=%v", strings.Join(strings.Split(packerPluginPath, ":"), "\n* PACKER_PLUGIN_PATH="))
}

return packerPluginPath, nil
}

Expand Down

0 comments on commit f80ba28

Please sign in to comment.