Skip to content

Commit 2bdc376

Browse files
authored
chore: adopt golangci-lint v2 (#474)
Signed-off-by: rudeigerc <[email protected]>
1 parent dbdb8c9 commit 2bdc376

File tree

10 files changed

+47
-37
lines changed

10 files changed

+47
-37
lines changed

.github/workflows/golang-workflow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ on:
88

99
jobs:
1010
golang-ci:
11-
uses: kerthcet/github-workflow-as-kube/.github/workflows/[email protected].18
11+
uses: kerthcet/github-workflow-as-kube/.github/workflows/[email protected].21

.github/workflows/kube-workflow-init.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ on:
55

66
jobs:
77
init:
8-
uses: kerthcet/github-workflow-as-kube/.github/workflows/[email protected].18
8+
uses: kerthcet/github-workflow-as-kube/.github/workflows/[email protected].21
99
secrets:
1010
AGENT_TOKEN: ${{ secrets.AGENT_TOKEN }}

.github/workflows/kube-workflow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ on:
1919

2020
jobs:
2121
event-handler:
22-
uses: kerthcet/github-workflow-as-kube/.github/workflows/[email protected].18
22+
uses: kerthcet/github-workflow-as-kube/.github/workflows/[email protected].21
2323
secrets:
2424
AGENT_TOKEN: ${{ secrets.AGENT_TOKEN }}

.golangci.yaml

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
1+
version: "2"
12
run:
2-
timeout: 5m
33
allow-parallel-runners: true
4-
5-
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
8-
exclude-use-default: false
9-
# restore some of the defaults
10-
# (fill in the rest as needed)
11-
exclude-rules:
12-
- path: "api/*"
13-
linters:
14-
- lll
15-
- path: "pkg/*"
16-
linters:
17-
- dupl
18-
- lll
19-
- path: "test/*"
20-
linters:
21-
- dupl
22-
- lll
234
linters:
24-
disable-all: true
5+
default: none
256
enable:
7+
- copyloopvar
268
- dupl
279
- errcheck
28-
- copyloopvar
2910
- goconst
30-
- gofmt
31-
- goimports
32-
- gosimple
3311
- govet
3412
- ineffassign
3513
- misspell
3614
- nakedret
3715
- prealloc
3816
- staticcheck
39-
- typecheck
4017
- unconvert
4118
- unparam
4219
- unused
20+
exclusions:
21+
generated: lax
22+
rules:
23+
- linters:
24+
- lll
25+
path: api/*
26+
- linters:
27+
- dupl
28+
- lll
29+
path: pkg/*
30+
- linters:
31+
- dupl
32+
- lll
33+
path: test/*
34+
paths:
35+
- third_party$
36+
- builtin$
37+
- examples$
38+
formatters:
39+
enable:
40+
- gofmt
41+
- goimports
42+
exclusions:
43+
generated: lax
44+
paths:
45+
- third_party$
46+
- builtin$
47+
- examples$

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ test-deploy-with-helm: kind-image-build
139139
E2E_KIND_NODE_VERSION=$(E2E_KIND_NODE_VERSION) KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) KIND=$(KIND) KUBECTL=$(KUBECTL) USE_EXISTING_CLUSTER=$(USE_EXISTING_CLUSTER) IMAGE_TAG=$(IMG) TAG=$(GIT_TAG) ./hack/test-deploy-with-helm.sh
140140

141141
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
142-
GOLANGCI_LINT_VERSION ?= v1.64.8
142+
GOLANGCI_LINT_VERSION ?= v2.2.1
143143
golangci-lint:
144144
@[ -f $(GOLANGCI_LINT) ] || { \
145145
set -e ;\
@@ -162,6 +162,10 @@ lint: golangci-lint pythonci-lint
162162
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
163163
$(GOLANGCI_LINT) run --fix
164164

165+
.PHONY: lint-config
166+
lint-config: golangci-lint ## Verify golangci-lint linter configuration
167+
$(GOLANGCI_LINT) config verify
168+
165169
##@ Build
166170

167171
.PHONY: build
@@ -341,4 +345,4 @@ helm-package: helm
341345
.PHONY: launch-website
342346
launch-website:
343347
cd site && \
344-
hugo server
348+
hugo server

pkg/controller/inference/service_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (r *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
106106
service.Spec.WorkloadTemplate.WorkerTemplate.Spec.SchedulerName = configs.SchedulerName
107107
}
108108

109-
if err := r.Client.Update(ctx, service); err != nil {
109+
if err := r.Update(ctx, service); err != nil {
110110
return ctrl.Result{}, fmt.Errorf("failed to update service: %w", err)
111111
}
112112
}

pkg/controller_helper/backendruntime/backendruntime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func renderFlags(flags []string, modelInfo map[string]string) ([]string, error)
130130
if !exists || replacement == "" {
131131
return nil, fmt.Errorf("missing flag or the flag has format error: %s", flag)
132132
}
133-
value = strings.Replace(value, match[0], replacement, -1)
133+
value = strings.ReplaceAll(value, match[0], replacement)
134134
}
135135

136136
res = append(res, value)

pkg/controller_helper/modelsource/modelsource_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func TestInjectModelEnvVars(t *testing.T) {
210210
for _, env := range container.Env {
211211
envVarMap[*env.Name] = true
212212
if env.ValueFrom != nil && env.ValueFrom.SecretKeyRef != nil {
213-
if *env.ValueFrom.SecretKeyRef.LocalObjectReferenceApplyConfiguration.Name == tt.expectSecretRef {
213+
if *env.ValueFrom.SecretKeyRef.Name == tt.expectSecretRef {
214214
secretRefFound = true
215215
}
216216
}

pkg/util/convert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var (
7979
mismatchDetection: parseBool(os.Getenv("KUBE_PATCH_CONVERSION_DETECTOR")),
8080
comparison: conversion.EqualitiesOrDie(
8181
func(a, b time.Time) bool {
82-
return a.UTC() == b.UTC()
82+
return a.UTC().Equal(b.UTC())
8383
},
8484
),
8585
}

test/util/validation/validate_service.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,10 @@ func ValidateSkipModelLoader(model *coreapi.OpenModel, index int, template corev
292292
envStrings = append(envStrings, modelSource.HUGGING_FACE_TOKEN_KEY, modelSource.HUGGING_FACE_HUB_TOKEN)
293293
} else if model.Spec.Source.URI != nil {
294294
protocol, _, _ := pkgUtil.ParseURI(string(*model.Spec.Source.URI))
295-
if protocol == modelSource.S3 || protocol == modelSource.GCS {
295+
switch protocol {
296+
case modelSource.S3, modelSource.GCS:
296297
envStrings = append(envStrings, modelSource.AWS_ACCESS_KEY_ID, modelSource.AWS_ACCESS_KEY_SECRET)
297-
} else if protocol == modelSource.OSS {
298+
case modelSource.OSS:
298299
envStrings = append(envStrings, modelSource.OSS_ACCESS_KEY_ID, modelSource.OSS_ACCESS_KEY_SECRET)
299300
}
300301
}

0 commit comments

Comments
 (0)