Skip to content

Commit c9a0e65

Browse files
committed
Updated golang version
go mod edit -go 1.23.0 go mod vendor make clean make certs make gen make build Fixed case of as to match FROM. Switch go version to 1.23 consistently. Finished switch from uber/mock to golang/mock. Updating to lint 1.60.1, which is needed for golang 1.23
1 parent c1a1e09 commit c9a0e65

File tree

24 files changed

+1556
-63
lines changed

24 files changed

+1556
-63
lines changed

.github/workflows/golangci-lint.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ permissions:
1010
contents: read
1111

1212
env:
13-
GO_VERSION: v1.22
14-
GOLANGCI_LINT_VERSION: v1.56
13+
GO_VERSION: v1.23
14+
GOLANGCI_LINT_VERSION: v1.60.1
1515

1616
jobs:
1717
golangci:

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ALL_ARCH ?= amd64 arm arm64 ppc64le s390x
2424
# The output type could either be docker (local), or registry.
2525
OUTPUT_TYPE ?= docker
2626
GO_TOOLCHAIN ?= golang
27-
GO_VERSION ?= 1.22.7
27+
GO_VERSION ?= 1.23.0
2828
BASEIMAGE ?= gcr.io/distroless/static-debian11:nonroot
2929

3030
ifeq ($(GOPATH),)
@@ -33,7 +33,7 @@ endif
3333
GOOS ?= $(shell go env GOOS)
3434
GOARCH ?= $(shell go env GOARCH)
3535
INSTALL_LOCATION:=$(shell go env GOPATH)/bin
36-
GOLANGCI_LINT_VERSION ?= 1.56.2
36+
GOLANGCI_LINT_VERSION ?= 1.60.1
3737
GOSEC_VERSION ?= 2.13.1
3838

3939
REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
@@ -125,7 +125,7 @@ bin/proxy-server:
125125
.PHONY: lint
126126
lint:
127127
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(INSTALL_LOCATION) v$(GOLANGCI_LINT_VERSION)
128-
$(INSTALL_LOCATION)/golangci-lint run --verbose
128+
$(INSTALL_LOCATION)/golangci-lint run --config ./.golangci.yaml --verbose
129129

130130
## --------------------------------------
131131
## Go

artifacts/images/agent-build.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG GO_TOOLCHAIN
55
ARG GO_VERSION
66
ARG BASEIMAGE
77

8-
FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} as builder
8+
FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} AS builder
99

1010
# Copy in the go src
1111
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy

artifacts/images/server-build.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG GO_TOOLCHAIN
55
ARG GO_VERSION
66
ARG BASEIMAGE
77

8-
FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} as builder
8+
FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} AS builder
99

1010
# Copy in the go src
1111
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy

artifacts/images/test-client-build.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG GO_TOOLCHAIN
55
ARG GO_VERSION
66
ARG BASEIMAGE
77

8-
FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} as builder
8+
FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} AS builder
99

1010
# Copy in the go src
1111
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy

artifacts/images/test-server-build.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG GO_TOOLCHAIN
55
ARG GO_VERSION
66
ARG BASEIMAGE
77

8-
FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} as builder
8+
FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} AS builder
99

1010
# Copy in the go src
1111
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy

cmd/server/app/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ func (p *Proxy) runHealthServer(o *options.ProxyRunOptions, server *server.Proxy
467467
return
468468
}
469469
w.WriteHeader(500)
470-
fmt.Fprintf(w, msg)
470+
fmt.Fprint(w, msg)
471471
})
472472

473473
muxHandler := http.NewServeMux()

go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module sigs.k8s.io/apiserver-network-proxy
22

3-
go 1.22.7
3+
go 1.23.0
44

