Skip to content

Commit

Permalink
Support releases-api returned content-type (#57)
Browse files Browse the repository at this point in the history
* Support releases-api returned content-type

Signed-off-by: Scott Macfarlane <smacfarlane@hashicorp.com>

* Set Go to v1.18 when building consul from source

Signed-off-by: Scott Macfarlane <smacfarlane@hashicorp.com>

* remove unused variables

Co-authored-by: Radek Simko <radek.simko@gmail.com>
  • Loading branch information
smacfarlane and radeksimko committed May 10, 2022
1 parent 099cd34 commit ba20d15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/releasesjson/releases.go
Expand Up @@ -79,7 +79,7 @@ func (r *Releases) ListProductVersions(ctx context.Context, productName string)
}

contentType := resp.Header.Get("content-type")
if contentType != "application/json" {
if contentType != "application/json" && contentType != "application/vnd+hashicorp.releases-api.v0+json" {
return nil, fmt.Errorf("unexpected Content-Type: %q", contentType)
}

Expand Down Expand Up @@ -144,7 +144,7 @@ func (r *Releases) GetProductVersion(ctx context.Context, product string, versio
}

contentType := resp.Header.Get("content-type")
if contentType != "application/json" {
if contentType != "application/json" && contentType != "application/vnd+hashicorp.releases-api.v0+json" {
return nil, fmt.Errorf("unexpected Content-Type: %q", contentType)
}

Expand Down
6 changes: 2 additions & 4 deletions product/consul.go
Expand Up @@ -15,9 +15,7 @@ import (
var consulVersionOutputRe = regexp.MustCompile(`Consul ` + simpleVersionRe)

var (
v1_16 = version.Must(version.NewVersion("1.16"))
// TODO: version.MustConstraint() ?
v1_16c, _ = version.NewConstraint("1.16")
v1_18 = version.Must(version.NewVersion("1.18"))
)

var Consul = Product{
Expand Down Expand Up @@ -52,6 +50,6 @@ var Consul = Product{
BuildInstructions: &BuildInstructions{
GitRepoURL: "https://github.com/hashicorp/consul.git",
PreCloneCheck: &build.GoIsInstalled{},
Build: &build.GoBuild{Version: v1_16},
Build: &build.GoBuild{Version: v1_18},
},
}

0 comments on commit ba20d15

Please sign in to comment.