Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1d8ad8c
Bump golangci-lint for go1.25
brandond Dec 12, 2025
682476e
Add lint/validate job
brandond Dec 12, 2025
a81c0f6
lint: file is not properly formatted
brandond Dec 15, 2025
cdd68b5
lint: redundant-build-tag
brandond Dec 15, 2025
3b8fd0a
lint: use-any
brandond Dec 15, 2025
ae7ca9d
lint: dot-imports
brandond Dec 15, 2025
b9ef15d
lint: comment-spacings
brandond Dec 15, 2025
61ae3ae
lint: deep-exit
brandond Dec 15, 2025
84be07b
lint: bare-return
brandond Dec 15, 2025
c411d69
lint: bool-literal-in-expr
brandond Dec 15, 2025
11f5c39
lint: defer,get-return
brandond Dec 15, 2025
ab8e822
lint: duplicated-imports
brandond Dec 15, 2025
1be8139
lint: empty-lines
brandond Dec 15, 2025
88b394d
lint: exported
brandond Dec 15, 2025
fd639c1
lint: if-return
brandond Dec 15, 2025
e210569
lint: import-alias-naming
brandond Dec 15, 2025
835f1aa
lint: indent-error-flow
brandond Dec 15, 2025
fcea322
lint: redefines-builtin-id
brandond Dec 15, 2025
089f4a7
lint: struct-tag
brandond Dec 15, 2025
00ae1bd
lint: superfluous-else
brandond Dec 15, 2025
ebaff0a
lint: unchecked-type-assertion
brandond Dec 16, 2025
86b314d
lint: unexported-naming
brandond Dec 16, 2025
7b1af88
lint: unexported-return
brandond Dec 16, 2025
50937e8
lint: unnecessary-stmt
brandond Dec 16, 2025
36bf7a9
lint: useless-break
brandond Dec 16, 2025
c9dea96
lint: identical-switch-branches
brandond Dec 16, 2025
0f867bc
lint: unhandled-error
brandond Dec 16, 2025
6cd9049
lint: unnecessary-format,use-errors-new
brandond Dec 16, 2025
d2acbc3
lint: nested-structs
brandond Dec 16, 2025
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
63 changes: 63 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Validate
on:
pull_request:
paths-ignore:
- "**.md"
- "channel.yaml"
- "install.sh"
- "tests/**"
- "!tests/e2e**"
- "!tests/docker**"
- ".github/**"
- "!.github/actions/**"
- "!.github/workflows/validate.yaml"

permissions:
contents: read

jobs:
validate:
name: Validate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: ${{ github.event.pull_request.commits }}

- name: Set Go Version
run: |
source ./scripts/version.sh
{
echo "GOTOOLCHAIN=${VERSION_GOLANG/go}"
} >> "$GITHUB_ENV"

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: "${{ env.GOTOOLCHAIN }}"

- name: Lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.7
args: "--new-from-merge-base ${{ github.event.pull_request.base.sha }}"

- name: Lint (windows)
uses: golangci/golangci-lint-action@v9
with:
version: v2.7
args: "--new-from-merge-base ${{ github.event.pull_request.base.sha }} ./pkg/... ./cmd/..."
env:
GOOS: "windows"

- name: Validate
run: ./scripts/validate
env:
SKIP_LINT: "true"

- name: Validate (windows)
run: ./scripts/validate
env:
SKIP_LINT: "true"
GOOS: "windows"
46 changes: 0 additions & 46 deletions .golangci.json

This file was deleted.

56 changes: 56 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
issues:
max-issues-per-linter: 1000
max-same-issues: 100
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
linters:
default: none
enable:
- govet
- revive
settings:
revive:
enable-all-rules: true
rules:
- {name: add-constant, disabled: true}
- {name: argument-limit, disabled: true}
- {name: cognitive-complexity, disabled: true}
- {name: confusing-naming, disabled: true}
- {name: confusing-results, disabled: true}
- {name: cyclomatic, disabled: true}
- {name: early-return, disabled: true}
- {name: empty-block, disabled: true}
- {name: enforce-switch-style, disabled: true}
- {name: flag-parameter, disabled: true}
- {name: function-length, disabled: true}
- {name: function-result-limit, disabled: true}
- {name: import-shadowing, disabled: true}
- {name: line-length-limit, disabled: true}
- {name: max-control-nesting, disabled: true}
- {name: max-public-structs, disabled: true}
- {name: redundant-import-alias, disabled: true}
- {name: unsecure-url-scheme, disabled: true}
- {name: unused-parameter, disabled: true}
- {name: unused-receiver, disabled: true}
- {name: var-naming, disabled: true}
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
- tests/
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
version: "2"
4 changes: 2 additions & 2 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ RUN case "$(go env GOARCH)" in \
fi

# Install goimports
RUN GOPROXY=direct go install golang.org/x/tools/cmd/goimports@gopls/v0.16.0
RUN GOPROXY=direct go install golang.org/x/tools/cmd/goimports@gopls/v0.20.0

# Cleanup
RUN rm -rf /go/src /go/pkg

# Install golangci-lint for amd64
RUN if [ "$(go env GOARCH)" = "amd64" ]; then \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.55.2; \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/refs/tags/v2.7.2/install.sh | sh -s -- v2.7.2; \
fi

# Set SELINUX environment variable
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ RUN apk -U --no-cache add bash git gcc musl-dev docker vim less file curl wget c
fi

