From f57e58de063d7bde3022e7460fc150980eff6e44 Mon Sep 17 00:00:00 2001 From: Sven Pfennig Date: Mon, 20 Jan 2025 08:10:37 +0100 Subject: [PATCH] chore(deps): update golangci-lint Signed-off-by: Sven Pfennig --- .github/workflows/ci.yml | 6 +++--- .golangci.yaml | 4 ++-- internal/containerd/configure.go | 4 ++-- internal/controller/shim_controller.go | 5 +++-- internal/shim/install.go | 6 +++--- internal/state/state.go | 2 +- tests/node-installer/fs.go | 2 +- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d55a035..04e1b5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: - go-version: "1.21" + go-version: "1.23" - run: make test golangci: @@ -37,9 +37,9 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: - go-version: "1.21" + go-version: "1.23" - name: golangci-lint uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.0 with: - version: v1.57.2 + version: v1.63.4 skip-cache: true diff --git a/.golangci.yaml b/.golangci.yaml index 3cdf0c1..c8343b6 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -188,11 +188,11 @@ linters: - asasalint # checks for pass []any as any in variadic func(...any) - asciicheck # checks that your code does not contain non-ASCII identifiers - bidichk # checks for dangerous unicode character sequences + - copyloopvar # Copyloopvar is a linter detects places where loop variables are copied. - cyclop # checks function and package cyclomatic complexity - dupl # tool for code clone detection - errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error - errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13 - - exportloopref # checks for pointers to enclosing loop variables - forbidigo # forbids identifiers - funlen # tool for detection of long functions - gocognit # computes and checks the cognitive complexity of functions @@ -200,7 +200,7 @@ linters: - gocritic # provides diagnostics that check for bugs, performance and style issues - gocyclo # computes and checks the cyclomatic complexity of functions - goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt - - gomnd # detects magic numbers + - mnd # detects magic numbers - goprintffuncname # checks that printf-like functions are named with f at the end - gosec # inspects source code for security problems - makezero # finds slice declarations with non-zero initial length diff --git a/internal/containerd/configure.go b/internal/containerd/configure.go index fc89e0b..9aedad7 100644 --- a/internal/containerd/configure.go +++ b/internal/containerd/configure.go @@ -64,7 +64,7 @@ func (c *Config) AddRuntime(shimPath string) error { } // Open file in append mode - file, err := c.hostFs.OpenFile(c.configPath, os.O_APPEND|os.O_WRONLY, 0o644) //nolint:gomnd // file permissions + file, err := c.hostFs.OpenFile(c.configPath, os.O_APPEND|os.O_WRONLY, 0o644) //nolint:mnd // file permissions if err != nil { return err } @@ -101,7 +101,7 @@ func (c *Config) RemoveRuntime(shimPath string) (changed bool, err error) { modifiedData := strings.ReplaceAll(string(data), cfg, "") // Write the modified data back to the file. - err = afero.WriteFile(c.hostFs, c.configPath, []byte(modifiedData), 0o644) //nolint:gomnd // file permissions + err = afero.WriteFile(c.hostFs, c.configPath, []byte(modifiedData), 0o644) //nolint:mnd // file permissions if err != nil { return false, err } diff --git a/internal/controller/shim_controller.go b/internal/controller/shim_controller.go index b006621..9c2183d 100644 --- a/internal/controller/shim_controller.go +++ b/internal/controller/shim_controller.go @@ -48,6 +48,7 @@ const ( UNINSTALL = "uninstall" ProvisioningStatusProvisioned = "provisioned" ProvisioningStatusPending = "pending" + K8sNameMaxLength = 63 ) // ShimReconciler reconciles a Shim object @@ -385,7 +386,7 @@ func (sr *ShimReconciler) createJobManifest(shim *rcmv1.Shim, node *corev1.Node, sr.setOperationConfiguration(shim, &opConfig) name := node.Name + "-" + shim.Name + "-" + operation - nameMax := int(math.Min(float64(len(name)), 63)) + nameMax := int(math.Min(float64(len(name)), K8sNameMaxLength)) job := &batchv1.Job{ TypeMeta: metav1.TypeMeta{ @@ -498,7 +499,7 @@ func (sr *ShimReconciler) handleDeployRuntimeClass(ctx context.Context, shim *rc // createRuntimeClassManifest creates a RuntimeClass manifest for a Shim. func (sr *ShimReconciler) createRuntimeClassManifest(shim *rcmv1.Shim) (*nodev1.RuntimeClass, error) { name := shim.Spec.RuntimeClass.Name - nameMax := int(math.Min(float64(len(name)), 63)) + nameMax := int(math.Min(float64(len(name)), K8sNameMaxLength)) nodeSelector := shim.Spec.NodeSelector if nodeSelector == nil { diff --git a/internal/shim/install.go b/internal/shim/install.go index 8d9de4e..965f684 100644 --- a/internal/shim/install.go +++ b/internal/shim/install.go @@ -28,18 +28,18 @@ import ( func (c *Config) Install(shimName string) (filePath string, changed bool, err error) { shimPath := filepath.Join(c.assetPath, shimName) - srcFile, err := c.rootFs.OpenFile(shimPath, os.O_RDONLY, 0o000) //nolint:gomnd // file permissions + srcFile, err := c.rootFs.OpenFile(shimPath, os.O_RDONLY, 0o000) //nolint:mnd // file permissions if err != nil { return "", false, err } dstFilePath := path.Join(c.kwasmPath, "bin", shimName) - err = c.hostFs.MkdirAll(path.Dir(dstFilePath), 0o775) //nolint:gomnd // file permissions + err = c.hostFs.MkdirAll(path.Dir(dstFilePath), 0o775) //nolint:mnd // file permissions if err != nil { return dstFilePath, false, err } - dstFile, err := c.hostFs.OpenFile(dstFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o755) //nolint:gomnd // file permissions + dstFile, err := c.hostFs.OpenFile(dstFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o755) //nolint:mnd // file permissions if err != nil { return "", false, err } diff --git a/internal/state/state.go b/internal/state/state.go index 34113d3..4ca1a5d 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -60,5 +60,5 @@ func (l *State) Write() error { slog.Debug("writing lock file", "content", string(out)) - return afero.WriteFile(l.fs, l.lockFilePath, out, 0644) //nolint:gomnd // file permissions + return afero.WriteFile(l.fs, l.lockFilePath, out, 0644) //nolint:mnd // file permissions } diff --git a/tests/node-installer/fs.go b/tests/node-installer/fs.go index 7d2d63f..89cc784 100644 --- a/tests/node-installer/fs.go +++ b/tests/node-installer/fs.go @@ -15,7 +15,7 @@ func FixtureFs(fixturePath string) afero.Fs { return err } if info.IsDir() { - return fs.MkdirAll(path, 0755) //nolint:gomnd // file permissions + return fs.MkdirAll(path, 0755) //nolint:mnd // file permissions } src, err := baseFs.Open(path) if err != nil {