From 5cd5c2c9ee3ca9fceb717106e24c15a8eeb78d1a Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Fri, 1 Oct 2021 09:41:25 -0400 Subject: [PATCH 1/3] build: Update to golang 1.17.1 --- .circleci/config.yml | 8 ++++---- contributing/README.md | 2 +- scripts/release/mac-remote-build | 2 +- scripts/update_golang_version.sh | 2 +- scripts/vagrant-linux-priv-go.sh | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2dd81ad025d..228ae36cd7e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -512,7 +512,7 @@ executors: go: working_directory: /go/src/github.com/hashicorp/nomad docker: - - image: docker.mirror.hashicorp.services/golang:1.16.7 + - image: docker.mirror.hashicorp.services/golang:1.17.1 environment: <<: *common_envs GOPATH: /go @@ -524,7 +524,7 @@ executors: environment: &machine_env <<: *common_envs GOPATH: /home/circleci/go - GOLANG_VERSION: 1.16.7 + GOLANG_VERSION: 1.17.1 # uses a more recent image with unattended upgrades disabled properly # but seems to break docker builds @@ -541,7 +541,7 @@ executors: environment: <<: *common_envs GOPATH: /Users/distiller/go - GOLANG_VERSION: 1.16.7 + GOLANG_VERSION: 1.17.1 go-windows: machine: @@ -553,7 +553,7 @@ executors: GOPATH: c:\gopath GOBIN: c:\gopath\bin GOTESTSUM_PATH: c:\tmp\test-reports - GOLANG_VERSION: 1.16.7 + GOLANG_VERSION: 1.17.1 GOTESTSUM_VERSION: 0.4.2 VAULT_VERSION: 1.4.1 diff --git a/contributing/README.md b/contributing/README.md index 4e9f8ebe89c..945e35d80c5 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.16.7+](https://golang.org/) *(Note: `gcc-go` is not supported)* +1. Install [Go 1.17.1+](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/scripts/release/mac-remote-build b/scripts/release/mac-remote-build index 92c3849ccb6..0222e2d4362 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.16.7" + local go_version="1.17.1" local download= download="https://storage.googleapis.com/golang/go${go_version}.darwin-amd64.tar.gz" diff --git a/scripts/update_golang_version.sh b/scripts/update_golang_version.sh index 7d60c34653a..89854b0ee0b 100755 --- a/scripts/update_golang_version.sh +++ b/scripts/update_golang_version.sh @@ -30,7 +30,7 @@ sed -i'' -e "s|go_version=\"*[^\"]*\"*$|go_version=\"${golang_version}\"|g" \ scripts/vagrant-linux-priv-go.sh scripts/release/mac-remote-build echo "--> Checking if there is any remaining references to old versions..." -if git grep -I --fixed-strings "${current_version}" | grep -v -e CHANGELOG.md -e vendor/ -e website/ -e ui/ -e contributing/golang.md -e '.*.go:' -e go.sum -e go.mod -e LICENSE +if git grep -I --fixed-strings "${current_version}" | grep -v -e CHANGELOG.md -e .changelog/ -e vendor/ -e website/ -e ui/ -e contributing/golang.md -e '.*.go:' -e go.sum -e go.mod -e LICENSE then echo " ^^ files may contain references to old golang version" >&2 echo " update script and run again" >&2 diff --git a/scripts/vagrant-linux-priv-go.sh b/scripts/vagrant-linux-priv-go.sh index 6ee1eaeca65..fd85d5bccbd 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.16.7" + local go_version="1.17.1" local download="https://storage.googleapis.com/golang/go${go_version}.linux-amd64.tar.gz" if go version 2>&1 | grep -q "${go_version}"; then From 6c414cd5f9113118084533d93905744355847c75 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Fri, 1 Oct 2021 09:59:55 -0400 Subject: [PATCH 2/3] gofmt all the files mostly to handle build directives in 1.17. --- api/namespace_test.go | 1 + api/quota_test.go | 1 + api/sentinel_test.go | 1 + build_linux_arm.go | 1 + client/allocdir/fs_unix.go | 1 + client/allocdir/task_dir_nonlinux.go | 1 + client/allocrunner/alloc_runner_unix_test.go | 1 + client/allocrunner/network_manager_nonlinux.go | 3 ++- client/allocrunner/networking_cni.go | 3 ++- client/allocrunner/networking_cni_test.go | 11 ++++++----- .../taskrunner/envoy_bootstrap_hook_test.go | 2 ++ .../taskrunner/logmon_hook_unix_test.go | 1 + client/allocrunner/taskrunner/sids_hook_test.go | 2 ++ client/allocrunner/testing.go | 1 + client/allocwatcher/alloc_watcher_unix_test.go | 1 + client/enterprise_client_oss.go | 1 + client/fingerprint/bridge_default.go | 1 + client/fingerprint/cgroup_default.go | 1 + client/fingerprint/cgroup_linux.go | 1 + client/fingerprint/cgroup_test.go | 1 + client/fingerprint/cpu_default.go | 3 ++- client/fingerprint/fingerprint_default.go | 1 + client/fingerprint/network_default.go | 1 + client/fingerprint/network_test.go | 2 +- client/fingerprint/storage_unix.go | 1 + client/lib/cgutil/cgutil_default.go | 1 + client/lib/cgutil/cpuset_manager_default.go | 1 + client/lib/fifo/fifo_unix.go | 1 + client/pluginmanager/drivermanager/testing.go | 1 + client/state/db_test.go | 2 +- command/agent/agent_oss.go | 1 + command/agent/config_oss.go | 1 + command/agent/consul/connect_proxies_test.go | 2 +- command/agent/host/darwin.go | 1 + command/agent/host/linux.go | 1 + command/agent/host/unix.go | 1 + command/agent/host/windows.go | 1 + command/agent/http_oss.go | 1 + command/agent/namespace_endpoint_test.go | 1 + command/agent/operator_endpoint_oss.go | 1 + command/agent/stub_asset.go | 1 + command/agent/testagent_oss.go | 1 + command/alloc_exec_unix.go | 1 + command/alloc_status_test.go | 10 +++++----- command/commands_oss.go | 1 + command/namespace_apply_test.go | 1 + command/namespace_delete_test.go | 1 + command/namespace_inspect_test.go | 1 + command/namespace_list_test.go | 1 + command/namespace_status_test.go | 1 + command/quota_delete_test.go | 1 + command/quota_inspect_test.go | 1 + command/quota_list_test.go | 1 + command/quota_status_test.go | 1 + drivers/docker/config_test.go | 4 ++-- drivers/docker/driver_default.go | 3 ++- drivers/docker/driver_test.go | 4 ++-- drivers/docker/driver_unix_test.go | 1 + drivers/docker/driver_windows_test.go | 1 + drivers/docker/util/stats_posix.go | 1 + drivers/docker/utils_unix_test.go | 1 + drivers/docker/utils_windows_test.go | 1 + drivers/exec/driver_unix_test.go | 1 + drivers/rawexec/driver_unix_test.go | 1 + drivers/shared/executor/executor_basic.go | 1 + drivers/shared/executor/executor_linux.go | 1 + drivers/shared/executor/executor_unix.go | 1 + drivers/shared/executor/pty_unix.go | 1 + drivers/shared/executor/pty_windows.go | 1 + .../executor/resource_container_default.go | 1 + drivers/shared/executor/utils_unix.go | 1 + drivers/shared/hostnames/mount_unix_test.go | 1 + drivers/shared/resolvconf/mount_unix_test.go | 1 + e2e/consul/namespaces_oss.go | 1 + e2e/nomad09upgrade/upgrade.go | 3 ++- e2e/nomad09upgrade/upgrade_basic.go | 3 ++- e2e/quotas/quotas_oss.go | 1 + e2e/vaultcompat/vault_test.go | 2 +- helper/freeport/ephemeral_darwin.go | 3 ++- helper/freeport/ephemeral_darwin_test.go | 3 ++- helper/freeport/ephemeral_freebsd.go | 3 ++- helper/freeport/ephemeral_linux.go | 3 ++- helper/freeport/ephemeral_linux_test.go | 3 ++- helper/freeport/ephemeral_windows.go | 3 ++- helper/mount/mount_linux.go | 1 + helper/mount/mount_unsupported.go | 1 + helper/pluginutils/catalog/register_testing.go | 1 + helper/pluginutils/loader/filter_unix.go | 1 + helper/pluginutils/loader/filter_windows.go | 1 + helper/raftutil/fsm_oss.go | 1 + helper/snapshot/archive_test.go | 2 +- helper/testtask/testtask_unix.go | 1 + helper/testtask/testtask_windows.go | 1 + helper/winsvc/service_windows.go | 3 ++- nomad/consul_oss_test.go | 3 ++- nomad/consul_policy_oss_test.go | 3 ++- nomad/consul_policy_test.go | 16 ++++++++-------- nomad/deploymentwatcher/multiregion_oss.go | 1 + nomad/endpoints_oss.go | 1 + nomad/fsm_not_ent.go | 1 + nomad/fsm_registry_oss.go | 1 + nomad/job_endpoint_oss.go | 1 + nomad/job_endpoint_oss_test.go | 1 + nomad/leader_oss.go | 1 + nomad/plan_apply_not_ent.go | 1 + nomad/search_endpoint_oss.go | 1 + nomad/server_setup_oss.go | 1 + nomad/state/state_store_oss.go | 1 + nomad/structs/consul_oss.go | 1 + nomad/structs/consul_oss_test.go | 3 ++- nomad/structs/structs_oss.go | 1 + nomad/structs/structs_test.go | 4 ++-- nomad/testing_oss.go | 1 + plugins/drivers/utils/utils_unix.go | 1 + scheduler/generic_sched_test.go | 12 ++++++------ scheduler/reconcile_test.go | 2 +- scheduler/scheduler_oss.go | 1 + scheduler/stack_not_ent.go | 1 + scheduler/util_test.go | 4 ++-- 119 files changed, 162 insertions(+), 54 deletions(-) diff --git a/api/namespace_test.go b/api/namespace_test.go index a5fac0310f0..811fa0a74f6 100644 --- a/api/namespace_test.go +++ b/api/namespace_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package api diff --git a/api/quota_test.go b/api/quota_test.go index ebe2872a938..88cb1226072 100644 --- a/api/quota_test.go +++ b/api/quota_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package api diff --git a/api/sentinel_test.go b/api/sentinel_test.go index 0eebd62f92d..79a7c2da87e 100644 --- a/api/sentinel_test.go +++ b/api/sentinel_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package api diff --git a/build_linux_arm.go b/build_linux_arm.go index db4f8ebf2b1..f774e9b2f82 100644 --- a/build_linux_arm.go +++ b/build_linux_arm.go @@ -1,3 +1,4 @@ +//go:build linux && cgo // +build linux,cgo // #cgo LDFLAGS: -mfloat-abi=hard diff --git a/client/allocdir/fs_unix.go b/client/allocdir/fs_unix.go index 77447a32f7f..9f832693870 100644 --- a/client/allocdir/fs_unix.go +++ b/client/allocdir/fs_unix.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package allocdir diff --git a/client/allocdir/task_dir_nonlinux.go b/client/allocdir/task_dir_nonlinux.go index 08e7ba6eb7e..87f813f7feb 100644 --- a/client/allocdir/task_dir_nonlinux.go +++ b/client/allocdir/task_dir_nonlinux.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package allocdir diff --git a/client/allocrunner/alloc_runner_unix_test.go b/client/allocrunner/alloc_runner_unix_test.go index 2130162542c..b21d3fecba6 100644 --- a/client/allocrunner/alloc_runner_unix_test.go +++ b/client/allocrunner/alloc_runner_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package allocrunner diff --git a/client/allocrunner/network_manager_nonlinux.go b/client/allocrunner/network_manager_nonlinux.go index 49f161fcbaa..e8a2d4ea54c 100644 --- a/client/allocrunner/network_manager_nonlinux.go +++ b/client/allocrunner/network_manager_nonlinux.go @@ -1,4 +1,5 @@ -//+build !linux +//go:build !linux +// +build !linux package allocrunner diff --git a/client/allocrunner/networking_cni.go b/client/allocrunner/networking_cni.go index ce3a994d54e..0ca806fb8f3 100644 --- a/client/allocrunner/networking_cni.go +++ b/client/allocrunner/networking_cni.go @@ -1,6 +1,7 @@ // For now CNI is supported only on Linux. // -//+build linux +//go:build linux +// +build linux package allocrunner diff --git a/client/allocrunner/networking_cni_test.go b/client/allocrunner/networking_cni_test.go index 832ca32cea2..c4d761d4d06 100644 --- a/client/allocrunner/networking_cni_test.go +++ b/client/allocrunner/networking_cni_test.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package allocrunner @@ -19,10 +20,10 @@ func TestCNI_cniToAllocNet_Fallback(t *testing.T) { // following: cniResult := &cni.CNIResult{ Interfaces: map[string]*cni.Config{ - "cali39179aa3-74": &cni.Config{}, - "eth0": &cni.Config{ + "cali39179aa3-74": {}, + "eth0": { IPConfigs: []*cni.IPConfig{ - &cni.IPConfig{ + { IP: net.IPv4(192, 168, 135, 232), }, }, @@ -48,8 +49,8 @@ func TestCNI_cniToAllocNet_Fallback(t *testing.T) { func TestCNI_cniToAllocNet_Invalid(t *testing.T) { cniResult := &cni.CNIResult{ Interfaces: map[string]*cni.Config{ - "eth0": &cni.Config{}, - "veth1": &cni.Config{ + "eth0": {}, + "veth1": { IPConfigs: []*cni.IPConfig{}, }, }, diff --git a/client/allocrunner/taskrunner/envoy_bootstrap_hook_test.go b/client/allocrunner/taskrunner/envoy_bootstrap_hook_test.go index ab46a0d193b..5d473613fb3 100644 --- a/client/allocrunner/taskrunner/envoy_bootstrap_hook_test.go +++ b/client/allocrunner/taskrunner/envoy_bootstrap_hook_test.go @@ -1,4 +1,6 @@ +//go:build !windows // +build !windows + // todo(shoenig): Once Connect is supported on Windows, we'll need to make this // set of tests work there too. diff --git a/client/allocrunner/taskrunner/logmon_hook_unix_test.go b/client/allocrunner/taskrunner/logmon_hook_unix_test.go index cf64766bc05..df85c054e77 100644 --- a/client/allocrunner/taskrunner/logmon_hook_unix_test.go +++ b/client/allocrunner/taskrunner/logmon_hook_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package taskrunner diff --git a/client/allocrunner/taskrunner/sids_hook_test.go b/client/allocrunner/taskrunner/sids_hook_test.go index 2f2dcc6fc63..c0adcb0e9c9 100644 --- a/client/allocrunner/taskrunner/sids_hook_test.go +++ b/client/allocrunner/taskrunner/sids_hook_test.go @@ -1,4 +1,6 @@ +//go:build !windows // +build !windows + // todo(shoenig): Once Connect is supported on Windows, we'll need to make this // set of tests work there too. diff --git a/client/allocrunner/testing.go b/client/allocrunner/testing.go index 76bc5c519b0..da850719ef4 100644 --- a/client/allocrunner/testing.go +++ b/client/allocrunner/testing.go @@ -1,3 +1,4 @@ +//go:build !release // +build !release package allocrunner diff --git a/client/allocwatcher/alloc_watcher_unix_test.go b/client/allocwatcher/alloc_watcher_unix_test.go index aa75ab8eaf0..7967a69f01e 100644 --- a/client/allocwatcher/alloc_watcher_unix_test.go +++ b/client/allocwatcher/alloc_watcher_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package allocwatcher diff --git a/client/enterprise_client_oss.go b/client/enterprise_client_oss.go index 923fef86d44..0d68f7e8372 100644 --- a/client/enterprise_client_oss.go +++ b/client/enterprise_client_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package client diff --git a/client/fingerprint/bridge_default.go b/client/fingerprint/bridge_default.go index bf544522730..506253f134e 100644 --- a/client/fingerprint/bridge_default.go +++ b/client/fingerprint/bridge_default.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package fingerprint diff --git a/client/fingerprint/cgroup_default.go b/client/fingerprint/cgroup_default.go index 70d68cf3ca3..272540834ea 100644 --- a/client/fingerprint/cgroup_default.go +++ b/client/fingerprint/cgroup_default.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package fingerprint diff --git a/client/fingerprint/cgroup_linux.go b/client/fingerprint/cgroup_linux.go index 2bf58faac35..36cefdf0f31 100644 --- a/client/fingerprint/cgroup_linux.go +++ b/client/fingerprint/cgroup_linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package fingerprint diff --git a/client/fingerprint/cgroup_test.go b/client/fingerprint/cgroup_test.go index 8aa5b7455ee..d357c1e17e6 100644 --- a/client/fingerprint/cgroup_test.go +++ b/client/fingerprint/cgroup_test.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package fingerprint diff --git a/client/fingerprint/cpu_default.go b/client/fingerprint/cpu_default.go index 79676ad7944..1b266c3c671 100644 --- a/client/fingerprint/cpu_default.go +++ b/client/fingerprint/cpu_default.go @@ -1,4 +1,5 @@ -//+build !linux +//go:build !linux +// +build !linux package fingerprint diff --git a/client/fingerprint/fingerprint_default.go b/client/fingerprint/fingerprint_default.go index e2ae1ec6f3c..d558d62f62f 100644 --- a/client/fingerprint/fingerprint_default.go +++ b/client/fingerprint/fingerprint_default.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || netbsd || openbsd || solaris || windows // +build darwin dragonfly freebsd netbsd openbsd solaris windows package fingerprint diff --git a/client/fingerprint/network_default.go b/client/fingerprint/network_default.go index 3faa9388145..7cf92403129 100644 --- a/client/fingerprint/network_default.go +++ b/client/fingerprint/network_default.go @@ -1,3 +1,4 @@ +//go:build !linux && !windows // +build !linux,!windows package fingerprint diff --git a/client/fingerprint/network_test.go b/client/fingerprint/network_test.go index 4b0fce93dcc..892398d559d 100644 --- a/client/fingerprint/network_test.go +++ b/client/fingerprint/network_test.go @@ -479,7 +479,7 @@ func TestNetworkFingerPrint_MultipleAliases(t *testing.T) { } } expected := []string{} - for alias, _ := range cfg.HostNetworks { + for alias := range cfg.HostNetworks { expected = append(expected, alias) } sort.Strings(expected) diff --git a/client/fingerprint/storage_unix.go b/client/fingerprint/storage_unix.go index ada8f4beab3..3ac5a6caed8 100644 --- a/client/fingerprint/storage_unix.go +++ b/client/fingerprint/storage_unix.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package fingerprint diff --git a/client/lib/cgutil/cgutil_default.go b/client/lib/cgutil/cgutil_default.go index e9bc0f35146..c2fc74e0da2 100644 --- a/client/lib/cgutil/cgutil_default.go +++ b/client/lib/cgutil/cgutil_default.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package cgutil diff --git a/client/lib/cgutil/cpuset_manager_default.go b/client/lib/cgutil/cpuset_manager_default.go index 29c970d7f2b..1f8c077baa6 100644 --- a/client/lib/cgutil/cpuset_manager_default.go +++ b/client/lib/cgutil/cpuset_manager_default.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package cgutil diff --git a/client/lib/fifo/fifo_unix.go b/client/lib/fifo/fifo_unix.go index c1d90a3adb3..28f51e92916 100644 --- a/client/lib/fifo/fifo_unix.go +++ b/client/lib/fifo/fifo_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package fifo diff --git a/client/pluginmanager/drivermanager/testing.go b/client/pluginmanager/drivermanager/testing.go index 080bf1c2d3a..b442db3aa32 100644 --- a/client/pluginmanager/drivermanager/testing.go +++ b/client/pluginmanager/drivermanager/testing.go @@ -1,3 +1,4 @@ +//go:build !release // +build !release package drivermanager diff --git a/client/state/db_test.go b/client/state/db_test.go index 06b78cb8719..c4f92ce754f 100644 --- a/client/state/db_test.go +++ b/client/state/db_test.go @@ -196,7 +196,7 @@ func TestStateDB_Batch(t *testing.T) { if getTxID != nil { numTransactions := getTxID() - prevTxID writeTime := time.Now().Sub(startTime) - expectedNumTransactions := ceilDiv(2 * numAllocs, batchSize) + ceilDiv(int(writeTime), int(batchDelay)) + expectedNumTransactions := ceilDiv(2*numAllocs, batchSize) + ceilDiv(int(writeTime), int(batchDelay)) require.LessOrEqual(numTransactions, expectedNumTransactions) prevTxID = getTxID() } diff --git a/command/agent/agent_oss.go b/command/agent/agent_oss.go index 3b873360338..4594204e59f 100644 --- a/command/agent/agent_oss.go +++ b/command/agent/agent_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package agent diff --git a/command/agent/config_oss.go b/command/agent/config_oss.go index c9154427605..9ae283f6f12 100644 --- a/command/agent/config_oss.go +++ b/command/agent/config_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package agent diff --git a/command/agent/consul/connect_proxies_test.go b/command/agent/consul/connect_proxies_test.go index 235b319c115..8ebcee193cb 100644 --- a/command/agent/consul/connect_proxies_test.go +++ b/command/agent/consul/connect_proxies_test.go @@ -12,6 +12,6 @@ func TestConnectProxies_Proxies(t *testing.T) { proxies, err := pc.Proxies() require.NoError(t, err) require.Equal(t, map[string][]string{ - "envoy": []string{"1.14.2", "1.13.2", "1.12.4", "1.11.2"}, + "envoy": {"1.14.2", "1.13.2", "1.12.4", "1.11.2"}, }, proxies) } diff --git a/command/agent/host/darwin.go b/command/agent/host/darwin.go index 856ac91637a..7a78070541a 100644 --- a/command/agent/host/darwin.go +++ b/command/agent/host/darwin.go @@ -1,3 +1,4 @@ +//go:build darwin // +build darwin package host diff --git a/command/agent/host/linux.go b/command/agent/host/linux.go index f886282ce28..f9776988b7a 100644 --- a/command/agent/host/linux.go +++ b/command/agent/host/linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package host diff --git a/command/agent/host/unix.go b/command/agent/host/unix.go index a5fae0a5891..30417004578 100644 --- a/command/agent/host/unix.go +++ b/command/agent/host/unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package host diff --git a/command/agent/host/windows.go b/command/agent/host/windows.go index 2b15988b9a5..11aa237f735 100644 --- a/command/agent/host/windows.go +++ b/command/agent/host/windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package host diff --git a/command/agent/http_oss.go b/command/agent/http_oss.go index 863ab4bc27c..7f54194c935 100644 --- a/command/agent/http_oss.go +++ b/command/agent/http_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package agent diff --git a/command/agent/namespace_endpoint_test.go b/command/agent/namespace_endpoint_test.go index 9e9a0fd0132..7cbf2301b37 100644 --- a/command/agent/namespace_endpoint_test.go +++ b/command/agent/namespace_endpoint_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package agent diff --git a/command/agent/operator_endpoint_oss.go b/command/agent/operator_endpoint_oss.go index d589afebebc..8467c907bea 100644 --- a/command/agent/operator_endpoint_oss.go +++ b/command/agent/operator_endpoint_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package agent diff --git a/command/agent/stub_asset.go b/command/agent/stub_asset.go index 00ef7222d85..17fbd2592c6 100644 --- a/command/agent/stub_asset.go +++ b/command/agent/stub_asset.go @@ -1,3 +1,4 @@ +//go:build !ui // +build !ui package agent diff --git a/command/agent/testagent_oss.go b/command/agent/testagent_oss.go index eae187a51ea..4f93ace4ae3 100644 --- a/command/agent/testagent_oss.go +++ b/command/agent/testagent_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package agent diff --git a/command/alloc_exec_unix.go b/command/alloc_exec_unix.go index 36c3901df25..a03caaed13d 100644 --- a/command/alloc_exec_unix.go +++ b/command/alloc_exec_unix.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package command diff --git a/command/alloc_status_test.go b/command/alloc_status_test.go index c875a5bc0ab..69626b50e3c 100644 --- a/command/alloc_status_test.go +++ b/command/alloc_status_test.go @@ -133,9 +133,9 @@ func TestAllocStatusCommand_LifecycleInfo(t *testing.T) { a.TaskResources["init_task"] = a.TaskResources["web"] a.TaskResources["prestart_sidecar"] = a.TaskResources["web"] a.TaskStates = map[string]*structs.TaskState{ - "web": &structs.TaskState{State: "pending"}, - "init_task": &structs.TaskState{State: "running"}, - "prestart_sidecar": &structs.TaskState{State: "running"}, + "web": {State: "pending"}, + "init_task": {State: "running"}, + "prestart_sidecar": {State: "running"}, } require.Nil(t, state.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{a})) @@ -429,7 +429,7 @@ func TestAllocStatusCommand_HostVolumes(t *testing.T) { // fakes the placement enough so that we have something to iterate // on in 'nomad alloc status' alloc.TaskStates = map[string]*structs.TaskState{ - "web": &structs.TaskState{ + "web": { Events: []*structs.TaskEvent{ structs.NewTaskEvent("test event").SetMessage("test msg"), }, @@ -504,7 +504,7 @@ func TestAllocStatusCommand_CSIVolumes(t *testing.T) { } // if we don't set a task state, there's nothing to iterate on alloc status alloc.TaskStates = map[string]*structs.TaskState{ - "web": &structs.TaskState{ + "web": { Events: []*structs.TaskEvent{ structs.NewTaskEvent("test event").SetMessage("test msg"), }, diff --git a/command/commands_oss.go b/command/commands_oss.go index 83dae1bd236..2b283681ff6 100644 --- a/command/commands_oss.go +++ b/command/commands_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package command diff --git a/command/namespace_apply_test.go b/command/namespace_apply_test.go index d4d7bd09e04..a5611e2addf 100644 --- a/command/namespace_apply_test.go +++ b/command/namespace_apply_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package command diff --git a/command/namespace_delete_test.go b/command/namespace_delete_test.go index 8c187e232eb..155f2cff719 100644 --- a/command/namespace_delete_test.go +++ b/command/namespace_delete_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package command diff --git a/command/namespace_inspect_test.go b/command/namespace_inspect_test.go index 7f4862a63e7..296b0fa5d74 100644 --- a/command/namespace_inspect_test.go +++ b/command/namespace_inspect_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package command diff --git a/command/namespace_list_test.go b/command/namespace_list_test.go index 95b01833316..822199c623c 100644 --- a/command/namespace_list_test.go +++ b/command/namespace_list_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package command diff --git a/command/namespace_status_test.go b/command/namespace_status_test.go index fa4a387dddc..74073b8f271 100644 --- a/command/namespace_status_test.go +++ b/command/namespace_status_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package command diff --git a/command/quota_delete_test.go b/command/quota_delete_test.go index 91b0d042a85..351332c62be 100644 --- a/command/quota_delete_test.go +++ b/command/quota_delete_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package command diff --git a/command/quota_inspect_test.go b/command/quota_inspect_test.go index 3c7f7dde884..6fee89c6054 100644 --- a/command/quota_inspect_test.go +++ b/command/quota_inspect_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package command diff --git a/command/quota_list_test.go b/command/quota_list_test.go index b1f21e8c271..d50935e7c60 100644 --- a/command/quota_list_test.go +++ b/command/quota_list_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package command diff --git a/command/quota_status_test.go b/command/quota_status_test.go index 954d4cf7024..53689320f62 100644 --- a/command/quota_status_test.go +++ b/command/quota_status_test.go @@ -1,3 +1,4 @@ +//go:build ent // +build ent package command diff --git a/drivers/docker/config_test.go b/drivers/docker/config_test.go index 53485dbb955..b9deb9213e7 100644 --- a/drivers/docker/config_test.go +++ b/drivers/docker/config_test.go @@ -694,12 +694,12 @@ func TestConfig_DriverConfig_AllowRuntimes(t *testing.T) { { name: "pure default", config: `{}`, - expected: map[string]struct{}{"runc": struct{}{}, "nvidia": struct{}{}}, + expected: map[string]struct{}{"runc": {}, "nvidia": {}}, }, { name: "custom", config: `{ allow_runtimes = ["runc", "firecracker"]}`, - expected: map[string]struct{}{"runc": struct{}{}, "firecracker": struct{}{}}, + expected: map[string]struct{}{"runc": {}, "firecracker": {}}, }, } diff --git a/drivers/docker/driver_default.go b/drivers/docker/driver_default.go index b180ae8f92b..8607b899b19 100644 --- a/drivers/docker/driver_default.go +++ b/drivers/docker/driver_default.go @@ -1,4 +1,5 @@ -//+build !windows +//go:build !windows +// +build !windows package docker diff --git a/drivers/docker/driver_test.go b/drivers/docker/driver_test.go index f51b8b3f07a..aa542a58b1e 100644 --- a/drivers/docker/driver_test.go +++ b/drivers/docker/driver_test.go @@ -1224,12 +1224,12 @@ func TestDockerDriver_CreateContainerConfig_Mounts(t *testing.T) { defer freeport.Return(ports) cfg.Mounts = []DockerMount{ - DockerMount{ + { Type: "bind", Target: "/map-bind-target", Source: "/map-source", }, - DockerMount{ + { Type: "tmpfs", Target: "/map-tmpfs-target", }, diff --git a/drivers/docker/driver_unix_test.go b/drivers/docker/driver_unix_test.go index d3658ea351c..019b42764b1 100644 --- a/drivers/docker/driver_unix_test.go +++ b/drivers/docker/driver_unix_test.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package docker diff --git a/drivers/docker/driver_windows_test.go b/drivers/docker/driver_windows_test.go index 05306d83fe5..f54b83f2095 100644 --- a/drivers/docker/driver_windows_test.go +++ b/drivers/docker/driver_windows_test.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package docker diff --git a/drivers/docker/util/stats_posix.go b/drivers/docker/util/stats_posix.go index 35609639576..ae755c43003 100644 --- a/drivers/docker/util/stats_posix.go +++ b/drivers/docker/util/stats_posix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package util diff --git a/drivers/docker/utils_unix_test.go b/drivers/docker/utils_unix_test.go index 2260ef89ef1..29f52696451 100644 --- a/drivers/docker/utils_unix_test.go +++ b/drivers/docker/utils_unix_test.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package docker diff --git a/drivers/docker/utils_windows_test.go b/drivers/docker/utils_windows_test.go index 2891fe8d313..d433055e961 100644 --- a/drivers/docker/utils_windows_test.go +++ b/drivers/docker/utils_windows_test.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package docker diff --git a/drivers/exec/driver_unix_test.go b/drivers/exec/driver_unix_test.go index 3b2e60374aa..a9da57c02d5 100644 --- a/drivers/exec/driver_unix_test.go +++ b/drivers/exec/driver_unix_test.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package exec diff --git a/drivers/rawexec/driver_unix_test.go b/drivers/rawexec/driver_unix_test.go index b35902297fa..9d6d6d70a53 100644 --- a/drivers/rawexec/driver_unix_test.go +++ b/drivers/rawexec/driver_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package rawexec diff --git a/drivers/shared/executor/executor_basic.go b/drivers/shared/executor/executor_basic.go index 7326ad172d3..083166bd37c 100644 --- a/drivers/shared/executor/executor_basic.go +++ b/drivers/shared/executor/executor_basic.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package executor diff --git a/drivers/shared/executor/executor_linux.go b/drivers/shared/executor/executor_linux.go index 54be7ed79f7..1956125c31f 100644 --- a/drivers/shared/executor/executor_linux.go +++ b/drivers/shared/executor/executor_linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package executor diff --git a/drivers/shared/executor/executor_unix.go b/drivers/shared/executor/executor_unix.go index 6f90b7ade4f..da2d9ddcb75 100644 --- a/drivers/shared/executor/executor_unix.go +++ b/drivers/shared/executor/executor_unix.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package executor diff --git a/drivers/shared/executor/pty_unix.go b/drivers/shared/executor/pty_unix.go index 964c09fbda3..d940d9e0423 100644 --- a/drivers/shared/executor/pty_unix.go +++ b/drivers/shared/executor/pty_unix.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package executor diff --git a/drivers/shared/executor/pty_windows.go b/drivers/shared/executor/pty_windows.go index 12411a5a5d4..f9c4cf35e8b 100644 --- a/drivers/shared/executor/pty_windows.go +++ b/drivers/shared/executor/pty_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package executor diff --git a/drivers/shared/executor/resource_container_default.go b/drivers/shared/executor/resource_container_default.go index 7bd02dbb69d..ff4c8f9e808 100644 --- a/drivers/shared/executor/resource_container_default.go +++ b/drivers/shared/executor/resource_container_default.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || netbsd || openbsd || solaris || windows // +build darwin dragonfly freebsd netbsd openbsd solaris windows package executor diff --git a/drivers/shared/executor/utils_unix.go b/drivers/shared/executor/utils_unix.go index ce1a39f8667..6f45ccf4341 100644 --- a/drivers/shared/executor/utils_unix.go +++ b/drivers/shared/executor/utils_unix.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package executor diff --git a/drivers/shared/hostnames/mount_unix_test.go b/drivers/shared/hostnames/mount_unix_test.go index e7273b1d803..97ee369b9bc 100644 --- a/drivers/shared/hostnames/mount_unix_test.go +++ b/drivers/shared/hostnames/mount_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package hostnames diff --git a/drivers/shared/resolvconf/mount_unix_test.go b/drivers/shared/resolvconf/mount_unix_test.go index 271eb6c0274..8469f0a30d4 100644 --- a/drivers/shared/resolvconf/mount_unix_test.go +++ b/drivers/shared/resolvconf/mount_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package resolvconf diff --git a/e2e/consul/namespaces_oss.go b/e2e/consul/namespaces_oss.go index 249fd6f53fc..ce41810aef0 100644 --- a/e2e/consul/namespaces_oss.go +++ b/e2e/consul/namespaces_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent // Nomad OSS ignores Consul Namespace configuration in jobs, these e2e tests diff --git a/e2e/nomad09upgrade/upgrade.go b/e2e/nomad09upgrade/upgrade.go index bf0ed6eacfd..88f2fc88d4a 100644 --- a/e2e/nomad09upgrade/upgrade.go +++ b/e2e/nomad09upgrade/upgrade.go @@ -1,4 +1,5 @@ -//+build linux +//go:build linux +// +build linux package nomad09upgrade diff --git a/e2e/nomad09upgrade/upgrade_basic.go b/e2e/nomad09upgrade/upgrade_basic.go index 948fa109c92..e77783e58b7 100644 --- a/e2e/nomad09upgrade/upgrade_basic.go +++ b/e2e/nomad09upgrade/upgrade_basic.go @@ -1,3 +1,4 @@ -//+build !linux +//go:build !linux +// +build !linux package nomad09upgrade diff --git a/e2e/quotas/quotas_oss.go b/e2e/quotas/quotas_oss.go index a7a586aa842..44a0f3a4bae 100644 --- a/e2e/quotas/quotas_oss.go +++ b/e2e/quotas/quotas_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package quotas diff --git a/e2e/vaultcompat/vault_test.go b/e2e/vaultcompat/vault_test.go index 3c166ae0c56..27446ebbd7b 100644 --- a/e2e/vaultcompat/vault_test.go +++ b/e2e/vaultcompat/vault_test.go @@ -70,7 +70,7 @@ func syncVault(t *testing.T) ([]*version.Version, map[string]string) { } binaries := make(map[string]string, len(versions)) - for ver, _ := range versions { + for ver := range versions { binaries[ver] = filepath.Join(binDir, ver) } return sorted, binaries diff --git a/helper/freeport/ephemeral_darwin.go b/helper/freeport/ephemeral_darwin.go index 897f8fbf6ec..48277420e1d 100644 --- a/helper/freeport/ephemeral_darwin.go +++ b/helper/freeport/ephemeral_darwin.go @@ -1,4 +1,5 @@ -//+build darwin +//go:build darwin +// +build darwin package freeport diff --git a/helper/freeport/ephemeral_darwin_test.go b/helper/freeport/ephemeral_darwin_test.go index e602f474ad7..10d0b9bba9f 100644 --- a/helper/freeport/ephemeral_darwin_test.go +++ b/helper/freeport/ephemeral_darwin_test.go @@ -1,4 +1,5 @@ -//+build darwin +//go:build darwin +// +build darwin package freeport diff --git a/helper/freeport/ephemeral_freebsd.go b/helper/freeport/ephemeral_freebsd.go index 3c335c88bb2..64b420eb46c 100644 --- a/helper/freeport/ephemeral_freebsd.go +++ b/helper/freeport/ephemeral_freebsd.go @@ -1,4 +1,5 @@ -//+build freebsd +//go:build freebsd +// +build freebsd package freeport diff --git a/helper/freeport/ephemeral_linux.go b/helper/freeport/ephemeral_linux.go index 342b4a0c639..4e6de69ed9a 100644 --- a/helper/freeport/ephemeral_linux.go +++ b/helper/freeport/ephemeral_linux.go @@ -1,4 +1,5 @@ -//+build linux +//go:build linux +// +build linux package freeport diff --git a/helper/freeport/ephemeral_linux_test.go b/helper/freeport/ephemeral_linux_test.go index 2d9385df4bf..cd4e9db3428 100644 --- a/helper/freeport/ephemeral_linux_test.go +++ b/helper/freeport/ephemeral_linux_test.go @@ -1,4 +1,5 @@ -//+build linux +//go:build linux +// +build linux package freeport diff --git a/helper/freeport/ephemeral_windows.go b/helper/freeport/ephemeral_windows.go index 9401c107fe4..c4cd40df7f8 100644 --- a/helper/freeport/ephemeral_windows.go +++ b/helper/freeport/ephemeral_windows.go @@ -1,4 +1,5 @@ -//+build windows +//go:build windows +// +build windows package freeport diff --git a/helper/mount/mount_linux.go b/helper/mount/mount_linux.go index 4e4f2ab69d2..0bca7bf958b 100644 --- a/helper/mount/mount_linux.go +++ b/helper/mount/mount_linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package mount diff --git a/helper/mount/mount_unsupported.go b/helper/mount/mount_unsupported.go index 8605aded4b4..5522faea29d 100644 --- a/helper/mount/mount_unsupported.go +++ b/helper/mount/mount_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package mount diff --git a/helper/pluginutils/catalog/register_testing.go b/helper/pluginutils/catalog/register_testing.go index d3d58c925ee..f1e0914ba8c 100644 --- a/helper/pluginutils/catalog/register_testing.go +++ b/helper/pluginutils/catalog/register_testing.go @@ -1,3 +1,4 @@ +//go:build !release // +build !release package catalog diff --git a/helper/pluginutils/loader/filter_unix.go b/helper/pluginutils/loader/filter_unix.go index fefea7cb250..5ef82140488 100644 --- a/helper/pluginutils/loader/filter_unix.go +++ b/helper/pluginutils/loader/filter_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package loader diff --git a/helper/pluginutils/loader/filter_windows.go b/helper/pluginutils/loader/filter_windows.go index 7e8c4bb7c1e..021e1cc2448 100644 --- a/helper/pluginutils/loader/filter_windows.go +++ b/helper/pluginutils/loader/filter_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package loader diff --git a/helper/raftutil/fsm_oss.go b/helper/raftutil/fsm_oss.go index c9e725b12a2..0ac4e7cde76 100644 --- a/helper/raftutil/fsm_oss.go +++ b/helper/raftutil/fsm_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package raftutil diff --git a/helper/snapshot/archive_test.go b/helper/snapshot/archive_test.go index 8a12f59ce0a..1ac93507dfc 100644 --- a/helper/snapshot/archive_test.go +++ b/helper/snapshot/archive_test.go @@ -21,7 +21,7 @@ func TestArchive(t *testing.T) { Term: 2011, Configuration: raft.Configuration{ Servers: []raft.Server{ - raft.Server{ + { Suffrage: raft.Voter, ID: raft.ServerID("hello"), Address: raft.ServerAddress("127.0.0.1:8300"), diff --git a/helper/testtask/testtask_unix.go b/helper/testtask/testtask_unix.go index c3d3ceb682e..cac2fb0d405 100644 --- a/helper/testtask/testtask_unix.go +++ b/helper/testtask/testtask_unix.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package testtask diff --git a/helper/testtask/testtask_windows.go b/helper/testtask/testtask_windows.go index a532b418ece..28273038971 100644 --- a/helper/testtask/testtask_windows.go +++ b/helper/testtask/testtask_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package testtask diff --git a/helper/winsvc/service_windows.go b/helper/winsvc/service_windows.go index eeecf1b82da..84c043d1531 100644 --- a/helper/winsvc/service_windows.go +++ b/helper/winsvc/service_windows.go @@ -1,4 +1,5 @@ -//+build windows +//go:build windows +// +build windows package winsvc diff --git a/nomad/consul_oss_test.go b/nomad/consul_oss_test.go index 6fbd6e36909..520467d71ce 100644 --- a/nomad/consul_oss_test.go +++ b/nomad/consul_oss_test.go @@ -1,4 +1,5 @@ -//+build !ent +//go:build !ent +// +build !ent package nomad diff --git a/nomad/consul_policy_oss_test.go b/nomad/consul_policy_oss_test.go index 79993291db8..464bfcf09a0 100644 --- a/nomad/consul_policy_oss_test.go +++ b/nomad/consul_policy_oss_test.go @@ -1,4 +1,5 @@ -//+build !ent +//go:build !ent +// +build !ent package nomad diff --git a/nomad/consul_policy_test.go b/nomad/consul_policy_test.go index 4e5f9cea065..150780d156e 100644 --- a/nomad/consul_policy_test.go +++ b/nomad/consul_policy_test.go @@ -521,7 +521,7 @@ func TestConsulPolicy_allowKeystoreRead(t *testing.T) { t.Run("kv wild namespace prefix any read", func(t *testing.T) { policy := &ConsulPolicy{ NamespacePrefixes: map[string]*ConsulPolicy{ - "": &ConsulPolicy{ + "": { KeyPrefixes: []*ConsulKeyRule{{ Name: "", Policy: "read", @@ -536,7 +536,7 @@ func TestConsulPolicy_allowKeystoreRead(t *testing.T) { t.Run("kv apple namespace prefix any read", func(t *testing.T) { policy := &ConsulPolicy{ NamespacePrefixes: map[string]*ConsulPolicy{ - "apple": &ConsulPolicy{ + "apple": { KeyPrefixes: []*ConsulKeyRule{{ Name: "", Policy: "read", @@ -551,7 +551,7 @@ func TestConsulPolicy_allowKeystoreRead(t *testing.T) { t.Run("kv matching namespace prefix any read", func(t *testing.T) { policy := &ConsulPolicy{ NamespacePrefixes: map[string]*ConsulPolicy{ - "app": &ConsulPolicy{ + "app": { KeyPrefixes: []*ConsulKeyRule{{ Name: "", Policy: "read", @@ -566,7 +566,7 @@ func TestConsulPolicy_allowKeystoreRead(t *testing.T) { t.Run("kv other namespace prefix any read", func(t *testing.T) { policy := &ConsulPolicy{ NamespacePrefixes: map[string]*ConsulPolicy{ - "other": &ConsulPolicy{ + "other": { KeyPrefixes: []*ConsulKeyRule{{ Name: "", Policy: "read", @@ -583,7 +583,7 @@ func TestConsulPolicy_allowKeystoreRead(t *testing.T) { t.Run("kv match namespace any read", func(t *testing.T) { policy := &ConsulPolicy{ Namespaces: map[string]*ConsulPolicy{ - "apple": &ConsulPolicy{ + "apple": { KeyPrefixes: []*ConsulKeyRule{{ Name: "", Policy: "read", @@ -598,7 +598,7 @@ func TestConsulPolicy_allowKeystoreRead(t *testing.T) { t.Run("kv mismatch namespace any read", func(t *testing.T) { policy := &ConsulPolicy{ Namespaces: map[string]*ConsulPolicy{ - "other": &ConsulPolicy{ + "other": { KeyPrefixes: []*ConsulKeyRule{{ Name: "", Policy: "read", @@ -613,7 +613,7 @@ func TestConsulPolicy_allowKeystoreRead(t *testing.T) { t.Run("kv matching namespace prefix any read", func(t *testing.T) { policy := &ConsulPolicy{ Namespaces: map[string]*ConsulPolicy{ - "apple": &ConsulPolicy{ + "apple": { KeyPrefixes: []*ConsulKeyRule{{ Name: "", Policy: "read", @@ -628,7 +628,7 @@ func TestConsulPolicy_allowKeystoreRead(t *testing.T) { t.Run("kv mismatch namespace prefix any read", func(t *testing.T) { policy := &ConsulPolicy{ Namespaces: map[string]*ConsulPolicy{ - "other": &ConsulPolicy{ + "other": { KeyPrefixes: []*ConsulKeyRule{{ Name: "", Policy: "read", diff --git a/nomad/deploymentwatcher/multiregion_oss.go b/nomad/deploymentwatcher/multiregion_oss.go index 427fa904f8c..98b363ad48b 100644 --- a/nomad/deploymentwatcher/multiregion_oss.go +++ b/nomad/deploymentwatcher/multiregion_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package deploymentwatcher diff --git a/nomad/endpoints_oss.go b/nomad/endpoints_oss.go index eb912f0a3d9..7c15a04baa8 100644 --- a/nomad/endpoints_oss.go +++ b/nomad/endpoints_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package nomad diff --git a/nomad/fsm_not_ent.go b/nomad/fsm_not_ent.go index aa7f4389a1e..b21ca608e64 100644 --- a/nomad/fsm_not_ent.go +++ b/nomad/fsm_not_ent.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package nomad diff --git a/nomad/fsm_registry_oss.go b/nomad/fsm_registry_oss.go index 3ac0351ae0f..c1a18750fdf 100644 --- a/nomad/fsm_registry_oss.go +++ b/nomad/fsm_registry_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package nomad diff --git a/nomad/job_endpoint_oss.go b/nomad/job_endpoint_oss.go index ac43893f4eb..d4485381842 100644 --- a/nomad/job_endpoint_oss.go +++ b/nomad/job_endpoint_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package nomad diff --git a/nomad/job_endpoint_oss_test.go b/nomad/job_endpoint_oss_test.go index 24ac312aaa1..e90e7cb8200 100644 --- a/nomad/job_endpoint_oss_test.go +++ b/nomad/job_endpoint_oss_test.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package nomad diff --git a/nomad/leader_oss.go b/nomad/leader_oss.go index 38ff1d4aacb..eb19d9107b9 100644 --- a/nomad/leader_oss.go +++ b/nomad/leader_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package nomad diff --git a/nomad/plan_apply_not_ent.go b/nomad/plan_apply_not_ent.go index 1b413a1e5b3..44534cab6ce 100644 --- a/nomad/plan_apply_not_ent.go +++ b/nomad/plan_apply_not_ent.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package nomad diff --git a/nomad/search_endpoint_oss.go b/nomad/search_endpoint_oss.go index a724518c296..4a8735b4e60 100644 --- a/nomad/search_endpoint_oss.go +++ b/nomad/search_endpoint_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package nomad diff --git a/nomad/server_setup_oss.go b/nomad/server_setup_oss.go index 6ada6a06e06..2e08a9ea508 100644 --- a/nomad/server_setup_oss.go +++ b/nomad/server_setup_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package nomad diff --git a/nomad/state/state_store_oss.go b/nomad/state/state_store_oss.go index e8f91195ecd..aaa57de0324 100644 --- a/nomad/state/state_store_oss.go +++ b/nomad/state/state_store_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package state diff --git a/nomad/structs/consul_oss.go b/nomad/structs/consul_oss.go index a2a2cc4e8e6..fa1c36c70f6 100644 --- a/nomad/structs/consul_oss.go +++ b/nomad/structs/consul_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package structs diff --git a/nomad/structs/consul_oss_test.go b/nomad/structs/consul_oss_test.go index 4479fa8388a..de3359c345a 100644 --- a/nomad/structs/consul_oss_test.go +++ b/nomad/structs/consul_oss_test.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package structs @@ -73,7 +74,7 @@ func TestJob_ConfigEntries(t *testing.T) { exp := map[string]*ConsulConfigEntries{ // in OSS, consul namespace is not supported - "": &ConsulConfigEntries{ + "": { Ingress: map[string]*ConsulIngressConfigEntry{ "group1-service1": new(ConsulIngressConfigEntry), "group2-service1": new(ConsulIngressConfigEntry), diff --git a/nomad/structs/structs_oss.go b/nomad/structs/structs_oss.go index ec540a82c23..2d0fcf37971 100644 --- a/nomad/structs/structs_oss.go +++ b/nomad/structs/structs_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package structs diff --git a/nomad/structs/structs_test.go b/nomad/structs/structs_test.go index ab14ba01a16..b595b419b0a 100644 --- a/nomad/structs/structs_test.go +++ b/nomad/structs/structs_test.go @@ -1390,7 +1390,7 @@ func TestTaskGroupNetwork_Validate(t *testing.T) { }, }, Tasks: []*Task{ - &Task{ + { Name: "task1", Resources: &Resources{ Networks: Networks{ @@ -1424,7 +1424,7 @@ func TestTaskGroupNetwork_Validate(t *testing.T) { }, }, Tasks: []*Task{ - &Task{ + { Name: "task1", Resources: &Resources{ Networks: Networks{ diff --git a/nomad/testing_oss.go b/nomad/testing_oss.go index 5f4d5e82cc2..2db273d7b2f 100644 --- a/nomad/testing_oss.go +++ b/nomad/testing_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package nomad diff --git a/plugins/drivers/utils/utils_unix.go b/plugins/drivers/utils/utils_unix.go index d7592be07aa..12e08cc9710 100644 --- a/plugins/drivers/utils/utils_unix.go +++ b/plugins/drivers/utils/utils_unix.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package utils diff --git a/scheduler/generic_sched_test.go b/scheduler/generic_sched_test.go index 2298250d802..1b38d9c0005 100644 --- a/scheduler/generic_sched_test.go +++ b/scheduler/generic_sched_test.go @@ -3452,7 +3452,7 @@ func TestServiceSched_NodeDrain_TaskHandle(t *testing.T) { alloc.Name = fmt.Sprintf("my-job.web[%d]", i) alloc.DesiredTransition.Migrate = helper.BoolToPtr(true) alloc.TaskStates = map[string]*structs.TaskState{ - "web": &structs.TaskState{ + "web": { TaskHandle: &structs.TaskHandle{ Version: 1, DriverState: []byte("test-driver-state"), @@ -6289,7 +6289,7 @@ func TestPropagateTaskState(t *testing.T) { ClientStatus: structs.AllocClientStatusRunning, DesiredTransition: structs.DesiredTransition{}, TaskStates: map[string]*structs.TaskState{ - taskName: &structs.TaskState{ + taskName: { TaskHandle: taskHandle, }, }, @@ -6305,7 +6305,7 @@ func TestPropagateTaskState(t *testing.T) { Migrate: helper.BoolToPtr(true), }, TaskStates: map[string]*structs.TaskState{ - taskName: &structs.TaskState{ + taskName: { TaskHandle: taskHandle, }, }, @@ -6319,7 +6319,7 @@ func TestPropagateTaskState(t *testing.T) { ClientStatus: structs.AllocClientStatusRunning, DesiredTransition: structs.DesiredTransition{}, TaskStates: map[string]*structs.TaskState{ - taskName: &structs.TaskState{}, + taskName: {}, }, }, prevLost: true, @@ -6333,7 +6333,7 @@ func TestPropagateTaskState(t *testing.T) { Migrate: helper.BoolToPtr(true), }, TaskStates: map[string]*structs.TaskState{ - taskName: &structs.TaskState{}, + taskName: {}, }, }, prevLost: false, @@ -6345,7 +6345,7 @@ func TestPropagateTaskState(t *testing.T) { ClientStatus: structs.AllocClientStatusComplete, DesiredTransition: structs.DesiredTransition{}, TaskStates: map[string]*structs.TaskState{ - taskName: &structs.TaskState{ + taskName: { TaskHandle: taskHandle, }, }, diff --git a/scheduler/reconcile_test.go b/scheduler/reconcile_test.go index 736b518d781..d698b2d8744 100644 --- a/scheduler/reconcile_test.go +++ b/scheduler/reconcile_test.go @@ -609,7 +609,7 @@ func TestReconciler_Inplace_Rollback(t *testing.T) { // different rescheduling states allocs[1].ClientStatus = structs.AllocClientStatusFailed allocs[1].TaskStates = map[string]*structs.TaskState{ - "web": &structs.TaskState{FinishedAt: time.Now().Add(-10 * time.Minute)}} + "web": {FinishedAt: time.Now().Add(-10 * time.Minute)}} allocs[2].ClientStatus = structs.AllocClientStatusFailed // job is rolled back, we expect allocs[0] to be updated in-place diff --git a/scheduler/scheduler_oss.go b/scheduler/scheduler_oss.go index 71cdff3ecff..a6062f2a1db 100644 --- a/scheduler/scheduler_oss.go +++ b/scheduler/scheduler_oss.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package scheduler diff --git a/scheduler/stack_not_ent.go b/scheduler/stack_not_ent.go index 2c1660ec291..7214c6be826 100644 --- a/scheduler/stack_not_ent.go +++ b/scheduler/stack_not_ent.go @@ -1,3 +1,4 @@ +//go:build !ent // +build !ent package scheduler diff --git a/scheduler/util_test.go b/scheduler/util_test.go index 9bb3ff81fea..eba4227e677 100644 --- a/scheduler/util_test.go +++ b/scheduler/util_test.go @@ -51,7 +51,7 @@ func TestDiffSystemAllocsForNode_Sysbatch_terminal(t *testing.T) { t.Run("current job", func(t *testing.T) { terminal := structs.TerminalByNodeByName{ "node1": map[string]*structs.Allocation{ - "my-sysbatch.pinger[0]": &structs.Allocation{ + "my-sysbatch.pinger[0]": { ID: uuid.Generate(), NodeID: "node1", Name: "my-sysbatch.pinger[0]", @@ -75,7 +75,7 @@ func TestDiffSystemAllocsForNode_Sysbatch_terminal(t *testing.T) { previousJob.JobModifyIndex -= 1 terminal := structs.TerminalByNodeByName{ "node1": map[string]*structs.Allocation{ - "my-sysbatch.pinger[0]": &structs.Allocation{ + "my-sysbatch.pinger[0]": { ID: uuid.Generate(), NodeID: "node1", Name: "my-sysbatch.pinger[0]", From 0d34b22880f92790da8abd839f3084a099b384cb Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Mon, 4 Oct 2021 13:50:42 -0400 Subject: [PATCH 3/3] update docs and changelog --- .changelog/11251.txt | 3 +++ contributing/golang.md | 1 + 2 files changed, 4 insertions(+) create mode 100644 .changelog/11251.txt diff --git a/.changelog/11251.txt b/.changelog/11251.txt new file mode 100644 index 00000000000..e7f74fb092e --- /dev/null +++ b/.changelog/11251.txt @@ -0,0 +1,3 @@ +```release-note:improvement +build: Updated to Go 1.17.1 +``` diff --git a/contributing/golang.md b/contributing/golang.md index f97cc266cee..e7090a42eed 100644 --- a/contributing/golang.md +++ b/contributing/golang.md @@ -12,6 +12,7 @@ version. | Nomad Version | Go Version | |:-------------:|:----------:| +| 1.2 | 1.17 | | 1.1 | 1.16 | | 1.0 | 1.15 | | 0.12 | 1.14 |