From 911700ffea097b22be257033de8c887d58fdd522 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Fri, 3 Feb 2023 08:14:53 -0600 Subject: [PATCH] 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 --- .changelog/16029.txt | 3 +++ .circleci/config.yml | 8 ++++---- .go-version | 2 +- command/agent/http_test.go | 9 +++++++-- command/metrics_test.go | 14 +++++++------- contributing/README.md | 2 +- go.mod | 2 +- scripts/release/mac-remote-build | 2 +- scripts/vagrant-linux-priv-go.sh | 2 +- 9 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 .changelog/16029.txt diff --git a/.changelog/16029.txt b/.changelog/16029.txt new file mode 100644 index 000000000..5e6d05904 --- /dev/null +++ b/.changelog/16029.txt @@ -0,0 +1,3 @@ +```release-note:improvement +build: Update to go1.20 +``` diff --git a/.circleci/config.yml b/.circleci/config.yml index 02cedb3db..4832e78cd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/.go-version b/.go-version index 83d5e73f0..5fb5a6b4f 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.19.5 +1.20 diff --git a/command/agent/http_test.go b/command/agent/http_test.go index 05fe2929b..6c7b61221 100644 --- a/command/agent/http_test.go +++ b/command/agent/http_test.go @@ -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) } diff --git a/command/metrics_test.go b/command/metrics_test.go index 4412f1e50..f899fa3e7 100644 --- a/command/metrics_test.go +++ b/command/metrics_test.go @@ -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() diff --git a/contributing/README.md b/contributing/README.md index f0557e912..5075d8f95 100644 --- a/contributing/README.md +++ b/contributing/README.md @@ -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 diff --git a/go.mod b/go.mod index 8358cc147..c8e62e614 100644 --- a/go.mod +++ b/go.mod @@ -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 ( diff --git a/scripts/release/mac-remote-build b/scripts/release/mac-remote-build index 955f50905..75f369379 100755 --- a/scripts/release/mac-remote-build +++ b/scripts/release/mac-remote-build @@ -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" diff --git a/scripts/vagrant-linux-priv-go.sh b/scripts/vagrant-linux-priv-go.sh index 537adbeb0..0fc56c94e 100755 --- a/scripts/vagrant-linux-priv-go.sh +++ b/scripts/vagrant-linux-priv-go.sh @@ -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