Skip to content

Commit 62f9431

Browse files
authored
Update golangci lint to v2.x (#1256)
* update golangci-lint to v2 Signed-off-by: Etai Lev Ran <[email protected]> * fix v2 lint issues Signed-off-by: Etai Lev Ran <[email protected]> --------- Signed-off-by: Etai Lev Ran <[email protected]>
1 parent 0f31663 commit 62f9431

File tree

9 files changed

+59
-48
lines changed

9 files changed

+59
-48
lines changed

.golangci.yml

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,54 @@
1+
version: "2"
12
run:
2-
timeout: 5m
33
allow-parallel-runners: true
4-
5-
# Settings related to issues
6-
issues:
7-
# Which dirs to exclude: issues from them won't be reported
8-
exclude-dirs:
9-
- bin
104
linters:
11-
disable-all: true
5+
default: none
126
enable:
137
- copyloopvar
148
- dupword
159
- durationcheck
10+
- errcheck
1611
- fatcontext
1712
- ginkgolinter
13+
- goconst
1814
- gocritic
1915
- govet
16+
- ineffassign
2017
- loggercheck
18+
- makezero
2119
- misspell
20+
- nakedret
2221
- perfsprint
22+
- prealloc
2323
- revive
24+
- staticcheck
2425
- unconvert
25-
- makezero
26-
- errcheck
27-
- goconst
28-
- gofmt
29-
- goimports
30-
- gosimple
31-
- ineffassign
32-
- nakedret
33-
- prealloc
34-
- typecheck
3526
- unparam
3627
- unused
37-
38-
linters-settings:
39-
revive:
40-
rules:
41-
- name: comment-spacings
28+
settings:
29+
revive:
30+
rules:
31+
- name: comment-spacings
32+
exclusions:
33+
generated: lax
34+
presets:
35+
- comments
36+
- common-false-positives
37+
- legacy
38+
- std-error-handling
39+
paths:
40+
- bin
41+
- third_party$
42+
- builtin$
43+
- examples$
44+
formatters:
45+
enable:
46+
- gofmt
47+
- goimports
48+
exclusions:
49+
generated: lax
50+
paths:
51+
- bin
52+
- third_party$
53+
- builtin$
54+
- examples$

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ test-e2e: ## Run end-to-end tests against an existing Kubernetes cluster.
149149

150150
.PHONY: lint
151151
lint: golangci-lint ## Run golangci-lint linter
152-
$(GOLANGCI_LINT) run
152+
$(GOLANGCI_LINT) run --timeout 5m
153153

154154
.PHONY: lint-fix
155155
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
@@ -373,7 +373,7 @@ GCI = $(LOCALBIN)/gci
373373
KUSTOMIZE_VERSION ?= v5.4.3
374374
CONTROLLER_TOOLS_VERSION ?= v0.16.1
375375
ENVTEST_VERSION ?= release-0.19
376-
GOLANGCI_LINT_VERSION ?= v1.62.2
376+
GOLANGCI_LINT_VERSION ?= v2.3.0
377377
HELM_VERSION ?= v3.17.1
378378
KUBECTL_VALIDATE_VERSION ?= v0.0.4
379379
GCI_VERSION ?= v0.13.6
@@ -396,7 +396,7 @@ $(ENVTEST): $(LOCALBIN)
396396
.PHONY: golangci-lint
397397
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
398398
$(GOLANGCI_LINT): $(LOCALBIN)
399-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
399+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
400400

401401
.PHONY: yq
402402
yq: ## Download yq locally if necessary.

conformance/conformance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func ensureGatewayAvailableAndReady(t *testing.T, k8sClient client.Client, opts
296296
extTimeoutConf := inferenceconfig.DefaultInferenceExtensionTimeoutConfig()
297297

298298
// Use the GatewayMustHaveAddress timeout from the suite's base TimeoutConfig for the Gateway object to appear.
299-
waitForGatewayCreationTimeout := extTimeoutConf.TimeoutConfig.GatewayMustHaveAddress
299+
waitForGatewayCreationTimeout := extTimeoutConf.GatewayMustHaveAddress
300300

301301
logDebugf(t, opts.Debug, "Waiting up to %v for Gateway object %s/%s to appear after manifest application...", waitForGatewayCreationTimeout, gatewayNN.Namespace, gatewayNN.Name)
302302

conformance/tests/basic/gateway_following_epp_routing.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
3434
k8sutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes"
3535
"sigs.k8s.io/gateway-api-inference-extension/conformance/utils/traffic"
36-
trafficutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/traffic"
3736
)
3837

3938
func init() {
@@ -94,12 +93,12 @@ var GatewayFollowingEPPRouting = suite.ConformanceTest{
9493
for i := 0; i < len(pods); i++ {
9594
// Send an initial request targeting a single pod and wait for it to be successful to ensure the Gateway and EPP
9695
// are functioning correctly before running the main test cases.
97-
trafficutils.MakeRequestAndExpectSuccess(
96+
traffic.MakeRequestAndExpectSuccess(
9897
t,
9998
s.RoundTripper,
10099
s.TimeoutConfig,
101100
gwAddr,
102-
trafficutils.Request{
101+
traffic.Request{
103102
Host: hostname,
104103
Path: path,
105104
Headers: map[string]string{eppSelectionHeaderName: podIPs[i]},

conformance/utils/kubernetes/helpers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func checkCondition(t *testing.T, conditions []metav1.Condition, expectedConditi
7272
func InferencePoolMustHaveCondition(t *testing.T, c client.Reader, poolNN types.NamespacedName, expectedCondition metav1.Condition) {
7373
t.Helper() // Marks this function as a test helper
7474

75-
var timeoutConfig config.InferenceExtensionTimeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()
75+
var timeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()
7676
var lastObservedPool *inferenceapi.InferencePool
7777
var lastError error
7878
var conditionFound bool
@@ -165,7 +165,7 @@ func InferencePoolMustHaveNoParents(t *testing.T, c client.Reader, poolNN types.
165165

166166
var lastObservedPool *inferenceapi.InferencePool
167167
var lastError error
168-
var timeoutConfig config.InferenceExtensionTimeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()
168+
var timeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()
169169

170170
ctx := context.Background()
171171
waitErr := wait.PollUntilContextTimeout(
@@ -286,7 +286,7 @@ func HTTPRouteAndInferencePoolMustBeAcceptedAndRouteAccepted(
286286
gatewayNN types.NamespacedName,
287287
poolNN types.NamespacedName) {
288288
t.Helper()
289-
var timeoutConfig config.InferenceExtensionTimeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()
289+
var timeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()
290290

291291
HTTPRouteMustBeAcceptedAndResolved(t, c, timeoutConfig.TimeoutConfig, routeNN, gatewayNN)
292292
InferencePoolMustBeRouteAccepted(t, c, poolNN)

pkg/bbr/handlers/request.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
basepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
2525
eppb "github.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3"
26-
extProcPb "github.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3"
2726
"sigs.k8s.io/controller-runtime/pkg/log"
2827

2928
"sigs.k8s.io/gateway-api-inference-extension/pkg/bbr/metrics"
@@ -122,13 +121,13 @@ func (s *Server) HandleRequestBody(ctx context.Context, requestBodyBytes []byte)
122121
}
123122

124123
func addStreamedBodyResponse(responses []*eppb.ProcessingResponse, requestBodyBytes []byte) []*eppb.ProcessingResponse {
125-
return append(responses, &extProcPb.ProcessingResponse{
126-
Response: &extProcPb.ProcessingResponse_RequestBody{
127-
RequestBody: &extProcPb.BodyResponse{
128-
Response: &extProcPb.CommonResponse{
129-
BodyMutation: &extProcPb.BodyMutation{
130-
Mutation: &extProcPb.BodyMutation_StreamedResponse{
131-
StreamedResponse: &extProcPb.StreamedBodyResponse{
124+
return append(responses, &eppb.ProcessingResponse{
125+
Response: &eppb.ProcessingResponse_RequestBody{
126+
RequestBody: &eppb.BodyResponse{
127+
Response: &eppb.CommonResponse{
128+
BodyMutation: &eppb.BodyMutation{
129+
Mutation: &eppb.BodyMutation_StreamedResponse{
130+
StreamedResponse: &eppb.StreamedBodyResponse{
132131
Body: requestBodyBytes,
133132
EndOfStream: true,
134133
},

pkg/epp/datastore/datastore.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (ds *datastore) ModelSetIfOlder(infModel *v1alpha2.InferenceModel) bool {
175175
existing, exists := ds.models[infModel.Spec.ModelName]
176176
if exists {
177177
diffObj := infModel.Name != existing.Name || infModel.Namespace != existing.Namespace
178-
if diffObj && existing.ObjectMeta.CreationTimestamp.Before(&infModel.ObjectMeta.CreationTimestamp) {
178+
if diffObj && existing.CreationTimestamp.Before(&infModel.CreationTimestamp) {
179179
return false
180180
}
181181
}
@@ -205,7 +205,7 @@ func (ds *datastore) ModelResync(ctx context.Context, reader client.Reader, mode
205205
!m.DeletionTimestamp.IsZero() { // ignore objects marked for deletion
206206
continue
207207
}
208-
if oldest == nil || m.ObjectMeta.CreationTimestamp.Before(&oldest.ObjectMeta.CreationTimestamp) {
208+
if oldest == nil || m.CreationTimestamp.Before(&oldest.CreationTimestamp) {
209209
oldest = m
210210
}
211211
}

pkg/epp/util/testing/wrappers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (p *PodWrapper) IP(ip string) *PodWrapper {
101101
func (p *PodWrapper) DeletionTimestamp() *PodWrapper {
102102
now := metav1.Now()
103103
p.ObjectMeta.DeletionTimestamp = &now
104-
p.ObjectMeta.Finalizers = []string{"finalizer"}
104+
p.Finalizers = []string{"finalizer"}
105105
return p
106106
}
107107

@@ -160,7 +160,7 @@ func (m *InferenceModelWrapper) Criticality(criticality v1alpha2.Criticality) *I
160160
func (m *InferenceModelWrapper) DeletionTimestamp() *InferenceModelWrapper {
161161
now := metav1.Now()
162162
m.ObjectMeta.DeletionTimestamp = &now
163-
m.ObjectMeta.Finalizers = []string{"finalizer"}
163+
m.Finalizers = []string{"finalizer"}
164164
return m
165165
}
166166

pkg/generator/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ func main() {
7979
crdRaw := parser.CustomResourceDefinitions[groupKind]
8080

8181
// Inline version of "addAttribution(&crdRaw)" ...
82-
if crdRaw.ObjectMeta.Annotations == nil {
83-
crdRaw.ObjectMeta.Annotations = map[string]string{}
82+
if crdRaw.Annotations == nil {
83+
crdRaw.Annotations = map[string]string{}
8484
}
85-
crdRaw.ObjectMeta.Annotations[version.BundleVersionAnnotation] = version.BundleVersion
85+
crdRaw.Annotations[version.BundleVersionAnnotation] = version.BundleVersion
8686

8787
// Prevent the top level metadata for the CRD to be generated regardless of the intention in the arguments
8888
crd.FixTopLevelMetadata(crdRaw)

0 commit comments

Comments
 (0)