mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-04-24 09:02:13 -04:00
* Use ~/.opentf.d instead of ~/.terraform.d Stay backwards-compatible, though. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Fix imports. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Add tests. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Use util function. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Fix windows directories. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Add a comment to the tests. Signed-off-by: Jakub Martin <kubam@spacelift.io> --------- Signed-off-by: Jakub Martin <kubam@spacelift.io>
35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"path/filepath"
|
|
"runtime"
|
|
|
|
"github.com/placeholderplaceholderplaceholder/opentf/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 ~/.opentf.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
|
|
}
|