forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugins.go
31 lines (27 loc) · 945 Bytes
/
plugins.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"fmt"
"log"
"path/filepath"
"runtime"
"github.com/hashicorp/terraform/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
}