Skip to content

Commit b3cb360

Browse files
authored
Merge pull request #138 from rollandf/lint
chore: update golang-ci
2 parents 046133d + 68b3156 commit b3cb360

File tree

12 files changed

+45
-31
lines changed

12 files changed

+45
-31
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Set up Go 1.x
1212
uses: actions/setup-go@v3
1313
with:
14-
go-version: '1.20.x'
14+
go-version: '1.23.x'
1515
- name: checkout
1616
uses: actions/checkout@v3
1717
- name: lint
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up Go 1.x
2626
uses: actions/setup-go@v3
2727
with:
28-
go-version: '1.20.x'
28+
go-version: '1.23.x'
2929
- name: checkout
3030
uses: actions/checkout@v3
3131
- name: install hwdata -yq
@@ -41,7 +41,7 @@ jobs:
4141
- name: Set up Go 1.x
4242
uses: actions/setup-go@v3
4343
with:
44-
go-version: '1.20.x'
44+
go-version: '1.23.x'
4545
- name: checkout
4646
uses: actions/checkout@v3
4747
- name: build

.github/workflows/static-scan.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: set up Go
99
uses: actions/setup-go@v3
1010
with:
11-
go-version: 1.20.x
11+
go-version: 1.23.x
1212
- name: checkout PR
1313
uses: actions/checkout@v2
1414
- name: run make lint
@@ -19,7 +19,7 @@ jobs:
1919
- name: set up Go
2020
uses: actions/setup-go@v3
2121
with:
22-
go-version: 1.20.x
22+
go-version: 1.23.x
2323
- name: checkout PR
2424
uses: actions/checkout@v2
2525
- name: run make hadolint

.golangci.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,21 @@ linters-settings:
4848
for-loops: false # Report preallocation suggestions on for loops, false by default
4949

5050
linters:
51-
# please, do not use `enable-all`: it's deprecated and will be removed soon.
52-
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
5351
disable-all: true
5452
enable:
5553
- bodyclose
56-
- depguard
5754
- dogsled
5855
- dupl
5956
- errcheck
60-
- exportloopref
57+
- copyloopvar
6158
- funlen
6259
- gochecknoinits
6360
- goconst
6461
- gocritic
6562
- gocognit
6663
- gofmt
6764
- goimports
68-
- gomnd
65+
- mnd
6966
- goprintffuncname
7067
- gosec
7168
- gosimple
@@ -90,9 +87,15 @@ issues:
9087
exclude-rules:
9188
- path: _test\.go
9289
linters:
93-
- gomnd
9490
- goconst
9591
- dupl
92+
- revive
93+
- stylecheck
94+
text: "should not use dot imports"
95+
- path: _test\.go
96+
linters:
97+
- mnd
98+
- goconst
9699
- text: "Magic number: 1"
97100
linters:
98-
- gomnd
101+
- mnd

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ GOLANGCI_LINT = $(BINDIR)/golangci-lint
3838
# golangci-lint version should be updated periodically
3939
# we keep it fixed to avoid it from unexpectedly failing on the project
4040
# in case of a version bump
41-
GOLANGCI_LINT_VER = v1.51.2
41+
GOLANGCI_LINT_VER = v1.62.2
4242
TIMEOUT = 20
4343
Q = $(if $(filter 1,$V),,@)
4444

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/Mellanox/k8s-rdma-shared-dev-plugin
22

3-
go 1.20
3+
go 1.23
44

