Skip to content

Commit a3c0edf

Browse files
authored
github-actions: update lint action (#2379)
* github-actions: update lint action seems like something broke with newer golang versions. Update golangci-lint version and set `only-new-issues` to `true`. Signed-off-by: Maksim An <[email protected]> * lint: fix lint errors Signed-off-by: Maksim An <[email protected]> --------- Signed-off-by: Maksim An <[email protected]>
1 parent b9fc67d commit a3c0edf

File tree

11 files changed

+32
-32
lines changed

11 files changed

+32
-32
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Run golangci-lint
3737
uses: golangci/golangci-lint-action@v6
3838
with:
39-
version: v1.54
39+
version: v1.64
4040
args: >-
4141
--verbose
4242
--max-issues-per-linter=0

.golangci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ run:
55
- admin
66
- functional
77
- integration
8-
skip-dirs:
9-
# paths are relative to module root
10-
- cri-containerd/test-images
118

129
linters:
1310
enable:
@@ -34,13 +31,15 @@ linters-settings:
3431
# struct order is often for Win32 compat
3532
# also, ignore pointer bytes/GC issues for now until performance becomes an issue
3633
- fieldalignment
37-
check-shadowing: true
3834

3935
stylecheck:
4036
# https://staticcheck.io/docs/checks
4137
checks: ["all"]
4238

4339
issues:
40+
exclude-dirs:
41+
# paths are relative to module root
42+
- cri-containerd/test-images
4443
exclude-rules:
4544
# err is very often shadowed in nested scopes
4645
- linters:

hcn/hcnerrors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func checkForErrors(methodName string, hr error, resultBuffer *uint16) error {
3939

4040
if errorFound {
4141
returnError := new(hr, methodName, result)
42-
logrus.Debugf(returnError.Error()) // HCN errors logged for debugging.
42+
logrus.Debug(returnError.Error()) // HCN errors logged for debugging.
4343
return returnError
4444
}
4545

internal/exec/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (e *Exec) Start() error {
175175
pSec := &windows.SecurityAttributes{Length: uint32(unsafe.Sizeof(zeroSec)), InheritHandle: 1}
176176
tSec := &windows.SecurityAttributes{Length: uint32(unsafe.Sizeof(zeroSec)), InheritHandle: 1}
177177

178-
siEx.ProcThreadAttributeList = attrList.List() //nolint:govet // unusedwrite: ProcThreadAttributeList will be read in syscall
178+
siEx.ProcThreadAttributeList = attrList.List()
179179
siEx.Cb = uint32(unsafe.Sizeof(*siEx))
180180
if e.execConfig.token != 0 {
181181
err = windows.CreateProcessAsUser(

internal/guest/gcserr/errors.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ func BaseStackTrace(e error) errors.StackTrace {
7373
cause := e
7474
var tracer StackTracer
7575
for cause != nil {
76-
serr, ok := cause.(StackTracer) //nolint:errorlint
76+
serr, ok := cause.(StackTracer)
7777
if ok {
7878
tracer = serr
7979
}
80-
cerr, ok := cause.(causer) //nolint:errorlint
80+
cerr, ok := cause.(causer)
8181
if !ok {
8282
break
8383
}
@@ -132,7 +132,7 @@ func (e *wrappingHresultError) StackTrace() errors.StackTrace {
132132
type stackTracer interface {
133133
StackTrace() errors.StackTrace
134134
}
135-
serr, ok := e.Cause().(stackTracer) //nolint:errorlint
135+
serr, ok := e.Cause().(stackTracer)
136136
if !ok {
137137
return nil
138138
}
@@ -167,11 +167,11 @@ func GetHresult(e error) (Hresult, error) {
167167
}
168168
cause := e
169169
for cause != nil {
170-
herr, ok := cause.(hresulter) //nolint:errorlint
170+
herr, ok := cause.(hresulter)
171171
if ok {
172172
return herr.Hresult(), nil
173173
}
174-
cerr, ok := cause.(causer) //nolint:errorlint
174+
cerr, ok := cause.(causer)
175175
if !ok {
176176
break
177177
}

internal/guest/network/netns_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package network
66
import (
77
"bytes"
88
"context"
9+
"errors"
910
"fmt"
1011
"net"
1112
"strings"
@@ -72,7 +73,7 @@ func unreachableNetlinkRouteAdd(count *int, link netlink.Link, expected []*testR
7273
if err := f(route); err != nil {
7374
return err
7475
}
75-
return fmt.Errorf(unreachableErrStr)
76+
return errors.New(unreachableErrStr)
7677
}
7778
}
7879

internal/hcs/process.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ func (process *Process) SystemID() string {
6363
}
6464

6565
func (process *Process) processSignalResult(ctx context.Context, err error) (bool, error) {
66-
switch err { //nolint:errorlint
67-
case nil:
66+
if err == nil {
6867
return true, nil
69-
case ErrVmcomputeOperationInvalidState, ErrComputeSystemDoesNotExist, ErrElementNotFound:
68+
}
69+
if errors.Is(err, ErrVmcomputeOperationInvalidState) || errors.Is(err, ErrComputeSystemDoesNotExist) || errors.Is(err, ErrElementNotFound) {
7070
if !process.stopped() {
7171
// The process should be gone, but we have not received the notification.
7272
// After a second, force unblock the process wait to work around a possible
@@ -82,9 +82,8 @@ func (process *Process) processSignalResult(ctx context.Context, err error) (boo
8282
}()
8383
}
8484
return false, nil
85-
default:
86-
return false, err
8785
}
86+
return false, nil
8887
}
8988

9089
// Signal signals the process with `options`.

internal/hcs/system.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,10 @@ func (computeSystem *System) Shutdown(ctx context.Context) error {
238238

239239
resultJSON, err := vmcompute.HcsShutdownComputeSystem(ctx, computeSystem.handle, "")
240240
events := processHcsResult(ctx, resultJSON)
241-
switch err { //nolint:errorlint
242-
case nil, ErrVmcomputeAlreadyStopped, ErrComputeSystemDoesNotExist, ErrVmcomputeOperationPending:
243-
default:
241+
if err != nil &&
242+
!errors.Is(err, ErrVmcomputeAlreadyStopped) &&
243+
!errors.Is(err, ErrComputeSystemDoesNotExist) &&
244+
!errors.Is(err, ErrVmcomputeOperationPending) {
244245
return makeSystemError(computeSystem, operation, err, events)
245246
}
246247
return nil
@@ -259,9 +260,10 @@ func (computeSystem *System) Terminate(ctx context.Context) error {
259260

260261
resultJSON, err := vmcompute.HcsTerminateComputeSystem(ctx, computeSystem.handle, "")
261262
events := processHcsResult(ctx, resultJSON)
262-
switch err { //nolint:errorlint
263-
case nil, ErrVmcomputeAlreadyStopped, ErrComputeSystemDoesNotExist, ErrVmcomputeOperationPending:
264-
default:
263+
if err != nil &&
264+
!errors.Is(err, ErrVmcomputeAlreadyStopped) &&
265+
!errors.Is(err, ErrComputeSystemDoesNotExist) &&
266+
!errors.Is(err, ErrVmcomputeOperationPending) {
265267
return makeSystemError(computeSystem, operation, err, events)
266268
}
267269
return nil
@@ -279,14 +281,13 @@ func (computeSystem *System) waitBackground() {
279281
span.AddAttributes(trace.StringAttribute("cid", computeSystem.id))
280282

281283
err := waitForNotification(ctx, computeSystem.callbackNumber, hcsNotificationSystemExited, nil)
282-
switch err { //nolint:errorlint
283-
case nil:
284+
if err == nil {
284285
log.G(ctx).Debug("system exited")
285-
case ErrVmcomputeUnexpectedExit:
286+
} else if errors.Is(err, ErrVmcomputeUnexpectedExit) {
286287
log.G(ctx).Debug("unexpected system exit")
287288
computeSystem.exitError = makeSystemError(computeSystem, operation, err, nil)
288289
err = nil
289-
default:
290+
} else {
290291
err = makeSystemError(computeSystem, operation, err, nil)
291292
}
292293
computeSystem.closedWaitOnce.Do(func() {

internal/hns/hnsaccelnet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ func (nnvManagementMacList *HNSNnvManagementMacList) Set() (*HNSNnvManagementMac
4747
func GetNnvManagementMacAddressList() (*HNSNnvManagementMacList, error) {
4848
operation := "Get"
4949
title := "hcsshim::nnvManagementMacList::" + operation
50-
logrus.Debugf(title)
50+
logrus.Debug(title)
5151
return HNSNnvManagementMacRequest("GET", "", "")
5252
}
5353

5454
// Delete ManagementMacAddressList by sending "DELETE" NnvManagementMacRequest to HNS.
5555
func DeleteNnvManagementMacAddressList() (*HNSNnvManagementMacList, error) {
5656
operation := "Delete"
5757
title := "hcsshim::nnvManagementMacList::" + operation
58-
logrus.Debugf(title)
58+
logrus.Debug(title)
5959
return HNSNnvManagementMacRequest("DELETE", "", "")
6060
}

internal/regopolicyinterpreter/regopolicyinterpreter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ func (r *RegoPolicyInterpreter) query(rule string, input map[string]interface{})
543543
resultSet, err := query.Eval(ctx)
544544
output := buf.String()
545545

546-
r.logInfo(output)
546+
r.logInfo("%s", output)
547547

548548
return resultSet, err
549549
}

internal/vmcompute/vmcompute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func execute(ctx gcontext.Context, timeout time.Duration, f func() error) error
104104
}()
105105
select {
106106
case <-ctx.Done():
107-
if ctx.Err() == gcontext.DeadlineExceeded { //nolint:errorlint
107+
if ctx.Err() == gcontext.DeadlineExceeded {
108108
log.G(ctx).WithField(logfields.Timeout, trueTimeout).
109109
Warning("Syscall did not complete within operation timeout. This may indicate a platform issue. " +
110110
"If it appears to be making no forward progress, obtain the stacks and see if there is a syscall " +

0 commit comments

Comments
 (0)