Skip to content

Commit 50a7e2f

Browse files
authored
Merge pull request #1009 from NVIDIA/dependabot/github_actions/main/golangci/golangci-lint-action-7
Bump golangci/golangci-lint-action from 6 to 7
2 parents c1cf52d + 0fb3eec commit 50a7e2f

File tree

13 files changed

+86
-58
lines changed

13 files changed

+86
-58
lines changed

.github/workflows/golang.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
with:
4141
go-version: ${{ env.GOLANG_VERSION }}
4242
- name: Lint
43-
uses: golangci/golangci-lint-action@v6
43+
uses: golangci/golangci-lint-action@v7
4444
with:
4545
version: latest
4646
args: -v --timeout 5m

.golangci.yml

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,72 @@
1-
run:
2-
timeout: 10m
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
315

16+
version: "2"
417
linters:
518
enable:
619
- contextcheck
720
- gocritic
8-
- gofmt
9-
- goimports
1021
- gosec
11-
- gosimple
12-
- govet
13-
- ineffassign
1422
- misspell
15-
- staticcheck
1623
- unconvert
17-
18-
linters-settings:
19-
goimports:
20-
local-prefixes: github.com/NVIDIA/nvidia-container-toolkit
21-
22-
issues:
23-
exclude:
24-
# The legacy hook relies on spec.Hooks.Prestart, which is deprecated as of the v1.2.0 OCI runtime spec.
25-
- "SA1019:(.+).Prestart is deprecated(.+)"
26-
# TODO: We should address each of the following integer overflows.
27-
- "G115: integer overflow conversion(.+)"
28-
exclude-rules:
29-
# Exclude the gocritic dupSubExpr issue for cgo files.
30-
- path: internal/dxcore/dxcore.go
31-
linters:
32-
- gocritic
33-
text: dupSubExpr
34-
# Exclude the checks for usage of returns to config.Delete(Path) in the crio and containerd config packages.
35-
- path: pkg/config/engine/
36-
linters:
37-
- errcheck
38-
text: config.Delete
39-
# RENDERD refers to the Render Device and not the past tense of render.
40-
- path: .*.go
41-
linters:
42-
- misspell
43-
text: "`RENDERD` is a misspelling of `RENDERED`"
24+
exclusions:
25+
generated: lax
26+
presets:
27+
- comments
28+
- common-false-positives
29+
- legacy
30+
- std-error-handling
31+
rules:
32+
# Exclude the gocritic dupSubExpr issue for cgo files.
33+
- linters:
34+
- gocritic
35+
path: internal/dxcore/dxcore.go
36+
text: dupSubExpr
37+
# Exclude the checks for usage of returns to config.Delete(Path) in the
38+
# crio and containerd config packages.
39+
- linters:
40+
- errcheck
41+
path: pkg/config/engine/
42+
text: config.Delete
43+
# RENDERD refers to the Render Device and not the past tense of render.
44+
- linters:
45+
- misspell
46+
path: .*.go
47+
text: '`RENDERD` is a misspelling of `RENDERED`'
48+
# The legacy hook relies on spec.Hooks.Prestart, which is deprecated as of
49+
# the v1.2.0 OCI runtime spec.
50+
- path: (.+)\.go$
51+
text: SA1019:(.+).Prestart is deprecated(.+)
52+
# TODO: We should address each of the following integer overflows.
53+
- path: (.+)\.go$
54+
text: 'G115: integer overflow conversion(.+)'
55+
paths:
56+
- third_party$
57+
- builtin$
58+
- examples$
59+
formatters:
60+
enable:
61+
- gofmt
62+
- goimports
63+
settings:
64+
goimports:
65+
local-prefixes:
66+
- github.com/NVIDIA/nvidia-container-toolkit
67+
exclusions:
68+
generated: lax
69+
paths:
70+
- third_party$
71+
- builtin$
72+
- examples$

cmd/nvidia-cdi-hook/cudacompat/cudacompat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (m command) createLdsoconfdFile(in containerRoot, pattern string, dirs ...s
199199
if added[dir] {
200200
continue
201201
}
202-
_, err = configFile.WriteString(fmt.Sprintf("%s\n", dir))
202+
_, err = fmt.Fprintf(configFile, "%s\n", dir)
203203
if err != nil {
204204
return fmt.Errorf("failed to update config file: %w", err)
205205
}

cmd/nvidia-cdi-hook/update-ldcache/update-ldcache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (m command) createLdsoconfdFile(in containerRoot, pattern string, dirs ...s
184184
if added[dir] {
185185
continue
186186
}
187-
_, err = configFile.WriteString(fmt.Sprintf("%s\n", dir))
187+
_, err = fmt.Fprintf(configFile, "%s\n", dir)
188188
if err != nil {
189189
return fmt.Errorf("failed to update config file: %w", err)
190190
}

cmd/nvidia-container-runtime-hook/hook_config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func TestGetHookConfig(t *testing.T) {
8585
configflag = &filename
8686

8787
for _, line := range tc.lines {
88-
_, err := configFile.WriteString(fmt.Sprintf("%s\n", line))
88+
_, err := fmt.Fprintf(configFile, "%s\n", line)
8989
require.NoError(t, err)
9090
}
9191
}

cmd/nvidia-ctk-installer/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (a *app) initialize(pidFile string) error {
240240
return fmt.Errorf("unable to get flock on pidfile: %v", err)
241241
}
242242

243-
_, err = f.WriteString(fmt.Sprintf("%v\n", os.Getpid()))
243+
_, err = fmt.Fprintf(f, "%v\n", os.Getpid())
244244
if err != nil {
245245
return fmt.Errorf("unable to write PID to pidfile: %v", err)
246246
}

internal/discover/symlinks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func WithDriverDotSoSymlinks(mounts Discover, version string, nvidiaCDIHookPath
4242

4343
// Hooks returns a hook to create the additional symlinks based on the mounts.
4444
func (d *additionalSymlinks) Hooks() ([]Hook, error) {
45-
mounts, err := d.Discover.Mounts()
45+
mounts, err := d.Mounts()
4646
if err != nil {
4747
return nil, fmt.Errorf("failed to get library mounts: %v", err)
4848
}

internal/oci/spec_memory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ func (s *memorySpec) Modify(m SpecModifier) error {
6161
// Otherwise the returned value will be empty and the boolean will
6262
// be false.
6363
func (s memorySpec) LookupEnv(key string) (string, bool) {
64-
if s.Spec == nil || s.Spec.Process == nil {
64+
if s.Spec == nil || s.Process == nil {
6565
return "", false
6666
}
6767

68-
for _, env := range s.Spec.Process.Env {
68+
for _, env := range s.Process.Env {
6969
if !strings.HasPrefix(env, key) {
7070
continue
7171
}

internal/oci/spec_memory_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func TestModify(t *testing.T) {
160160
require.EqualValues(t, &specs.Spec{}, spec.Spec, "%d: %v", i, tc)
161161
default:
162162
require.NoError(t, err, "%d: %v", i, tc)
163-
require.Equal(t, "updated", spec.Spec.Version, "%d: %v", i, tc)
163+
require.Equal(t, "updated", spec.Version, "%d: %v", i, tc)
164164
}
165165
}
166166
}

internal/platform-support/dgpu/nvsandboxutils.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ func (d *nvsandboxutilsDGPU) Devices() ([]discover.Device, error) {
7171

7272
var devices []discover.Device
7373
for _, info := range gpuFileInfos {
74-
switch {
75-
case info.SubType == nvsandboxutils.NV_DEV_DRI_CARD, info.SubType == nvsandboxutils.NV_DEV_DRI_RENDERD:
74+
switch info.SubType {
75+
case nvsandboxutils.NV_DEV_DRI_CARD, nvsandboxutils.NV_DEV_DRI_RENDERD:
7676
if d.isMig {
7777
continue
7878
}
7979
fallthrough
80-
case info.SubType == nvsandboxutils.NV_DEV_NVIDIA, info.SubType == nvsandboxutils.NV_DEV_NVIDIA_CAPS_NVIDIA_CAP:
80+
case nvsandboxutils.NV_DEV_NVIDIA, nvsandboxutils.NV_DEV_NVIDIA_CAPS_NVIDIA_CAP:
8181
containerPath := info.Path
8282
if d.devRoot != "/" {
8383
containerPath = strings.TrimPrefix(containerPath, d.devRoot)
@@ -89,7 +89,7 @@ func (d *nvsandboxutilsDGPU) Devices() ([]discover.Device, error) {
8989
Path: containerPath,
9090
}
9191
devices = append(devices, device)
92-
case info.SubType == nvsandboxutils.NV_DEV_DRI_CARD_SYMLINK, info.SubType == nvsandboxutils.NV_DEV_DRI_RENDERD_SYMLINK:
92+
case nvsandboxutils.NV_DEV_DRI_CARD_SYMLINK, nvsandboxutils.NV_DEV_DRI_RENDERD_SYMLINK:
9393
if d.isMig {
9494
continue
9595
}

0 commit comments

Comments
 (0)