mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-19 14:31:40 -04:00
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.
28 lines
576 B
Go
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
|
|
}
|