Permalink
Cannot retrieve contributors at this time
31 lines (27 sloc)
954 Bytes
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |