mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
fix releases path and protocol header
Last minute change to the location of the binaries
This commit is contained in:
parent
a529b64cc8
commit
1b201e67ea
@ -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_<x.y.z>/terraform-provider-name_<x.y.z>_<os>_<arch>.<ext>
|
||||
// https://releases.hashicorp.com/terraform-provider-name/<x.y.z>/terraform-provider-name_<x.y.z>_<os>_<arch>.<ext>
|
||||
//
|
||||
// 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_<x.y.z>/terraform-provider-name_<x.y.z>_<os>_<arch>.<ext>
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user