From ba20d15dd3afb5d76443144d3744e83c83b5f62a Mon Sep 17 00:00:00 2001 From: Scott Macfarlane <36851+smacfarlane@users.noreply.github.com> Date: Mon, 9 May 2022 23:49:42 -0700 Subject: [PATCH] Support releases-api returned content-type (#57) * Support releases-api returned content-type Signed-off-by: Scott Macfarlane * Set Go to v1.18 when building consul from source Signed-off-by: Scott Macfarlane * remove unused variables Co-authored-by: Radek Simko --- internal/releasesjson/releases.go | 4 ++-- product/consul.go | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/releasesjson/releases.go b/internal/releasesjson/releases.go index 24e32ff..849f16a 100644 --- a/internal/releasesjson/releases.go +++ b/internal/releasesjson/releases.go @@ -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) } @@ -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) } diff --git a/product/consul.go b/product/consul.go index b619d89..aeeac94 100644 --- a/product/consul.go +++ b/product/consul.go @@ -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{ @@ -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}, }, }