Skip to content

Commit 9c8dba4

Browse files
authored
Merge pull request #3220 from crazy-max/go-1.24
update to go 1.24
2 parents b63092e + f3306ba commit 9c8dba4

File tree

23 files changed

+113
-85
lines changed

23 files changed

+113
-85
lines changed

.golangci.yml

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,60 @@
1+
version: "2"
2+
13
run:
24
tests: false
35
timeout: 10m
46

57
linters:
6-
disable-all: true
8+
default: none
79
enable:
810
- misspell
9-
- gofmt
10-
- goimports
1111
- ineffassign
1212
- revive
1313
- unconvert
1414
- unused
1515
- govet
16+
settings:
17+
govet:
18+
enable:
19+
- nilness
20+
exclusions:
21+
generated: lax
22+
presets:
23+
- comments
24+
- common-false-positives
25+
- legacy
26+
- std-error-handling
27+
rules:
28+
- linters:
29+
- revive
30+
text: stutters
31+
- linters:
32+
- revive
33+
text: empty-block
34+
- linters:
35+
- revive
36+
text: superfluous-else
37+
- linters:
38+
- revive
39+
text: unused-parameter
40+
- linters:
41+
- revive
42+
text: redefines-builtin-id
43+
- linters:
44+
- revive
45+
text: if-return
46+
paths:
47+
- .*\.pb\.go$
48+
49+
formatters:
50+
enable:
51+
- gofmt
52+
- goimports
53+
exclusions:
54+
generated: lax
55+
paths:
56+
- .*\.pb\.go$
1657

1758
issues:
18-
exclude-files:
19-
- ".*\\.pb\\.go$"
2059
max-issues-per-linter: 0
2160
max-same-issues: 0

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION=1.21
3+
ARG GO_VERSION=1.24
44
ARG PROTOC_VERSION=3.11.4
5-
ARG GOLANGCI_LINT_VERSION=v1.57.2
5+
ARG GOLANGCI_LINT_VERSION=v2.1.5
66
ARG DEBIAN_FRONTEND=noninteractive
77

88
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bullseye AS gobase

