From 8dc53e59152bc21a21eaf4ee06faea8bdf83432a Mon Sep 17 00:00:00 2001 From: Randy Bruno Piverger <21374229+Randy424@users.noreply.github.com> Date: Tue, 15 Sep 2026 13:16:32 -0700 Subject: [PATCH] Bump golangci-lint to v2.13.2 for Go 1.26 export-data support golangci-lint v1.64.8 predates Go 1.26 by nearly a year and cannot read its export data format, failing with: could not decode ..., export data version 4 is greater than maximum supported version 2 Confirmed via golangci-lint's own changelog that go1.26 support (golangci-lint#6271) first shipped in v2.9.0. Verified independently against a real Prow CI run (stolostron/console, ACM-42591 validation PR): switching to v2.13.2 clears the export-data error completely. v1 and v2 use incompatible config schemas, so backend/.golangci.yml is migrated via golangci-lint's own migrate command rather than hand-edited. The migration tool correctly drops errcheck, gosimple, govet, ineffassign, staticcheck, and unused from the explicit enable list (now part of v2's default set) and moves gci under the new formatters section. Also fixes the 3 real staticcheck findings the version bump surfaces (previously masked by the export-data crash, not new bugs): - aggregate/status.go: simplify a negated boolean (De Morgan's law) - auth/auth.go: TLSClientConfig is embedded in rest.Config; the explicit selector was redundant - vmproxy/units.go: error strings should not be capitalized or end in punctuation (six occurrences, ST1005) Note: the version bump also surfaces 3 new unused findings in internal/clusterinfo/clusterinfo_test.go and internal/informers/factory_test.go (test helpers that appear to be declared but never referenced), from the recent partial-discovery work in #66. Left those alone since they are outside this fix's scope and worth a second look from whoever wrote that test. Signed-off-by: Randy Bruno Piverger <21374229+Randy424@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5 --- backend/.golangci.yml | 66 ++++++++++++++++------------ backend/internal/aggregate/status.go | 2 +- backend/internal/auth/auth.go | 2 +- backend/internal/vmproxy/units.go | 12 ++--- scripts/golangci-lint-backend.sh | 4 +- 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/backend/.golangci.yml b/backend/.golangci.yml index b436b9a0fd..27246b9bde 100644 --- a/backend/.golangci.yml +++ b/backend/.golangci.yml @@ -1,34 +1,46 @@ -# golangci-lint configuration -# https://golangci-lint.run/usage/configuration/ +version: "2" run: tests: true linters: enable: - copyloopvar - - errcheck - - gosimple - - govet - - ineffassign - misspell - revive - - staticcheck - - unused -linters-settings: - copyloopvar: - check-alias: true - govet: - enable: - - shadow - misspell: - locale: US - revive: - rules: - - name: package-comments - disabled: true - gci: - sections: - - standard - - default - - prefix(github.com/stolostron/console/backend) - - blank - - dot + settings: + copyloopvar: + check-alias: true + govet: + enable: + - shadow + misspell: + locale: US + revive: + rules: + - name: package-comments + disabled: true + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + settings: + gci: + sections: + - standard + - default + - prefix(github.com/stolostron/console/backend) + - blank + - dot + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/backend/internal/aggregate/status.go b/backend/internal/aggregate/status.go index 6c0af988a3..35f5b56928 100644 --- a/backend/internal/aggregate/status.go +++ b/backend/internal/aggregate/status.go @@ -162,7 +162,7 @@ func computeDeployedPodStatuses(related []mapKind, appStatusesMap map[string]Sta podMap := createResourceMap(related, "Pod") for appKey, clusterMap := range appStatusesMap { for clusterKey, appStatuses := range clusterMap { - if !(appStatuses.Health.Counts[scoreHealthy] > 0 && appStatuses.Synced.Counts[scoreHealthy] > 0) && !ignoreHealthCheck { + if (appStatuses.Health.Counts[scoreHealthy] <= 0 || appStatuses.Synced.Counts[scoreHealthy] <= 0) && !ignoreHealthCheck { continue } id := ids[statusIDKey(appKey, clusterKey)] diff --git a/backend/internal/auth/auth.go b/backend/internal/auth/auth.go index 91955d0bbd..e481bcbc1c 100644 --- a/backend/internal/auth/auth.go +++ b/backend/internal/auth/auth.go @@ -143,7 +143,7 @@ func RESTConfig(cfg *config.Config, sa ServiceAccount) (*rest.Config, error) { }, } if len(sa.CACert) == 0 { - restCfg.TLSClientConfig.Insecure = true + restCfg.Insecure = true } return restCfg, nil } diff --git a/backend/internal/vmproxy/units.go b/backend/internal/vmproxy/units.go index 69ed876a8b..76a996477c 100644 --- a/backend/internal/vmproxy/units.go +++ b/backend/internal/vmproxy/units.go @@ -51,19 +51,19 @@ func convertBytesToGibibytes(bytes float64) float64 { func toMillicores(cpuRequest string) (float64, error) { trimmed := strings.TrimSpace(cpuRequest) if trimmed == "" { - return 0, fmt.Errorf("Invalid input: cpuRequest must be a non-empty string.") + return 0, fmt.Errorf("invalid input: cpuRequest must be a non-empty string") } if strings.HasSuffix(trimmed, "m") { numericPart := trimmed[:len(trimmed)-1] millicores, err := strconv.Atoi(numericPart) if err != nil || strconv.Itoa(millicores) != numericPart { - return 0, fmt.Errorf("Invalid millicore value: %q. The part before \"m\" must be an integer.", cpuRequest) + return 0, fmt.Errorf("invalid millicore value: %q, the part before \"m\" must be an integer", cpuRequest) } return float64(millicores), nil } coreValue, err := strconv.ParseFloat(trimmed, 64) if err != nil { - return 0, fmt.Errorf("Invalid core value: %q. Must be a number or end with 'm'.", cpuRequest) + return 0, fmt.Errorf("invalid core value: %q, must be a number or end with 'm'", cpuRequest) } return coreValue * 1000, nil } @@ -73,11 +73,11 @@ var memoryRE = regexp.MustCompile(`^(\d+(\.\d+)?)\s*([A-Za-z]+)?$`) func toMebibytes(memoryRequest string) (float64, error) { trimmed := strings.TrimSpace(memoryRequest) if trimmed == "" { - return 0, fmt.Errorf("Invalid input: memoryRequest must be a non-empty string.") + return 0, fmt.Errorf("invalid input: memoryRequest must be a non-empty string") } match := memoryRE.FindStringSubmatch(trimmed) if match == nil { - return 0, fmt.Errorf("Invalid memory format: %q. Expected a number followed by an optional unit.", memoryRequest) + return 0, fmt.Errorf("invalid memory format: %q, expected a number followed by an optional unit", memoryRequest) } numericValue, err := strconv.ParseFloat(match[1], 64) if err != nil { @@ -105,7 +105,7 @@ func toMebibytes(memoryRequest string) (float64, error) { case multipliers[unit] != 0: bytes = numericValue * multipliers[unit] default: - return 0, fmt.Errorf("Invalid memory unit: %q.", unit) + return 0, fmt.Errorf("invalid memory unit: %q", unit) } return bytes / (1024 * 1024), nil } diff --git a/scripts/golangci-lint-backend.sh b/scripts/golangci-lint-backend.sh index 41220b9dce..bd8930e249 100755 --- a/scripts/golangci-lint-backend.sh +++ b/scripts/golangci-lint-backend.sh @@ -3,7 +3,7 @@ set -euo pipefail -readonly GOLANGCI_LINT_VERSION=v1.64.8 +readonly GOLANGCI_LINT_VERSION=v2.13.2 readonly ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" if ! command -v go >/dev/null 2>&1; then @@ -12,7 +12,7 @@ if ! command -v go >/dev/null 2>&1; then fi if ! command -v golangci-lint >/dev/null 2>&1; then - go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" + go install "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" fi export PATH="$(go env GOPATH)/bin:${PATH}"