Skip to content

Commit 216c026

Browse files
committed
Bump golangci/golangci-lint-action from 6 to 8
All lint-actions after 6 require you to use lint version 2+. Pulled the 2.1 version of golangci-lint Ran 'golangci-lint migrate' Fixed concerns raised by linter.
1 parent 86d627e commit 216c026

File tree

7 files changed

+52
-33
lines changed

7 files changed

+52
-33
lines changed

.github/workflows/golangci-lint.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions:
1212

1313
env:
1414
GO_VERSION: v1.23.6
15-
GOLANGCI_LINT_VERSION: v1.60.1
15+
GOLANGCI_LINT_VERSION: v2.1
1616

1717
jobs:
1818
golangci:
@@ -24,7 +24,7 @@ jobs:
2424
with:
2525
go-version: ${{ env.GO_VERSION }}
2626
- name: golangci-lint
27-
uses: golangci/golangci-lint-action@v6
27+
uses: golangci/golangci-lint-action@v8
2828
with:
2929
version: ${{ env.GOLANGCI_LINT_VERSION }}
3030
args: --verbose

.golangci.yaml

+33-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
1-
run:
2-
timeout: 5m
1+
version: "2"
32
linters:
4-
disable-all: true
3+
default: none
54
enable:
6-
- gofmt
7-
- revive
8-
- gosec
9-
- govet
10-
- unused
5+
- gosec
6+
- govet
7+
- revive
8+
- unused
9+
exclusions:
10+
generated: lax
11+
presets:
12+
- comments
13+
- common-false-positives
14+
- legacy
15+
- std-error-handling
16+
rules:
17+
- linters:
18+
- gosec
19+
path: _test\.go
20+
- linters:
21+
- gosec
22+
path: ^tests/
23+
paths:
24+
- third_party$
25+
- builtin$
26+
- examples$
1127
issues:
1228
fix: true
13-
exclude-rules:
14-
# Don't run security checks on test files
15-
- path: _test\.go
16-
linters:
17-
- gosec
18-
- path: ^tests/
19-
linters:
20-
- gosec
29+
formatters:
30+
enable:
31+
- gofmt
32+
exclusions:
33+
generated: lax
34+
paths:
35+
- third_party$
36+
- builtin$
37+
- examples$

