build: update to go1.20 (#16029)

* build: update to go1.20

* build: use stringy go1.20 in circle yaml

* tests: handle new x509 certificate error structure in go1.20

* cl: add cl entry
This commit is contained in:
Seth Hoenig 2023-02-03 08:14:53 -06:00 committed by GitHub
parent d2a9fbf03d
commit 911700ffea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 18 deletions

3
.changelog/16029.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
build: Update to go1.20
```

View File

@ -450,7 +450,7 @@ executors:
go:
working_directory: /go/src/github.com/hashicorp/nomad
docker:
- image: docker.mirror.hashicorp.services/golang:1.19.5
- image: docker.mirror.hashicorp.services/golang:1.20
resource_class: medium
environment:
<<: *common_envs
@ -463,7 +463,7 @@ executors:
resource_class: large
environment: &machine_env
<<: *common_envs
GOLANG_VERSION: 1.19.5
GOLANG_VERSION: '1.20'
go-macos:
working_directory: ~/go/src/github.com/hashicorp/nomad
@ -472,7 +472,7 @@ executors:
environment:
<<: *common_envs
GOPATH: /Users/distiller/go
GOLANG_VERSION: 1.19.5
GOLANG_VERSION: '1.20'
go-windows:
machine:
@ -484,7 +484,7 @@ executors:
GOPATH: c:\gopath
GOBIN: c:\gopath\bin
GOTESTSUM_PATH: c:\tmp\test-reports
GOLANG_VERSION: 1.19.5
GOLANG_VERSION: '1.20'
GOTESTSUM_VERSION: 1.7.0
VAULT_VERSION: 1.4.1

View File

@ -1 +1 @@
1.19.5
1.20

View File

@ -743,6 +743,7 @@ func TestHTTP_VerifyHTTPSClient(t *testing.T) {
CertFile: foocert,
KeyFile: fookey,
}
c.LogLevel = "off"
})
defer s.Shutdown()
@ -758,7 +759,9 @@ func TestHTTP_VerifyHTTPSClient(t *testing.T) {
if !ok {
t.Fatalf("expected a *url.Error but received: %T -> %v", err, err)
}
hostErr, ok := urlErr.Err.(x509.HostnameError)
cveErr := (urlErr.Err.(*tls.CertificateVerificationError)).Err
hostErr, ok := cveErr.(x509.HostnameError)
if !ok {
t.Fatalf("expected a x509.HostnameError but received: %T -> %v", urlErr.Err, urlErr.Err)
}
@ -786,7 +789,9 @@ func TestHTTP_VerifyHTTPSClient(t *testing.T) {
if !ok {
t.Fatalf("expected a *url.Error but received: %T -> %v", err, err)
}
_, ok = urlErr.Err.(x509.UnknownAuthorityError)
cveErr = (urlErr.Err.(*tls.CertificateVerificationError)).Err
_, ok = cveErr.(x509.UnknownAuthorityError)
if !ok {
t.Fatalf("expected a x509.UnknownAuthorityError but received: %T -> %v", urlErr.Err, urlErr.Err)
}

View File

@ -5,7 +5,7 @@ import (
"github.com/hashicorp/nomad/ci"
"github.com/mitchellh/cli"
"github.com/stretchr/testify/require"
"github.com/shoenig/test/must"
)
var _ cli.Command = &OperatorMetricsCommand{}
@ -73,19 +73,19 @@ func TestCommand_Metrics_Cases(t *testing.T) {
[]string{"-address=http://foo"},
1,
"",
"dial tcp: lookup foo: Temporary failure in name resolution",
"dial tcp: lookup foo", // dns resolution error messages changes with Go, OS version
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
code := cmd.Run(c.args)
out := ui.OutputWriter.String()
outerr := ui.ErrorWriter.String()
stdOut := ui.OutputWriter.String()
stdErr := ui.ErrorWriter.String()
require.Equalf(t, code, c.expectedCode, "expected exit code %d, got: %d: %s", c.expectedCode, code, outerr)
require.Contains(t, out, c.expectedOutput, "expected output \"%s\", got \"%s\"", c.expectedOutput, out)
require.Containsf(t, outerr, c.expectedError, "expected error \"%s\", got \"%s\"", c.expectedError, outerr)
must.Eq(t, code, c.expectedCode, must.Sprintf("expected exit code %d, got: %d: %s", c.expectedCode, code, stdErr))
must.StrContains(t, stdOut, c.expectedOutput)
must.StrContains(t, stdErr, c.expectedError)
ui.OutputWriter.Reset()
ui.ErrorWriter.Reset()

View File

@ -30,7 +30,7 @@ A development environment is supplied via Vagrant to make getting started easier
Developing without Vagrant
---
1. Install [Go 1.19.5+](https://golang.org/) *(Note: `gcc-go` is not supported)*
1. Install [Go 1.20+](https://golang.org/) *(Note: `gcc-go` is not supported)*
1. Clone this repo
```sh
$ git clone https://github.com/hashicorp/nomad.git

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/hashicorp/nomad
go 1.19
go 1.20
// Pinned dependencies are noted in github.com/hashicorp/nomad/issues/11826
replace (

View File

@ -56,7 +56,7 @@ REPO_PATH="${TMP_WORKSPACE}/gopath/src/github.com/hashicorp/nomad"
mkdir -p "${TMP_WORKSPACE}/tmp"
install_go() {
local go_version="1.19.5"
local go_version="1.20"
local download=
download="https://storage.googleapis.com/golang/go${go_version}.darwin-amd64.tar.gz"

View File

@ -3,7 +3,7 @@
set -o errexit
function install_go() {
local go_version="1.19.5"
local go_version="1.20"
local download="https://storage.googleapis.com/golang/go${go_version}.linux-amd64.tar.gz"
if go version 2>&1 | grep -q "${go_version}"; then