Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
- uses: golangci/golangci-lint-action@v6
- uses: golangci/golangci-lint-action@v7
with:
version: v1.64
version: v2.0
# Extra linters, only checking new code from a pull request.
- name: lint-extra
if: github.event_name == 'pull_request'
Expand Down
15 changes: 12 additions & 3 deletions .golangci-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
# github PRs only (see lint-extra in .github/workflows/validate.yml).
#
# For the default linter config, see .golangci.yml. This config should
# only enable additional linters not enabled in the default config.
# only enable additional linters and/or linter settings not enabled
# in the default config.
version: "2"

linters:
disable-all: true
default: none
enable:
- godot
- revive

- staticcheck
settings:
staticcheck:
checks:
- all
- -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression.
exclusions:
generated: strict
29 changes: 23 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
# For documentation, see https://golangci-lint.run/usage/configuration/
version: "2"

formatters:
enable:
- gofumpt
exclusions:
generated: strict

linters:
enable:
- errorlint
- gofumpt
- nolintlint
- unconvert
- unparam

linters-settings:
govet:
enable:
- nilness
settings:
govet:
enable:
- nilness
staticcheck:
checks:
- all
- -ST1000 # https://staticcheck.dev/docs/checks/#ST1000 Incorrect or missing package comment.
- -ST1003 # https://staticcheck.dev/docs/checks/#ST1003 Poorly chosen identifier.
- -ST1005 # https://staticcheck.dev/docs/checks/#ST1005 Incorrectly formatted error string.
- -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression.
exclusions:
generated: strict
presets:
- comments
- std-error-handling
7 changes: 4 additions & 3 deletions devices/devices_emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (e *emulator) Apply(rule devices.Rule) error {
}

// emulatorFromList takes a reader to a "devices.list"-like source, and returns
// a new Emulator that represents the state of the devices cgroup. Note that
// a new emulator that represents the state of the devices cgroup. Note that
// black-list devices cgroups cannot be fully reconstructed, due to limitations
// in the devices cgroup API. Instead, such cgroups are always treated as
// "allow all" cgroups.
Expand Down Expand Up @@ -301,11 +301,12 @@ func emulatorFromList(list io.Reader) (*emulator, error) {
// disruptive rules (like denying all device access) will only be applied if
// necessary.
//
// This function is the sole reason for all of Emulator -- to allow us
// This function is the sole reason for all of emulator -- to allow us
// to figure out how to update a containers' cgroups without causing spurious
// device errors (if possible).
func (source *emulator) Transition(target *emulator) ([]*devices.Rule, error) { //nolint:revive // Ignore receiver-naming warning.
func (e *emulator) Transition(target *emulator) ([]*devices.Rule, error) {
var transitionRules []*devices.Rule
source := e
oldRules := source.rules

// If the default policy doesn't match, we need to include a "disruptive"
Expand Down
21 changes: 9 additions & 12 deletions fs2/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ import (
// cgroupv2 files with .min, .max, .low, or .high suffix.
// The value of -1 is converted to "max" for cgroupv1 compatibility
// (which used to write -1 to remove the limit).
func numToStr(value int64) (ret string) {
switch {
case value == 0:
ret = ""
case value == -1:
ret = "max"
default:
ret = strconv.FormatInt(value, 10)
}

return ret
func numToStr(value int64) string {
switch value {
case 0:
return ""
case -1:
return "max"
}
return strconv.FormatInt(value, 10)
}

func isMemorySet(r *cgroups.Resources) bool {
Expand Down Expand Up @@ -57,7 +54,7 @@ func setMemory(dirPath string, r *cgroups.Resources) error {
if swapStr != "" {
if err := cgroups.WriteFile(dirPath, "memory.swap.max", swapStr); err != nil {
// If swap is not enabled, silently ignore setting to max or disabling it.
if !(errors.Is(err, os.ErrNotExist) && (swapStr == "max" || swapStr == "0")) {
if !(errors.Is(err, os.ErrNotExist) && (swapStr == "max" || swapStr == "0")) { //nolint:staticcheck // Ignore "QF1001: could apply De Morgan's law".
return err
}
}
Expand Down