cmd/server/app/options/options.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type ProxyRunOptions struct {
7474
// ID of this proxy server.
7575
ServerID string
7676
// Number of proxy server instances, should be 1 unless it is a HA proxy server.
77-
ServerCount uint
77+
ServerCount int
7878
// Agent pod's namespace for token-based agent authentication
7979
AgentNamespace string
8080
// Agent pod's service account for token-based agent authentication
@@ -140,7 +140,7 @@ func (o *ProxyRunOptions) Flags() *pflag.FlagSet {
140140
flags.BoolVar(&o.EnableProfiling, "enable-profiling", o.EnableProfiling, "enable pprof at host:admin-port/debug/pprof")
141141
flags.BoolVar(&o.EnableContentionProfiling, "enable-contention-profiling", o.EnableContentionProfiling, "enable contention profiling at host:admin-port/debug/pprof/block. \"--enable-profiling\" must also be set.")
142142
flags.StringVar(&o.ServerID, "server-id", o.ServerID, "The unique ID of this server. Can also be set by the 'PROXY_SERVER_ID' environment variable.")
143-
flags.UintVar(&o.ServerCount, "server-count", o.ServerCount, "The number of proxy server instances, should be 1 unless it is an HA server.")
143+
flags.IntVar(&o.ServerCount, "server-count", o.ServerCount, "The number of proxy server instances, should be 1 unless it is an HA server.")
144144
flags.StringVar(&o.AgentNamespace, "agent-namespace", o.AgentNamespace, "Expected agent's namespace during agent authentication (used with agent-service-account, authentication-audience, kubeconfig).")
145145
flags.StringVar(&o.AgentServiceAccount, "agent-service-account", o.AgentServiceAccount, "Expected agent's service account during agent authentication (used with agent-namespace, authentication-audience, kubeconfig).")
146146
flags.StringVar(&o.KubeconfigPath, "kubeconfig", o.KubeconfigPath, "absolute path to the kubeconfig file (used with agent-namespace, agent-service-account, authentication-audience).")

cmd/server/app/options/options_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestDefaultServerOptions(t *testing.T) {
5252
assertDefaultValue(t, "FrontendKeepaliveTime", defaultServerOptions.FrontendKeepaliveTime, 1*time.Hour)
5353
assertDefaultValue(t, "EnableProfiling", defaultServerOptions.EnableProfiling, false)
5454
assertDefaultValue(t, "EnableContentionProfiling", defaultServerOptions.EnableContentionProfiling, false)
55-
assertDefaultValue(t, "ServerCount", defaultServerOptions.ServerCount, uint(1))
55+
assertDefaultValue(t, "ServerCount", defaultServerOptions.ServerCount, 1)
5656
assertDefaultValue(t, "AgentNamespace", defaultServerOptions.AgentNamespace, "")
5757
assertDefaultValue(t, "AgentServiceAccount", defaultServerOptions.AgentServiceAccount, "")
5858
assertDefaultValue(t, "KubeconfigPath", defaultServerOptions.KubeconfigPath, "")

cmd/server/app/server.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (p *Proxy) Run(o *options.ProxyRunOptions, stopCh <-chan struct{}) error {
138138
if err != nil {
139139
return err
140140
}
141-
p.server = server.NewProxyServer(o.ServerID, ps, int(o.ServerCount), authOpt, o.XfrChannelSize)
141+
p.server = server.NewProxyServer(o.ServerID, ps, o.ServerCount, authOpt, o.XfrChannelSize)
142142

143143
frontendStop, err := p.runFrontendServer(ctx, o, p.server)
144144
if err != nil {
@@ -352,7 +352,7 @@ func (p *Proxy) runMTLSFrontendServer(ctx context.Context, o *options.ProxyRunOp
352352
}
353353
labels := runpprof.Labels(
354354
"core", "mtlsGrpcFrontend",
355-
"port", strconv.FormatUint(uint64(o.ServerPort), 10),
355+
"port", strconv.Itoa(o.ServerPort),
356356
)
357357
go runpprof.Do(context.Background(), labels, func(context.Context) { grpcServer.Serve(lis) })
358358
stop = grpcServer.GracefulStop
@@ -375,7 +375,7 @@ func (p *Proxy) runMTLSFrontendServer(ctx context.Context, o *options.ProxyRunOp
375375
}
376376
labels := runpprof.Labels(
377377
"core", "mtlsHttpFrontend",
378-
"port", strconv.FormatUint(uint64(o.ServerPort), 10),
378+
"port", strconv.Itoa(o.ServerPort),
379379
)
380380
go runpprof.Do(context.Background(), labels, func(context.Context) {
381381
err := server.ListenAndServeTLS("", "") // empty files defaults to tlsConfig
@@ -412,7 +412,7 @@ func (p *Proxy) runAgentServer(o *options.ProxyRunOptions, server *server.ProxyS
412412
}
413413
labels := runpprof.Labels(
414414
"core", "agentListener",
415-
"port", strconv.FormatUint(uint64(o.AgentPort), 10),
415+
"port", strconv.Itoa(o.AgentPort),
416416
)
417417
go runpprof.Do(context.Background(), labels, func(context.Context) { grpcServer.Serve(lis) })
418418
p.agentServer = grpcServer
@@ -442,7 +442,7 @@ func (p *Proxy) runAdminServer(o *options.ProxyRunOptions, _ *server.ProxyServer
442442

443443
labels := runpprof.Labels(
444444
"core", "adminListener",
445-
"port", strconv.FormatUint(uint64(o.AdminPort), 10),
445+
"port", strconv.Itoa(o.AdminPort),
446446
)
447447
go runpprof.Do(context.Background(), labels, func(context.Context) {
448448
err := p.adminServer.ListenAndServe()
@@ -484,7 +484,7 @@ func (p *Proxy) runHealthServer(o *options.ProxyRunOptions, server *server.Proxy
484484

485485
labels := runpprof.Labels(
486486
"core", "healthListener",
487-
"port", strconv.FormatUint(uint64(o.HealthPort), 10),
487+
"port", strconv.Itoa(o.HealthPort),
488488
)
489489
go runpprof.Do(context.Background(), labels, func(context.Context) {
490490
err := p.healthServer.ListenAndServe()

tests/framework/proxy_server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func serverOptions(t testing.TB, opts ProxyServerOpts) (*serveropts.ProxyRunOpti
139139
t.Helper()
140140
o := serveropts.NewProxyRunOptions()
141141

142-
o.ServerCount = uint(opts.ServerCount)
142+
o.ServerCount = opts.ServerCount
143143
o.Mode = opts.Mode
144144

145145
uid := uuid.New().String()

tests/proxy_test.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,13 @@ type delayedServer struct {
105105
maxWait time.Duration
106106
}
107107

108-
// randomDuration returns a random duration in the [min, max) interval
109-
func randomDuration(min, max time.Duration) time.Duration {
110-
d := min
111-
if max != min {
112-
d += time.Duration(rand.Int63n(int64(max - min)))
108+
// randomDuration returns a random duration in the [lower, upper) interval
109+
// Cannot use min/max because linter gives the following error.
110+
// "redefines-builtin-id: redefinition of the built-in function min (revive)"
111+
func randomDuration(lower, upper time.Duration) time.Duration {
112+
d := lower
113+
if upper != lower {
114+
d += time.Duration(rand.Int63n(int64(upper - lower)))
113115
}
114116
return d
115117
}

0 commit comments

Comments
 (0)