55
require (
66
github.com/google/uuid v1.6.0
@@ -40,6 +40,7 @@ require (
4040
github.com/go-openapi/jsonreference v0.20.2 // indirect
4141
github.com/go-openapi/swag v0.22.4 // indirect
4242
github.com/gogo/protobuf v1.3.2 // indirect
43+
github.com/golang/mock v1.6.0 // indirect
4344
github.com/golang/protobuf v1.5.4 // indirect
4445
github.com/google/gnostic-models v0.6.8 // indirect
4546
github.com/google/go-cmp v0.6.0 // indirect

go.sum

+11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v
3333
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
3434
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
3535
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
36+
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
37+
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
3638
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
3739
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
3840
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
@@ -122,6 +124,7 @@ github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
122124
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
123125
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
124126
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
127+
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
125128
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
126129
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
127130
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
@@ -137,22 +140,29 @@ golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6R
137140
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
138141
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
139142
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
143+
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
140144
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
141145
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
142146
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
143147
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
148+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
144149
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
145150
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
146151
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
147152
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
148153
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
149154
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
150155
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
156+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
151157
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
152158
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
153159
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
160+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
161+
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
162+
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
154163
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
155164
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
165+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
156166
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
157167
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
158168
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -165,6 +175,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
165175
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
166176
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
167177
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
178+
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
168179
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
169180
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
170181
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

konnectivity-client/proto/client/client.pb.go

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/agent/clientset.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ import (
3232

3333
const (
3434
fromResponses = "KNP server response headers"
35-
fromLeases = "KNP lease count"
36-
fromFallback = "fallback to 1"
35+
fromLeases = "KNP lease count"
36+
fromFallback = "fallback to 1"
3737
)
3838

3939
// ClientSet consists of clients connected to each instance of an HA proxy server.
@@ -46,8 +46,8 @@ type ClientSet struct {
4646
address string // proxy server address. Assuming HA proxy server
4747

4848
leaseCounter ServerCounter // counts number of proxy server leases
49-
lastReceivedServerCount int // last server count received from a proxy server
50-
lastServerCount int // last server count value from either lease system or proxy server, former takes priority
49+
lastReceivedServerCount int // last server count received from a proxy server
50+
lastServerCount int // last server count value from either lease system or proxy server, former takes priority
5151

5252
// unless it is an HA server. Initialized when the ClientSet creates
5353
// the first client. When syncForever is set, it will be the most recently seen.
@@ -73,7 +73,7 @@ type ClientSet struct {
7373
warnOnChannelLimit bool
7474
xfrChannelSize int
7575

76-
syncForever bool // Continue syncing (support dynamic server count).
76+
syncForever bool // Continue syncing (support dynamic server count).
7777
serverCountSource string
7878
}
7979

pkg/agent/clientset_test.go

+28-29
Original file line numberDiff line numberDiff line change
@@ -29,59 +29,58 @@ func (f *FakeServerCounter) Count() int {
2929
}
3030

3131
func TestServerCount(t *testing.T) {
32-
testCases := []struct{
33-
name string
32+
testCases := []struct {
33+
name string
3434
serverCountSource string
35-
leaseCounter ServerCounter
36-
responseCount int
37-
want int
38-
} {
35+
leaseCounter ServerCounter
36+
responseCount int
37+
want int
38+
}{
3939
{
40-
name: "higher from response",
40+
name: "higher from response",
4141
serverCountSource: "max",
42-
responseCount: 42,
43-
leaseCounter: &FakeServerCounter{24},
44-
want: 42,
42+
responseCount: 42,
43+
leaseCounter: &FakeServerCounter{24},
44+
want: 42,
4545
},
4646
{
47-
name: "higher from leases",
47+
name: "higher from leases",
4848
serverCountSource: "max",
49-
responseCount: 3,
50-
leaseCounter: &FakeServerCounter{6},
51-
want: 6,
49+
responseCount: 3,
50+
leaseCounter: &FakeServerCounter{6},
51+
want: 6,
5252
},
5353
{
54-
name: "both zero",
54+
name: "both zero",
5555
serverCountSource: "max",
56-
responseCount: 0,
57-
leaseCounter: &FakeServerCounter{0},
58-
want: 1,
56+
responseCount: 0,
57+
leaseCounter: &FakeServerCounter{0},
58+
want: 1,
5959
},
6060

6161
{
62-
name: "response picked by default when no lease counter",
62+
name: "response picked by default when no lease counter",
6363
serverCountSource: "default",
64-
responseCount: 3,
65-
leaseCounter: nil,
66-
want: 3,
64+
responseCount: 3,
65+
leaseCounter: nil,
66+
want: 3,
6767
},
6868
{
69-
name: "lease counter always picked when present",
69+
name: "lease counter always picked when present",
7070
serverCountSource: "default",
71-
responseCount: 6,
72-
leaseCounter: &FakeServerCounter{3},
73-
want: 3,
71+
responseCount: 6,
72+
leaseCounter: &FakeServerCounter{3},
73+
want: 3,
7474
},
7575
}
7676

7777
for _, tc := range testCases {
7878
t.Run(tc.name, func(t *testing.T) {
7979

8080
cs := &ClientSet{
81-
clients: make(map[string]*Client),
82-
leaseCounter: tc.leaseCounter,
81+
clients: make(map[string]*Client),
82+
leaseCounter: tc.leaseCounter,
8383
serverCountSource: tc.serverCountSource,
84-
8584
}
8685
cs.lastReceivedServerCount = tc.responseCount
8786
if got := cs.ServerCount(); got != tc.want {

pkg/server/backend_manager_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"reflect"
2323
"testing"
2424

25+
"github.com/golang/mock/gomock"
2526
"github.com/stretchr/testify/assert"
26-
"go.uber.org/mock/gomock"
2727
"google.golang.org/grpc/metadata"
2828

2929
agentmock "sigs.k8s.io/apiserver-network-proxy/proto/agent/mocks"

pkg/server/server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"testing"
2626
"time"
2727

28+
"github.com/golang/mock/gomock"
2829
"github.com/google/uuid"
29-
"go.uber.org/mock/gomock"
3030
"google.golang.org/grpc/metadata"
3131

3232
promtest "github.com/prometheus/client_golang/prometheus/testutil"

proto/agent/mocks/agent_mock.go

+9-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)