ca/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (s *Server) GetUnlockKey(_ context.Context, _ *api.GetUnlockKeyRequest) (*a
147147
// NodeCertificateStatus returns the current issuance status of an issuance request identified by the nodeID
148148
func (s *Server) NodeCertificateStatus(ctx context.Context, request *api.NodeCertificateStatusRequest) (*api.NodeCertificateStatusResponse, error) {
149149
if request.NodeID == "" {
150-
return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
150+
return nil, status.Error(codes.InvalidArgument, codes.InvalidArgument.String())
151151
}
152152

153153
serverCtx, err := s.isRunningLocked()
@@ -178,7 +178,7 @@ func (s *Server) NodeCertificateStatus(ctx context.Context, request *api.NodeCer
178178

179179
// This node ID doesn't exist
180180
if node == nil {
181-
return nil, status.Errorf(codes.NotFound, codes.NotFound.String())
181+
return nil, status.Error(codes.NotFound, codes.NotFound.String())
182182
}
183183

184184
log.G(ctx).WithFields(log.Fields{
@@ -234,7 +234,7 @@ func (s *Server) NodeCertificateStatus(ctx context.Context, request *api.NodeCer
234234
func (s *Server) IssueNodeCertificate(ctx context.Context, request *api.IssueNodeCertificateRequest) (*api.IssueNodeCertificateResponse, error) {
235235
// First, let's see if the remote node is presenting a non-empty CSR
236236
if len(request.CSR) == 0 {
237-
return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
237+
return nil, status.Error(codes.InvalidArgument, codes.InvalidArgument.String())
238238
}
239239

240240
if err := s.isReadyLocked(); err != nil {

direct.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ version/version.go:
4242
setup: ## install dependencies
4343
@echo "🐳 $@"
4444
# install golangci-lint to ./bin/golangci-lint
45-
@curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/v1.57.2/install.sh | sh -s v1.57.2
45+
@curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/v2.1.5/install.sh | sh -s v2.1.5
4646
@(cd ./tools ; GO111MODULE=on go install github.com/containerd/protobuild)
4747

4848
.PHONY: generate

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/moby/swarmkit/v2
22

3-
go 1.21.0
3+
go 1.23.0
44

55
require (
66
code.cloudfoundry.org/clock v1.1.0

manager/allocator/allocator_test_suite.go

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,24 +2083,21 @@ func watchNode(t *testing.T, watch chan events.Event, expectTimeout bool,
20832083
case event := <-watch:
20842084
if n, ok := event.(api.EventUpdateNode); ok {
20852085
node = n.Node.Copy()
2086-
if fn == nil || (fn != nil && fn(mockTester{}, originalNode, node, networks)) {
2086+
if fn == nil || fn(mockTester{}, originalNode, node, networks) {
20872087
return
20882088
}
20892089
}
20902090

20912091
if n, ok := event.(api.EventDeleteNode); ok {
20922092
node = n.Node.Copy()
2093-
if fn == nil || (fn != nil && fn(mockTester{}, originalNode, node, networks)) {
2093+
if fn == nil || fn(mockTester{}, originalNode, node, networks) {
20942094
return
20952095
}
20962096
}
20972097

20982098
case <-time.After(getWatchTimeout(expectTimeout)):
20992099
if !expectTimeout {
2100-
if node != nil && fn != nil {
2101-
fn(t, originalNode, node, networks)
2102-
}
2103-
2100+
fn(t, originalNode, node, networks)
21042101
t.Fatal("timed out before watchNode found expected node state", string(debug.Stack()))
21052102
}
21062103

@@ -2116,24 +2113,21 @@ func watchNetwork(t *testing.T, watch chan events.Event, expectTimeout bool, fn
21162113
case event := <-watch:
21172114
if n, ok := event.(api.EventUpdateNetwork); ok {
21182115
network = n.Network.Copy()
2119-
if fn == nil || (fn != nil && fn(mockTester{}, network)) {
2116+
if fn == nil || fn(mockTester{}, network) {
21202117
return
21212118
}
21222119
}
21232120

21242121
if n, ok := event.(api.EventDeleteNetwork); ok {
21252122
network = n.Network.Copy()
2126-
if fn == nil || (fn != nil && fn(mockTester{}, network)) {
2123+
if fn == nil || fn(mockTester{}, network) {
21272124
return
21282125
}
21292126
}
21302127

21312128
case <-time.After(getWatchTimeout(expectTimeout)):
21322129
if !expectTimeout {
2133-
if network != nil && fn != nil {
2134-
fn(t, network)
2135-
}
2136-
2130+
fn(t, network)
21372131
t.Fatal("timed out before watchNetwork found expected network state", string(debug.Stack()))
21382132
}
21392133

@@ -2149,24 +2143,21 @@ func watchService(t *testing.T, watch chan events.Event, expectTimeout bool, fn
21492143
case event := <-watch:
21502144
if s, ok := event.(api.EventUpdateService); ok {
21512145
service = s.Service.Copy()
2152-
if fn == nil || (fn != nil && fn(mockTester{}, service)) {
2146+
if fn == nil || fn(mockTester{}, service) {
21532147
return
21542148
}
21552149
}
21562150

21572151
if s, ok := event.(api.EventDeleteService); ok {
21582152
service = s.Service.Copy()
2159-
if fn == nil || (fn != nil && fn(mockTester{}, service)) {
2153+
if fn == nil || fn(mockTester{}, service) {
21602154
return
21612155
}
21622156
}
21632157

21642158
case <-time.After(getWatchTimeout(expectTimeout)):
21652159
if !expectTimeout {
2166-
if service != nil && fn != nil {
2167-
fn(t, service)
2168-
}
2169-
2160+
fn(t, service)
21702161
t.Fatalf("timed out before watchService found expected service state\n stack = %s", string(debug.Stack()))
21712162
}
21722163

@@ -2182,24 +2173,21 @@ func watchTask(t *testing.T, s *store.MemoryStore, watch chan events.Event, expe
21822173
case event := <-watch:
21832174
if t, ok := event.(api.EventUpdateTask); ok {
21842175
task = t.Task.Copy()
2185-
if fn == nil || (fn != nil && fn(mockTester{}, s, task)) {
2176+
if fn == nil || fn(mockTester{}, s, task) {
21862177
return
21872178
}
21882179
}
21892180

21902181
if t, ok := event.(api.EventDeleteTask); ok {
21912182
task = t.Task.Copy()
2192-
if fn == nil || (fn != nil && fn(mockTester{}, s, task)) {
2183+
if fn == nil || fn(mockTester{}, s, task) {
21932184
return
21942185
}
21952186
}
21962187

21972188
case <-time.After(getWatchTimeout(expectTimeout)):
21982189
if !expectTimeout {
2199-
if task != nil && fn != nil {
2200-
fn(t, s, task)
2201-
}
2202-
2190+
fn(t, s, task)
22032191
t.Fatalf("timed out before watchTask found expected task state %s", debug.Stack())
22042192
}
22052193

manager/controlapi/ca_rotation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func validateCAConfig(ctx context.Context, securityConfig *ca.SecurityConfig, cl
241241
if cluster.RootCA.LastForcedRotation != newConfig.ForceRotate {
242242
newRootCA, err := ca.CreateRootCA(ca.DefaultRootCN)
243243
if err != nil {
244-
return nil, status.Errorf(codes.Internal, err.Error())
244+
return nil, status.Error(codes.Internal, err.Error())
245245
}
246246
return newRootRotationObject(ctx, securityConfig, &cluster.RootCA, newRootCA, oldCertExtCAs, newConfig.ForceRotate)
247247
}
@@ -265,7 +265,7 @@ func validateCAConfig(ctx context.Context, securityConfig *ca.SecurityConfig, cl
265265
}
266266
newRootCA, err := ca.NewRootCA(newConfig.SigningCACert, signingCert, newConfig.SigningCAKey, ca.DefaultNodeCertExpiration, nil)
267267
if err != nil {
268-
return nil, status.Errorf(codes.InvalidArgument, err.Error())
268+
return nil, status.Error(codes.InvalidArgument, err.Error())
269269
}
270270

271271
if len(newRootCA.Pool.Subjects()) != 1 {

manager/controlapi/cluster.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ var (
3232

3333
func validateClusterSpec(spec *api.ClusterSpec) error {
3434
if spec == nil {
35-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
35+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
3636
}
3737

3838
// Validate that expiry time being provided is valid, and over our minimum
3939
if spec.CAConfig.NodeCertExpiry != nil {
4040
expiry, err := gogotypes.DurationFromProto(spec.CAConfig.NodeCertExpiry)
4141
if err != nil {
42-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
42+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
4343
}
4444
if expiry < ca.MinNodeCertExpiration {
4545
return status.Errorf(codes.InvalidArgument, "minimum certificate expiry time is: %s", ca.MinNodeCertExpiration)
@@ -60,7 +60,7 @@ func validateClusterSpec(spec *api.ClusterSpec) error {
6060
if spec.Dispatcher.HeartbeatPeriod != nil {
6161
heartbeatPeriod, err := gogotypes.DurationFromProto(spec.Dispatcher.HeartbeatPeriod)
6262
if err != nil {
63-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
63+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
6464
}
6565
if heartbeatPeriod < 0 {
6666
return status.Errorf(codes.InvalidArgument, "heartbeat time period cannot be a negative duration")
@@ -79,7 +79,7 @@ func validateClusterSpec(spec *api.ClusterSpec) error {
7979
// - Returns `NotFound` if the Cluster is not found.
8080
func (s *Server) GetCluster(_ context.Context, request *api.GetClusterRequest) (*api.GetClusterResponse, error) {
8181
if request.ClusterID == "" {
82-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
82+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
8383
}
8484

8585
var cluster *api.Cluster
@@ -105,7 +105,7 @@ func (s *Server) GetCluster(_ context.Context, request *api.GetClusterRequest) (
105105
// - Returns an error if the update fails.
106106
func (s *Server) UpdateCluster(ctx context.Context, request *api.UpdateClusterRequest) (*api.UpdateClusterResponse, error) {
107107
if request.ClusterID == "" || request.ClusterVersion == nil {
108-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
108+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
109109
}
110110
if err := validateClusterSpec(request.Spec); err != nil {
111111
return nil, err

manager/controlapi/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (s *Server) GetConfig(_ context.Context, request *api.GetConfigRequest) (*a
5252
// - Returns an error if the update fails.
5353
func (s *Server) UpdateConfig(ctx context.Context, request *api.UpdateConfigRequest) (*api.UpdateConfigResponse, error) {
5454
if request.ConfigID == "" || request.ConfigVersion == nil {
55-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
55+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
5656
}
5757

5858
var config *api.Config
@@ -234,7 +234,7 @@ func (s *Server) RemoveConfig(ctx context.Context, request *api.RemoveConfigRequ
234234

235235
func validateConfigSpec(spec *api.ConfigSpec) error {
236236
if spec == nil {
237-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
237+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
238238
}
239239
if err := validateConfigOrSecretAnnotations(spec.Annotations); err != nil {
240240
return err

manager/controlapi/network.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (s *Server) validateIPAM(ipam *api.IPAMOptions) error {
7070

7171
func (s *Server) validateNetworkSpec(spec *api.NetworkSpec) error {
7272
if spec == nil {
73-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
73+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
7474
}
7575

7676
if spec.Attachable && spec.Ingress {
@@ -138,7 +138,7 @@ func (s *Server) CreateNetwork(_ context.Context, request *api.CreateNetworkRequ
138138
// - Returns `NotFound` if the Network is not found.
139139
func (s *Server) GetNetwork(ctx context.Context, request *api.GetNetworkRequest) (*api.GetNetworkResponse, error) {
140140
if request.NetworkID == "" {
141-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
141+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
142142
}
143143

144144
var n *api.Network
@@ -162,7 +162,7 @@ func (s *Server) GetNetwork(ctx context.Context, request *api.GetNetworkRequest)
162162
// - Returns an error if the deletion fails.
163163
func (s *Server) RemoveNetwork(_ context.Context, request *api.RemoveNetworkRequest) (*api.RemoveNetworkResponse, error) {
164164
if request.NetworkID == "" {
165-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
165+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
166166
}
167167

168168
var (

0 commit comments

Comments
 (0)