mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
ffe056bacb
This is part of a general effort to move all of Terraform's non-library package surface under internal in order to reinforce that these are for internal use within Terraform only. If you were previously importing packages under this prefix into an external codebase, you could pin to an earlier release tag as an interim solution until you've make a plan to achieve the same functionality some other way.
32 lines
954 B
Go
32 lines
954 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"path/filepath"
|
|
"runtime"
|
|
|
|
"github.com/hashicorp/terraform/internal/command/cliconfig"
|
|
)
|
|
|
|
// globalPluginDirs returns directories that should be searched for
|
|
// globally-installed plugins (not specific to the current configuration).
|
|
//
|
|
// Earlier entries in this slice get priority over later when multiple copies
|
|
// of the same plugin version are found, but newer versions always override
|
|
// older versions where both satisfy the provider version constraints.
|
|
func globalPluginDirs() []string {
|
|
var ret []string
|
|
// Look in ~/.terraform.d/plugins/ , or its equivalent on non-UNIX
|
|
dir, err := cliconfig.ConfigDir()
|
|
if err != nil {
|
|
log.Printf("[ERROR] Error finding global config directory: %s", err)
|
|
} else {
|
|
machineDir := fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH)
|
|
ret = append(ret, filepath.Join(dir, "plugins"))
|
|
ret = append(ret, filepath.Join(dir, "plugins", machineDir))
|
|
}
|
|
|
|
return ret
|
|
}
|