File tree 5 files changed +50
-26
lines changed
5 files changed +50
-26
lines changed Original file line number Diff line number Diff line change 27
27
- uses : actions/setup-go@v5
28
28
with :
29
29
go-version : " ${{ env.GO_VERSION }}"
30
- - uses : golangci/golangci-lint-action@v6
30
+ - uses : golangci/golangci-lint-action@v7
31
31
with :
32
- version : v1.64
32
+ version : v2.0
33
33
# Extra linters, only checking new code from a pull request.
34
34
- name : lint-extra
35
35
if : github.event_name == 'pull_request'
Original file line number Diff line number Diff line change 2
2
# github PRs only (see lint-extra in .github/workflows/validate.yml).
3
3
#
4
4
# For the default linter config, see .golangci.yml. This config should
5
- # only enable additional linters not enabled in the default config.
5
+ # only enable additional linters and/or linter settings not enabled
6
+ # in the default config.
7
+ version : " 2"
6
8
7
9
linters :
8
- disable-all : true
10
+ default : none
9
11
enable :
10
12
- godot
11
13
- revive
12
-
14
+ - staticcheck
15
+ settings :
16
+ staticcheck :
17
+ checks :
18
+ - all
19
+ - -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression.
20
+ exclusions :
21
+ generated : strict
Original file line number Diff line number Diff line change 1
1
# For documentation, see https://golangci-lint.run/usage/configuration/
2
+ version : " 2"
3
+
4
+ formatters :
5
+ enable :
6
+ - gofumpt
7
+ exclusions :
8
+ generated : strict
2
9
3
10
linters :
4
11
enable :
5
12
- errorlint
6
- - gofumpt
7
13
- nolintlint
8
14
- unconvert
9
15
- unparam
10
-
11
- linters-settings :
12
- govet :
13
- enable :
14
- - nilness
16
+ settings :
17
+ govet :
18
+ enable :
19
+ - nilness
20
+ staticcheck :
21
+ checks :
22
+ - all
23
+ - -ST1000 # https://staticcheck.dev/docs/checks/#ST1000 Incorrect or missing package comment.
24
+ - -ST1003 # https://staticcheck.dev/docs/checks/#ST1003 Poorly chosen identifier.
25
+ - -ST1005 # https://staticcheck.dev/docs/checks/#ST1005 Incorrectly formatted error string.
26
+ - -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression.
27
+ exclusions :
28
+ generated : strict
29
+ presets :
30
+ - comments
31
+ - std-error-handling
Original file line number Diff line number Diff line change @@ -261,7 +261,7 @@ func (e *emulator) Apply(rule devices.Rule) error {
261
261
}
262
262
263
263
// emulatorFromList takes a reader to a "devices.list"-like source, and returns
264
- // a new Emulator that represents the state of the devices cgroup. Note that
264
+ // a new emulator that represents the state of the devices cgroup. Note that
265
265
// black-list devices cgroups cannot be fully reconstructed, due to limitations
266
266
// in the devices cgroup API. Instead, such cgroups are always treated as
267
267
// "allow all" cgroups.
@@ -301,11 +301,12 @@ func emulatorFromList(list io.Reader) (*emulator, error) {
301
301
// disruptive rules (like denying all device access) will only be applied if
302
302
// necessary.
303
303
//
304
- // This function is the sole reason for all of Emulator -- to allow us
304
+ // This function is the sole reason for all of emulator -- to allow us
305
305
// to figure out how to update a containers' cgroups without causing spurious
306
306
// device errors (if possible).
307
- func (source * emulator ) Transition (target * emulator ) ([]* devices.Rule , error ) { //nolint:revive // Ignore receiver-naming warning.
307
+ func (e * emulator ) Transition (target * emulator ) ([]* devices.Rule , error ) {
308
308
var transitionRules []* devices.Rule
309
+ source := e
309
310
oldRules := source .rules
310
311
311
312
// If the default policy doesn't match, we need to include a "disruptive"
Original file line number Diff line number Diff line change @@ -18,17 +18,14 @@ import (
18
18
// cgroupv2 files with .min, .max, .low, or .high suffix.
19
19
// The value of -1 is converted to "max" for cgroupv1 compatibility
20
20
// (which used to write -1 to remove the limit).
21
- func numToStr (value int64 ) (ret string ) {
22
- switch {
23
- case value == 0 :
24
- ret = ""
25
- case value == - 1 :
26
- ret = "max"
27
- default :
28
- ret = strconv .FormatInt (value , 10 )
29
- }
30
-
31
- return ret
21
+ func numToStr (value int64 ) string {
22
+ switch value {
23
+ case 0 :
24
+ return ""
25
+ case - 1 :
26
+ return "max"
27
+ }
28
+ return strconv .FormatInt (value , 10 )
32
29
}
33
30
34
31
func isMemorySet (r * cgroups.Resources ) bool {
@@ -57,7 +54,7 @@ func setMemory(dirPath string, r *cgroups.Resources) error {
57
54
if swapStr != "" {
58
55
if err := cgroups .WriteFile (dirPath , "memory.swap.max" , swapStr ); err != nil {
59
56
// If swap is not enabled, silently ignore setting to max or disabling it.
60
- if ! (errors .Is (err , os .ErrNotExist ) && (swapStr == "max" || swapStr == "0" )) {
57
+ if ! (errors .Is (err , os .ErrNotExist ) && (swapStr == "max" || swapStr == "0" )) { //nolint:staticcheck // Ignore "QF1001: could apply De Morgan's law".
61
58
return err
62
59
}
63
60
}
You can’t perform that action at this time.
0 commit comments