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 2dd81ad025db..228ae36cd7e4 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 4e9f8ebe89cb..945e35d80c5e 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 92c3849ccb64..0222e2d43622 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 7d60c34653ae..89854b0ee0ba 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 6ee1eaeca657..fd85d5bccbdb 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 a5fac0310f0a..811fa0a74f6d 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 ebe2872a938d..88cb12260727 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 0eebd62f92d7..79a7c2da87e8 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 db4f8ebf2b15..f774e9b2f822 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 77447a32f7f3..9f8326938701 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 08e7ba6eb7ea..87f813f7feb1 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 2130162542c0..b21d3fecba60 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 49f161fcbaa2..e8a2d4ea54c6 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 ce3a994d54ed..0ca806fb8f3e 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 832ca32cea2b..c4d761d4d061 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 ab46a0d193ba..5d473613fb35 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 cf64766bc055..df85c054e775 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 2f2dcc6fc63e..c0adcb0e9c94 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 76bc5c519b0d..da850719ef4e 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 aa75ab8eaf02..7967a69f01e1 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 923fef86d44b..0d68f7e8372a 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 bf5445227301..506253f134e9 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 70d68cf3ca3a..272540834ea8 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 2bf58faac355..36cefdf0f310 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 8aa5b7455eeb..d357c1e17e6b 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 79676ad79440..1b266c3c6715 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 e2ae1ec6f3c3..d558d62f62f9 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 3faa93881458..7cf924031291 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 4b0fce93dcc0..892398d559d0 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 ada8f4beab33..3ac5a6caed86 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 e9bc0f35146e..c2fc74e0da28 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 29c970d7f2b2..1f8c077baa6d 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 c1d90a3adb3b..28f51e929162 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 080bf1c2d3a2..b442db3aa320 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 06b78cb8719e..c4f92ce754fe 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 3b8733603381..4594204e59fa 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 c91544276050..9ae283f6f121 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 235b319c1157..8ebcee193cb8 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 856ac91637ae..7a78070541ad 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 f886282ce28e..f9776988b7ad 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 a5fae0a58911..30417004578e 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 2b15988b9a51..11aa237f7350 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 863ab4bc27ca..7f54194c935b 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 9e9a0fd01326..7cbf2301b379 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 d589afebebcd..8467c907beaf 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 00ef7222d850..17fbd2592c6c 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 eae187a51eaf..4f93ace4ae34 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 36c3901df25e..a03caaed13dd 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 c875a5bc0abb..69626b50e3c8 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 83dae1bd2362..2b283681ff65 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 d4d7bd09e04b..a5611e2addf9 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 8c187e232eb0..155f2cff719e 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 7f4862a63e78..296b0fa5d742 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 95b018333167..822199c623cd 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 fa4a387dddc6..74073b8f2711 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 91b0d042a85b..351332c62beb 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 3c7f7dde8842..6fee89c60542 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 b1f21e8c2716..d50935e7c601 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 954d4cf7024b..53689320f62c 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 53485dbb955a..b9deb9213e77 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 b180ae8f92bf..8607b899b199 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 f51b8b3f07a9..aa542a58b1ed 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 d3658ea351cf..019b42764b15 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 05306d83fe5a..f54b83f20956 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 356096395763..ae755c430039 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 2260ef89ef1d..29f526964511 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 2891fe8d3130..d433055e9615 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 3b2e60374aa8..a9da57c02d50 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 b35902297fa0..9d6d6d70a53d 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 7326ad172d33..083166bd37c3 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 54be7ed79f7c..1956125c31fb 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 6f90b7ade4f5..da2d9ddcb757 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 964c09fbda3e..d940d9e0423c 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 12411a5a5d44..f9c4cf35e8b2 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 7bd02dbb69d2..ff4c8f9e8087 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 ce1a39f86679..6f45ccf43413 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 e7273b1d803e..97ee369b9bcf 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 271eb6c02744..8469f0a30d4d 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 249fd6f53fc7..ce41810aef06 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 bf0ed6eacfd3..88f2fc88d4a6 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 948fa109c924..e77783e58b7e 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 a7a586aa8428..44a0f3a4bae2 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 3c166ae0c56d..27446ebbd7ba 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 897f8fbf6eca..48277420e1d9 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 e602f474ad72..10d0b9bba9f8 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 3c335c88bb2e..64b420eb46c5 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 342b4a0c639f..4e6de69ed9a9 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 2d9385df4bf6..cd4e9db34281 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 9401c107fe4c..c4cd40df7f89 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 4e4f2ab69d21..0bca7bf958b7 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 8605aded4b49..5522faea29da 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 d3d58c925ee8..f1e0914ba8ca 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 fefea7cb2508..5ef82140488d 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 7e8c4bb7c1e8..021e1cc2448a 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 c9e725b12a20..0ac4e7cde76e 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 8a12f59ce0a9..1ac93507dfc5 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 c3d3ceb682e1..cac2fb0d4056 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 a532b418ecee..28273038971e 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 eeecf1b82dad..84c043d1531b 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 6fbd6e36909f..520467d71cee 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 79993291db82..464bfcf09a0e 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 4e5f9cea065c..150780d156e0 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 427fa904f8cb..98b363ad48bb 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 eb912f0a3d98..7c15a04baa8f 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 aa7f4389a1e4..b21ca608e643 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 3ac0351ae0f1..c1a18750fdf8 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 ac43893f4ebe..d44853818425 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 24ac312aaa14..e90e7cb82003 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 38ff1d4aacbb..eb19d9107b94 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 1b413a1e5b3c..44534cab6cef 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 a724518c296c..4a8735b4e609 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 6ada6a06e065..2e08a9ea508b 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 e8f91195ecda..aaa57de03240 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 a2a2cc4e8e69..fa1c36c70f6b 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 4479fa8388a2..de3359c345ac 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 ec540a82c230..2d0fcf379711 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 ab14ba01a160..b595b419b0a7 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 5f4d5e82cc2f..2db273d7b2fa 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 d7592be07aa5..12e08cc97109 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 2298250d8029..1b38d9c00050 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 736b518d7818..d698b2d87449 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 71cdff3ecffb..a6062f2a1db7 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 2c1660ec2914..7214c6be826c 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 9bb3ff81fea8..eba4227e6773 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 000000000000..e7f74fb092ef --- /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 f97cc266ceea..e7090a42eedf 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 |