55
require (
66
github.com/Mellanox/rdmamap v1.1.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg
3434
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
3535
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
3636
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
37+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
3738
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
3839
github.com/googleapis/go-genproto v0.0.0-20200117163144-32f20d992d24 h1:iqmAazjqJalhqqPoTsjnqI2wPlgVbQJ6JNdHsbhA6FA=
3940
github.com/googleapis/go-genproto v0.0.0-20200117163144-32f20d992d24/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
@@ -78,6 +79,7 @@ github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626 h1:
7879
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626/go.mod h1:BRHJJd0E+cx42OybVYSgUvZmU0B8P9gZuRXlZUP7TKI=
7980
github.com/opencontainers/selinux v1.9.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
8081
github.com/opencontainers/selinux v1.10.0 h1:rAiKF8hTcgLI3w0DHm6i0ylVVcOrlgR1kK99DRLDhyU=
82+
github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
8183
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
8284
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
8385
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

pkg/resources/pci_net_device.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func NewPciNetDevice(dev *ghw.PCIDevice, rds types.RdmaDeviceSpec,
4545
}
4646

4747
linkType := ""
48-
if len(ifName) > 0 {
48+
if ifName != "" {
4949
link, err := nLink.LinkByName(ifName)
5050
if err != nil {
5151
return nil, err

pkg/resources/resources_manager.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,27 +353,27 @@ func (rm *resourceManager) GetFilteredDevices(devices []types.PciNetDevice,
353353
filteredDevice := devices
354354

355355
// filter by Vendors list
356-
if selector.Vendors != nil && len(selector.Vendors) > 0 {
356+
if len(selector.Vendors) > 0 {
357357
filteredDevice = NewVendorSelector(selector.Vendors).Filter(filteredDevice)
358358
}
359359

360360
// filter by DeviceIDs list
361-
if selector.DeviceIDs != nil && len(selector.DeviceIDs) > 0 {
361+
if len(selector.DeviceIDs) > 0 {
362362
filteredDevice = NewDeviceSelector(selector.DeviceIDs).Filter(filteredDevice)
363363
}
364364

365365
// filter by Driver list
366-
if selector.Drivers != nil && len(selector.Drivers) > 0 {
366+
if len(selector.Drivers) > 0 {
367367
filteredDevice = NewDriverSelector(selector.Drivers).Filter(filteredDevice)
368368
}
369369

370370
// filter by IfNames list
371-
if selector.IfNames != nil && len(selector.IfNames) > 0 {
371+
if len(selector.IfNames) > 0 {
372372
filteredDevice = NewIfNameSelector(selector.IfNames).Filter(filteredDevice)
373373
}
374374

375375
// filter by LinkType list
376-
if selector.LinkTypes != nil && len(selector.LinkTypes) > 0 {
376+
if len(selector.LinkTypes) > 0 {
377377
filteredDevice = NewLinkTypeSelector(selector.LinkTypes).Filter(filteredDevice)
378378
}
379379

pkg/resources/resources_manager_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ var _ = Describe("ResourcesManger", func() {
8181
Expect(rm.watchMode).To(Equal(false))
8282
})
8383
})
84+
//nolint:dupl
8485
Context("ReadConfig", func() {
8586
It("Read valid config file with non default periodic update", func() {
8687
configData := `{"configList": [{
@@ -505,6 +506,7 @@ var _ = Describe("ResourcesManger", func() {
505506
fakeResourceServer.AssertExpectations(testCallsAssertionReporter)
506507
})
507508
})
509+
//nolint:dupl
508510
Context("StopAllServers", func() {
509511
It("stop valid server", func() {
510512
fakeResourceServer := mocks.ResourceServer{}
@@ -532,6 +534,7 @@ var _ = Describe("ResourcesManger", func() {
532534
fakeResourceServer.AssertExpectations(testCallsAssertionReporter)
533535
})
534536
})
537+
//nolint:dupl
535538
Context("RestartAllServers", func() {
536539
It("restart valid server", func() {
537540
fakeResourceServer := mocks.ResourceServer{}

pkg/resources/server.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func (rs *resourceServer) register() error {
295295
}
296296

297297
// ListAndWatch lists devices and update that list according to the health status
298-
func (rs *resourceServer) ListAndWatch(e *pluginapi.Empty, s pluginapi.DevicePlugin_ListAndWatchServer) error {
298+
func (rs *resourceServer) ListAndWatch(_ *pluginapi.Empty, s pluginapi.DevicePlugin_ListAndWatchServer) error {
299299
log.Printf("ListAndWatch called by kubelet for: %s", rs.resourceName)
300300
resp := new(pluginapi.ListAndWatchResponse)
301301

@@ -366,7 +366,7 @@ func (rs *resourceServer) sendDevices(resp *pluginapi.ListAndWatchResponse,
366366
}
367367

368368
// Allocate which return list of devices.
369-
func (rs *resourceServer) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (
369+
func (rs *resourceServer) Allocate(_ context.Context, r *pluginapi.AllocateRequest) (
370370
*pluginapi.AllocateResponse, error) {
371371
log.Println("allocate request:", r)
372372

@@ -420,7 +420,7 @@ func (rs *resourceServer) cleanup() error {
420420
}
421421

422422
// GetInfo get info of plugin
423-
func (rs *resourceServer) GetInfo(ctx context.Context, rqt *registerapi.InfoRequest) (*registerapi.PluginInfo, error) {
423+
func (rs *resourceServer) GetInfo(_ context.Context, _ *registerapi.InfoRequest) (*registerapi.PluginInfo, error) {
424424
pluginInfoResponse := &registerapi.PluginInfo{
425425
Type: registerapi.DevicePlugin,
426426
Name: rs.resourceName,
@@ -431,7 +431,7 @@ func (rs *resourceServer) GetInfo(ctx context.Context, rqt *registerapi.InfoRequ
431431
}
432432

433433
// NotifyRegistrationStatus notify for registration status
434-
func (rs *resourceServer) NotifyRegistrationStatus(ctx context.Context, regstat *registerapi.RegistrationStatus) (
434+
func (rs *resourceServer) NotifyRegistrationStatus(_ context.Context, regstat *registerapi.RegistrationStatus) (
435435
*registerapi.RegistrationStatusResponse, error) {
436436
if regstat.PluginRegistered {
437437
log.Printf("%s gets registered successfully at Kubelet \n", rs.socketName)
@@ -490,7 +490,7 @@ func (rs *resourceServer) UpdateDevices(devices []types.PciNetDevice) {
490490
}
491491

492492
func (rs *resourceServer) GetPreferredAllocation(
493-
ctx context.Context, req *pluginapi.PreferredAllocationRequest) (*pluginapi.PreferredAllocationResponse, error) {
493+
_ context.Context, _ *pluginapi.PreferredAllocationRequest) (*pluginapi.PreferredAllocationResponse, error) {
494494
return nil, nil
495495
}
496496

0 commit comments

Comments
 (0)