diff --git a/plugin/discovery/get.go b/plugin/discovery/get.go index 2eff52d814..ee08786b95 100644 --- a/plugin/discovery/get.go +++ b/plugin/discovery/get.go @@ -19,14 +19,12 @@ import ( // Releases are located by parsing the html listing from releases.hashicorp.com. // // The URL for releases follows the pattern: -// https://releases.hashicorp.com/terraform-providers/terraform-provider-name/ + -// terraform-provider-name_/terraform-provider-name___. +// https://releases.hashicorp.com/terraform-provider-name//terraform-provider-name___. // // The plugin protocol version will be saved with the release and returned in // the header X-TERRAFORM_PROTOCOL_VERSION. -const providersPath = "/terraform-providers/" -const protocolVersionHeader = "X-TERRAFORM_PROTOCOL_VERSION" +const protocolVersionHeader = "x-terraform-protocol-version" var releaseHost = "https://releases.hashicorp.com" @@ -39,18 +37,17 @@ func providerName(name string) string { } // providerVersionsURL returns the path to the released versions directory for the provider: -// https://releases.hashicorp.com/terraform-providers/terraform-provider-name/ +// https://releases.hashicorp.com/terraform-provider-name/ func providerVersionsURL(name string) string { - return releaseHost + providersPath + providerName(name) + "/" + return releaseHost + "/" + providerName(name) + "/" } // providerURL returns the full path to the provider file, using the current OS // and ARCH: // .../terraform-provider-name_/terraform-provider-name___. func providerURL(name, version string) string { - versionDir := fmt.Sprintf("%s_%s", providerName(name), version) fileName := fmt.Sprintf("%s_%s_%s_%s.zip", providerName(name), version, runtime.GOOS, runtime.GOARCH) - u := fmt.Sprintf("%s%s/%s", providerVersionsURL(name), versionDir, fileName) + u := fmt.Sprintf("%s%s/%s", providerVersionsURL(name), version, fileName) return u } diff --git a/plugin/discovery/get_test.go b/plugin/discovery/get_test.go index 879be9ab27..af41318d13 100644 --- a/plugin/discovery/get_test.go +++ b/plugin/discovery/get_test.go @@ -25,18 +25,18 @@ func testListingHandler(w http.ResponseWriter, r *http.Request) { // returns a 200 for a valid provider url, using the patch number for the // plugin protocol version. func testHandler(w http.ResponseWriter, r *http.Request) { - if r.URL.Path == "/terraform-providers/terraform-provider-test/" { + if r.URL.Path == "/terraform-provider-test/" { testListingHandler(w, r) return } parts := strings.Split(r.URL.Path, "/") - if len(parts) != 5 { + if len(parts) != 4 { http.Error(w, "not found", http.StatusNotFound) return } - filename := parts[4] + filename := parts[3] reg := regexp.MustCompile(`(terraform-provider-test_(\d).(\d).(\d)_([^_]+)_([^._]+)).zip`) @@ -60,7 +60,7 @@ func testHandler(w http.ResponseWriter, r *http.Request) { func testReleaseServer() *httptest.Server { handler := http.NewServeMux() - handler.HandleFunc("/terraform-providers/terraform-provider-test/", testHandler) + handler.HandleFunc("/terraform-provider-test/", testHandler) return httptest.NewServer(handler) }