diff --git a/command/command.go b/command/command.go index bb8c7be5c..0fbb44df3 100644 --- a/command/command.go +++ b/command/command.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "os" + "runtime" "github.com/hashicorp/terraform/terraform" "github.com/mitchellh/cli" @@ -19,10 +20,13 @@ const DefaultDataDir = ".terraform" // of directories supplied by the user with the `-plugin-dir` flag during init. const PluginPathFile = "plugin_path" +// pluginMachineName is the directory name used in new plugin paths. +const pluginMachineName = runtime.GOOS + "_" + runtime.GOARCH + // DefaultPluginVendorDir is the location in the config directory to look for // user-added plugin binaries. Terraform only reads from this path if it // exists, it is never created by terraform. -const DefaultPluginVendorDir = "terraform.d/plugins" +const DefaultPluginVendorDir = "terraform.d/plugins/" + pluginMachineName // DefaultStateFilename is the default filename used for the state file. const DefaultStateFilename = "terraform.tfstate" diff --git a/command/init_test.go b/command/init_test.go index dd296d945..bf1d0dfca 100644 --- a/command/init_test.go +++ b/command/init_test.go @@ -519,11 +519,7 @@ func TestInit_findVendoredProviders(t *testing.T) { if err := os.MkdirAll(c.pluginDir(), 0755); err != nil { t.Fatal(err) } - vendorMachineDir := filepath.Join( - DefaultPluginVendorDir, - fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH), - ) - if err := os.MkdirAll(vendorMachineDir, 0755); err != nil { + if err := os.MkdirAll(DefaultPluginVendorDir, 0755); err != nil { t.Fatal(err) } @@ -534,7 +530,7 @@ func TestInit_findVendoredProviders(t *testing.T) { t.Fatal(err) } // the vendor path - greaterThanPath := filepath.Join(vendorMachineDir, "terraform-provider-greater_than_v2.3.4_x4") + greaterThanPath := filepath.Join(DefaultPluginVendorDir, "terraform-provider-greater_than_v2.3.4_x4") if err := ioutil.WriteFile(greaterThanPath, []byte("test bin"), 0755); err != nil { t.Fatal(err) }