Files
Packer-Cn/packer/plugin_folders.go
Lucas Bajolet 94aaff44a1 packer: only support one directory for plugins
Since we're removing the alternative plugin installation directories in
favour of only supporting installing them in the PACKER_PLUGIN_PATH
directory, we only return one directory when getting the known plugin
directories.
2024-03-01 09:04:15 -05:00

28 lines
576 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package packer
import (
"log"
"os"
"path/filepath"
"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 != "" {
return packerPluginPath, nil
}
cd, err := pathing.ConfigDir()
if err != nil {
log.Printf("[ERR] Error loading config directory: %v", err)
return "", err
}
return filepath.Join(cd, "plugins"), nil
}