Skip to content

Commit 61ad8a8

Browse files
Merge branch 'k8snetworkplumbingwg:master' into master
2 parents 325f798 + 168a5de commit 61ad8a8

38 files changed

+248
-255
lines changed

.github/dependabot.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
11
version: 2
22
updates:
3+
# Docker images
34
- package-ecosystem: docker
45
directory: /images
56
schedule:
67
interval: weekly
8+
day: monday
9+
commit-message:
10+
prefix: "chore:"
11+
12+
# GitHub Actions
13+
- package-ecosystem: github-actions
14+
directory: /
15+
schedule:
16+
interval: weekly
17+
day: monday
18+
commit-message:
19+
prefix: "chore:"
20+
21+
# Go modules
722
- package-ecosystem: gomod
823
directory: /
924
schedule:
1025
interval: weekly
26+
day: monday
27+
commit-message:
28+
prefix: "chore:"
1129
groups:
30+
kubernetes-dependencies:
31+
patterns:
32+
- k8s.io/*
1233
gomod-dependencies:
1334
patterns:
14-
- '*'
35+
- '*'
36+
exclude-patterns:
37+
- k8s.io/*

.github/workflows/build-test-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
name: build
66
runs-on: ubuntu-24.04
77
steps:
8-
- name: Set up Go matrix
8+
- name: Set up Go
99
uses: actions/setup-go@v3
1010
with:
1111
go-version: 1.23.x

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ jobs:
2727
uses: actions/checkout@v3
2828

2929
- name: Initialize CodeQL
30-
uses: github/codeql-action/init@v2
30+
uses: github/codeql-action/init@v3
3131
with:
3232
languages: ${{ matrix.language }}
3333
queries: +security-and-quality
3434

3535
- name: Autobuild
36-
uses: github/codeql-action/autobuild@v2
36+
uses: github/codeql-action/autobuild@v3
3737

3838
- name: Perform CodeQL Analysis
39-
uses: github/codeql-action/analyze@v2
39+
uses: github/codeql-action/analyze@v3
4040
with:
4141
category: "/language:${{ matrix.language }}"

.golangci.yml

Lines changed: 72 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,93 @@
1-
# Tested with golangci-lint ver. 1.37
1+
version: "2"
22
run:
3-
timeout: 3m
4-
5-
linters-settings:
6-
depguard:
7-
list-type: blacklist
8-
packages:
9-
# logging is allowed only by logutils.Log, logrus
10-
# is allowed to use only in logutils package
11-
- github.com/sirupsen/logrus
12-
packages-with-error-message:
13-
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
14-
dupl:
15-
threshold: 100
16-
funlen:
17-
lines: 100
18-
statements: 50
19-
goconst:
20-
min-len: 2
21-
min-occurrences: 2
22-
gocritic:
23-
enabled-tags:
24-
- diagnostic
25-
- experimental
26-
- opinionated
27-
- performance
28-
- style
29-
disabled-checks:
30-
- dupImport # https://github.com/go-critic/go-critic/issues/845
31-
- ifElseChain
32-
- octalLiteral
33-
- whyNoLint
34-
- wrapperFunc
35-
- unnamedResult
36-
settings:
37-
hugeParam:
38-
sizeThreshold: 512
39-
rangeValCopy:
40-
sizeThreshold: 512
41-
gocyclo:
42-
min-complexity: 15
43-
goimports:
44-
local-prefixes: github.com/k8snetworkplumbingwg/sriov-network-device-plugin
45-
gomnd:
46-
settings:
47-
mnd:
48-
# don't include the "operation" and "assign"
49-
checks: argument,case,condition,return
50-
lll:
51-
line-length: 140
52-
misspell:
53-
locale: US
54-
prealloc:
55-
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
56-
# True by default.
57-
simple: true
58-
range-loops: true # Report preallocation suggestions on range loops, true by default
59-
for-loops: false # Report preallocation suggestions on for loops, false by default
60-
3+
timeout: 5m
4+
allow-parallel-runners: true
615
linters:
62-
# please, do not use `enable-all`: it's deprecated and will be removed soon.
63-
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
64-
disable-all: true
6+
default: none
657
enable:
66-
- bodyclose
67-
# depguard has a bug in go 1.21 that will be fixed in future versions: https://github.com/kedacore/keda/pull/5285
68-
#- depguard
69-
- dogsled
8+
- copyloopvar
709
- dupl
7110
- errcheck
72-
- copyloopvar
73-
- exhaustive
7411
- funlen
75-
#- gochecknoinits
12+
- ginkgolinter
7613
- goconst
77-
- gocritic
7814
- gocyclo
79-
- gofmt
80-
- goimports
81-
- mnd
82-
- goprintffuncname
15+
- govet
16+
- gocritic
8317
- gosec
84-
- gosimple
85-
#- govet
18+
- goprintffuncname
19+
- importas
8620
- ineffassign
8721
- lll
8822
- misspell
23+
- mnd
8924
- nakedret
9025
- prealloc
91-
- rowserrcheck
92-
#- scopelint
9326
- staticcheck
94-
- stylecheck
95-
- typecheck
9627
- unconvert
9728
- unparam
9829
- unused
9930
- whitespace
31+
settings:
32+
dupl:
33+
threshold: 100
34+
funlen:
35+
statements: 50
36+
lines: 100
37+
lll:
38+
line-length: 140
39+
mnd:
40+
# don't include the "operation" and "assign"
41+
checks: ["argument", "case", "condition", "return"]
42+
goconst:
43+
min-len: 2
44+
min-occurrences: 2
45+
gocyclo:
46+
min-complexity: 15
47+
gosec:
48+
excludes:
49+
- G304
50+
ginkgolinter:
51+
forbid-focus-container: true
52+
misspell:
53+
locale: US
54+
staticcheck:
55+
checks:
56+
- all
57+
- -ST1000
58+
- -ST1003
59+
- -QF1008
60+
dot-import-whitelist:
61+
- github.com/onsi/ginkgo/v2
62+
- github.com/onsi/gomega
63+
exclusions:
64+
generated: lax
65+
paths:
66+
- .github/*
67+
- deployments/*
68+
- docs/*
69+
- pkg/utils/testing.go
70+
- pkg/resources/testing.go
71+
rules:
72+
- linters:
73+
- dupl
74+
- goconst
75+
- lll
76+
- gosec
77+
path: _test\.go
10078

10179
issues:
102-
# Excluding configuration per-path, per-linter, per-text and per-source
103-
exclude-rules:
104-
- path: _test\.go
105-
linters:
106-
- gomnd
107-
- gosec
108-
- dupl
109-
- lll
110-
- stylecheck
111-
- goconst
112-
exclude-dirs:
113-
- .github/
114-
- deployments/
115-
- docs/
116-
- images/
80+
max-issues-per-linter: 0
81+
max-same-issues: 0
82+
formatters:
83+
enable:
84+
- gci
85+
- gofmt
86+
- goimports
87+
settings:
88+
gci:
89+
sections:
90+
- standard
91+
- default
92+
- prefix(github.com/k8snetworkplumbingwg/sriov-network-device-plugin)
93+
custom-order: true

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ build: | $(BUILDDIR) ; $(info Building $(BINARY_NAME)...) @ ## Build SR-IOV Netw
5959
$(info Done!)
6060

6161
GOLANGCI_LINT = $(BINDIR)/golangci-lint
62-
GOLANGCI_LINT_VERSION ?= v1.63.4
62+
GOLANGCI_LINT_VERSION ?= v2.3.1
6363
$(GOLANGCI_LINT): | $(BINDIR) ; $(info installing golangci-lint...)
6464
$Q[ -f $(GOLANGCI_LINT) ] || { \
6565
set -e ;\
66-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
66+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
6767
}
6868

6969
MOCKERY = $(BINDIR)/mockery
@@ -87,6 +87,10 @@ test-coverage: | $(COVERAGE_DIR) ; $(info Running coverage tests...) @ ## Run c
8787
lint: $(GOLANGCI_LINT) ; $(info Running golangci-lint linter...) @ ## Run golangci-lint linter
8888
$Q $(GOLANGCI_LINT) run
8989

90+
.PHONY: lint-fix
91+
lint-fix: $(GOLANGCI_LINT) ; $(info Running golangci-lint linter with --fix...) @ ## Run golangci-lint linter with --fix to fix lint issues
92+
$Q $(GOLANGCI_LINT) run --fix
93+
9094
.PHONY: deps-update
9195
deps-update: ; $(info Updating dependencies...) @ ## Update dependencies
9296
$Q go mod tidy

cmd/sriovdp/manager_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@ import (
1919
"os"
2020
"testing"
2121

22-
CDImocks "github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/cdi/mocks"
22+
. "github.com/onsi/ginkgo"
23+
. "github.com/onsi/ginkgo/extensions/table"
24+
. "github.com/onsi/gomega"
25+
"github.com/stretchr/testify/mock"
2326

27+
CDImocks "github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/cdi/mocks"
2428
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/factory"
2529
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/netdevice"
2630
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/types"
2731
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/types/mocks"
2832
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/utils"
29-
30-
. "github.com/onsi/ginkgo"
31-
. "github.com/onsi/ginkgo/extensions/table"
32-
. "github.com/onsi/gomega"
33-
"github.com/stretchr/testify/mock"
3433
)
3534

3635
func TestSriovdp(t *testing.T) {
@@ -126,7 +125,7 @@ var _ = Describe("Resource manager", func() {
126125
Expect(err).NotTo(HaveOccurred())
127126
})
128127
It("should load resources list", func() {
129-
Expect(len(rm.configList)).To(Equal(2))
128+
Expect(rm.configList).To(HaveLen(2))
130129
})
131130
})
132131
Context("when the multi-selector config reading is successful", func() {
@@ -235,7 +234,7 @@ var _ = Describe("Resource manager", func() {
235234
})
236235
It("should return false", func() {
237236
defer fs.Use()()
238-
Expect(rm.validConfigs()).To(Equal(false))
237+
Expect(rm.validConfigs()).To(BeFalse())
239238
})
240239
})
241240
Context("when resource name is duplicated", func() {
@@ -269,7 +268,7 @@ var _ = Describe("Resource manager", func() {
269268
})
270269
It("should return false", func() {
271270
defer fs.Use()()
272-
Expect(rm.validConfigs()).To(Equal(false))
271+
Expect(rm.validConfigs()).To(BeFalse())
273272
})
274273
})
275274
Context("when both IsRdma and VdpaType are configured", func() {
@@ -298,7 +297,7 @@ var _ = Describe("Resource manager", func() {
298297
})
299298
It("should return false", func() {
300299
defer fs.Use()()
301-
Expect(rm.validConfigs()).To(Equal(false))
300+
Expect(rm.validConfigs()).To(BeFalse())
302301
})
303302
})
304303
Context("when isRdma and vdpaType are configured in separate selectors", func() {
@@ -331,7 +330,7 @@ var _ = Describe("Resource manager", func() {
331330
})
332331
It("should return true", func() {
333332
defer fs.Use()()
334-
Expect(rm.validConfigs()).To(Equal(true))
333+
Expect(rm.validConfigs()).To(BeTrue())
335334
})
336335
})
337336
Context("when isRdma and vdpaType are configured in a second selector", func() {
@@ -365,7 +364,7 @@ var _ = Describe("Resource manager", func() {
365364
})
366365
It("should return false", func() {
367366
defer fs.Use()()
368-
Expect(rm.validConfigs()).To(Equal(false))
367+
Expect(rm.validConfigs()).To(BeFalse())
369368
})
370369
})
371370
Describe("managing resources servers", func() {
@@ -386,7 +385,7 @@ var _ = Describe("Resource manager", func() {
386385
Expect(rm.initServers()).NotTo(HaveOccurred())
387386
})
388387
It("should finish with empty list of servers", func() {
389-
Expect(len(rm.resourceServers)).To(Equal(0))
388+
Expect(rm.resourceServers).To(BeEmpty())
390389
})
391390
})
392391
Context("when server is properly initialized", func() {

pkg/accelerator/accelDeviceProvider_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515
package accelerator_test
1616

1717
import (
18+
"github.com/jaypipes/ghw"
19+
"github.com/jaypipes/pcidb"
20+
. "github.com/onsi/ginkgo"
21+
. "github.com/onsi/gomega"
22+
1823
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/accelerator"
1924
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/factory"
2025
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/types"
2126
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/types/mocks"
2227
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/utils"
23-
24-
"github.com/jaypipes/ghw"
25-
"github.com/jaypipes/pcidb"
26-
27-
. "github.com/onsi/ginkgo"
28-
. "github.com/onsi/gomega"
2928
)
3029

3130
var _ = Describe("AcceleratorProvider", func() {

0 commit comments

Comments
 (0)