# Install goimports
RUN GOPROXY=direct go install golang.org/x/tools/cmd/goimports@gopls/v0.16.0
RUN GOPROXY=direct go install golang.org/x/tools/cmd/goimports@gopls/v0.20.0
RUN rm -rf /go/src /go/pkg

RUN if [ "$(go env GOARCH)" = "amd64" ]; then \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.2; \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/refs/tags/v2.7.2/install.sh | sh -s -- v2.7.2; \
fi

ARG SELINUX=true
Expand Down
1 change: 0 additions & 1 deletion cmd/k3s/main_linux.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux
// +build linux

package main

Expand Down
1 change: 0 additions & 1 deletion cmd/k3s/main_windows.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build windows
// +build windows

package main

Expand Down
7 changes: 3 additions & 4 deletions pkg/agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func splitCertKeyPEM(bytes []byte) (certPem []byte, keyPem []byte) {
}
}

return
return certPem, keyPem
}

// getKubeletClientCert fills the kubelet client certificate with content returned
Expand Down Expand Up @@ -392,9 +392,8 @@ func isValidResolvConf(resolvConfFile string) bool {
if len(ipMatch) == 2 {
if !isValidNameserver(ipMatch[1]) {
return false
} else {
foundNameserver = true
}
foundNameserver = true
}
}
if err := scanner.Err(); err != nil {
Expand Down Expand Up @@ -833,7 +832,7 @@ func validateNetworkConfig(nodeConfig *config.Node) error {
// Old versions of the server do not send enough information to correctly start the NPC. Users
// need to upgrade the server to at least the same version as the agent, or disable the NPC
// cluster-wide.
if nodeConfig.AgentConfig.DisableNPC == false && (nodeConfig.AgentConfig.ServiceCIDR == nil || nodeConfig.AgentConfig.ServiceNodePortRange.Size == 0) {
if !nodeConfig.AgentConfig.DisableNPC && (nodeConfig.AgentConfig.ServiceCIDR == nil || nodeConfig.AgentConfig.ServiceNodePortRange.Size == 0) {
return fmt.Errorf("incompatible down-level server detected; servers must be upgraded to at least %s, or restarted with --disable-network-policy", version.Version)
}

Expand Down
1 change: 0 additions & 1 deletion pkg/agent/config/config_linux.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux
// +build linux

package config

Expand Down
1 change: 0 additions & 1 deletion pkg/agent/config/config_linux_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux
// +build linux

package config

Expand Down
1 change: 0 additions & 1 deletion pkg/agent/config/config_windows.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build windows
// +build windows

package config

Expand Down
16 changes: 8 additions & 8 deletions pkg/agent/containerd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@ func getHostConfigs(registry *registries.Registry, noDefaultEndpoint bool, mirro
// create the default config, if it wasn't explicitly mentioned in the config section
config, ok := hosts[host]
if !ok {
if c, err := defaultHostConfig(host, mirrorAddr, configForHost(registry.Configs, host)); err != nil {
c, err := defaultHostConfig(host, mirrorAddr, configForHost(registry.Configs, host))
if err != nil {
logrus.Errorf("Failed to generate config for registry %s: %v", host, err)
continue
} else {
if noDefaultEndpoint {
c.Default = nil
} else if host == "*" {
c.Default = &templates.RegistryEndpoint{URL: &url.URL{}}
}
config = *c
}
if noDefaultEndpoint {
c.Default = nil
} else if host == "*" {
c.Default = &templates.RegistryEndpoint{URL: &url.URL{}}
}
config = *c
}

// track which endpoints we've already seen to avoid creating duplicates
Expand Down
1 change: 0 additions & 1 deletion pkg/agent/containerd/config_linux.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux
// +build linux

package containerd

Expand Down
1 change: 0 additions & 1 deletion pkg/agent/containerd/config_windows.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build windows
// +build windows

package containerd

Expand Down
1 change: 0 additions & 1 deletion pkg/agent/containerd/runtimes.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux
// +build linux

package containerd

Expand Down
7 changes: 1 addition & 6 deletions pkg/agent/containerd/runtimes_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux
// +build linux

package containerd

Expand Down Expand Up @@ -130,9 +129,5 @@ func createExec(path string) error {
return err
}

if err := os.Chmod(path, 0755); err != nil {
return err
}

return nil
return os.Chmod(path, 0755)
}
1 change: 0 additions & 1 deletion pkg/agent/cri/cri_linux.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux
// +build linux

package cri

Expand Down
1 change: 0 additions & 1 deletion pkg/agent/cri/cri_windows.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build windows
// +build windows

package cri

Expand Down
1 change: 0 additions & 1 deletion pkg/agent/cridockerd/config_linux.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux && !no_cri_dockerd
// +build linux,!no_cri_dockerd

package cridockerd

Expand Down
1 change: 0 additions & 1 deletion pkg/agent/cridockerd/config_windows.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build windows && !no_cri_dockerd
// +build windows,!no_cri_dockerd

package cridockerd

Expand Down
1 change: 0 additions & 1 deletion pkg/agent/cridockerd/cridockerd.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build !no_cri_dockerd
// +build !no_cri_dockerd

package cridockerd

Expand Down
1 change: 0 additions & 1 deletion pkg/agent/cridockerd/nocridockerd.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build no_cri_dockerd
// +build no_cri_dockerd

package cridockerd

Expand Down
Loading