From 4aaec9a970d14cd0052c66843e1a9e920532cc31 Mon Sep 17 00:00:00 2001 From: justinsb Date: Tue, 14 Jan 2025 17:23:40 -0500 Subject: [PATCH] chore: update golangci-lint Update everything to 1.63.4 (because go versions must match). exportloopref is not needed; that go-tcha has been fixed in go. Fix a few error message lint issues. --- .github/workflows/lint.yaml | 2 +- .github/workflows/presubmit-compositions.yaml | 4 ++-- .golangci.yaml | 1 - Makefile | 3 ++- experiments/compositions/composition/.golangci.yml | 1 - experiments/compositions/composition/Makefile | 2 +- experiments/compositions/composition/cmd/inline/main.go | 2 +- .../composition/internal/controller/composition_controller.go | 2 +- experiments/compositions/expanders/cel-expander/Makefile | 2 +- experiments/compositions/expanders/helm-expander/Makefile | 2 +- experiments/compositions/facade/Makefile | 2 +- pkg/controller/direct/common/compare.go | 2 +- 12 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 145146b374..f55a0c1aa4 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -46,5 +46,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6.1.0 with: - version: v1.59.1 # should match the version in Makefile + version: v1.63.4 # should match the version in Makefile args: --timeout=10m diff --git a/.github/workflows/presubmit-compositions.yaml b/.github/workflows/presubmit-compositions.yaml index e32a4eb8c6..e64aaa0854 100644 --- a/.github/workflows/presubmit-compositions.yaml +++ b/.github/workflows/presubmit-compositions.yaml @@ -42,10 +42,10 @@ jobs: go-version-file: 'go.mod' cache: false # because of https://github.com/golangci/golangci-lint-action/issues/135 - name: golangci-lint - uses: golangci/golangci-lint-action@v6 # v3.7.1 + uses: golangci/golangci-lint-action@v6.1.0 with: working-directory: ./experiments/compositions/composition - version: v1.59.1 # should match the version in Makefile + version: v1.63.4 # should match the version in Makefile args: --timeout=10m verify-goimports: runs-on: ubuntu-latest diff --git a/.golangci.yaml b/.golangci.yaml index 3aedd73f1c..be11eb538d 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -26,7 +26,6 @@ linters: - depguard - errcheck - errorlint - # - exportloopref # - forcetypeassert # - gci # - gocritic diff --git a/Makefile b/Makefile index 5058081819..af31d762ab 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ UNMANAGED_DETECTOR_IMG ?= gcr.io/${PROJECT_ID}/cnrm/unmanageddetector:${SHORT_SH GOLANGCI_LINT_CACHE := /tmp/golangci-lint # When updating this, make sure to update the corresponding action in # ./github/workflows/lint.yaml -GOLANGCI_LINT_VERSION := v1.59.1 +GOLANGCI_LINT_VERSION := v1.63.4 # Use Docker BuildKit when building images to allow usage of 'setcap' in # multi-stage builds (https://github.com/moby/moby/issues/38132) @@ -118,6 +118,7 @@ fmt: .PHONY: lint lint: + mkdir -p ${GOLANGCI_LINT_CACHE} docker run --rm -v $(shell pwd):/app \ -v ${GOLANGCI_LINT_CACHE}:/root/.cache/golangci-lint \ -w /app golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine \ diff --git a/experiments/compositions/composition/.golangci.yml b/experiments/compositions/composition/.golangci.yml index b615720033..7dd617b960 100644 --- a/experiments/compositions/composition/.golangci.yml +++ b/experiments/compositions/composition/.golangci.yml @@ -35,7 +35,6 @@ linters: enable: - dupl - errcheck - - exportloopref - goconst - gocyclo - gofmt diff --git a/experiments/compositions/composition/Makefile b/experiments/compositions/composition/Makefile index c69060ae29..6eeda5349e 100644 --- a/experiments/compositions/composition/Makefile +++ b/experiments/compositions/composition/Makefile @@ -80,7 +80,7 @@ test: manifests generate fmt vet envtest ## Run tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GOPREFIX) go test ./... -coverprofile cover.out GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.54.2 +GOLANGCI_LINT_VERSION ?= v1.63.4 golangci-lint: @[ -f $(GOLANGCI_LINT) ] || { \ set -e ;\ diff --git a/experiments/compositions/composition/cmd/inline/main.go b/experiments/compositions/composition/cmd/inline/main.go index 9c86791586..32fdb1990e 100644 --- a/experiments/compositions/composition/cmd/inline/main.go +++ b/experiments/compositions/composition/cmd/inline/main.go @@ -123,7 +123,7 @@ func (s *InlineSyncer) CopyToFileSystem() error { } if template == "" { - return fmt.Errorf("template not found for expander: " + s.expanderName) + return fmt.Errorf("template not found for expander: %s", s.expanderName) } // Get crdp.spec.stages[name] diff --git a/experiments/compositions/composition/internal/controller/composition_controller.go b/experiments/compositions/composition/internal/controller/composition_controller.go index d856852e0b..ff0ce4a9e6 100644 --- a/experiments/compositions/composition/internal/controller/composition_controller.go +++ b/experiments/compositions/composition/internal/controller/composition_controller.go @@ -262,7 +262,7 @@ func (r *CompositionReconciler) validateExpanderConfig(ctx context.Context, logg if result.Status != pb.Status_SUCCESS { logger.Error(nil, "expander.Validate() Status is not Success", "expander", expander.Name, "status", result.Status, "message", result.Error.Message) - err = fmt.Errorf(result.Error.Message) + err = fmt.Errorf("%s", result.Error.Message) return "ValidateStatusFailed", err } return "", nil diff --git a/experiments/compositions/expanders/cel-expander/Makefile b/experiments/compositions/expanders/cel-expander/Makefile index 5107111d11..4798623836 100644 --- a/experiments/compositions/expanders/cel-expander/Makefile +++ b/experiments/compositions/expanders/cel-expander/Makefile @@ -82,7 +82,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= v5.3.0 CONTROLLER_TOOLS_VERSION ?= v0.14.0 -GOLANGCI_LINT_VERSION ?= v1.54.2 +GOLANGCI_LINT_VERSION ?= v1.63.4 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. diff --git a/experiments/compositions/expanders/helm-expander/Makefile b/experiments/compositions/expanders/helm-expander/Makefile index b341b944f1..71134f38ac 100644 --- a/experiments/compositions/expanders/helm-expander/Makefile +++ b/experiments/compositions/expanders/helm-expander/Makefile @@ -82,7 +82,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= v5.3.0 CONTROLLER_TOOLS_VERSION ?= v0.14.0 -GOLANGCI_LINT_VERSION ?= v1.54.2 +GOLANGCI_LINT_VERSION ?= v1.63.4 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. diff --git a/experiments/compositions/facade/Makefile b/experiments/compositions/facade/Makefile index 3e9011d2b8..1b24cddb8f 100644 --- a/experiments/compositions/facade/Makefile +++ b/experiments/compositions/facade/Makefile @@ -65,7 +65,7 @@ test: manifests generate fmt vet envtest ## Run tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.54.2 +GOLANGCI_LINT_VERSION ?= v1.63.4 golangci-lint: @[ -f $(GOLANGCI_LINT) ] || { \ set -e ;\ diff --git a/pkg/controller/direct/common/compare.go b/pkg/controller/direct/common/compare.go index cec125b78c..d40166bbfe 100644 --- a/pkg/controller/direct/common/compare.go +++ b/pkg/controller/direct/common/compare.go @@ -41,7 +41,7 @@ var BasicDiff = func(fieldName protoreflect.Name, a, b proto.Message) (bool, err return true, nil } if !aField.Kind().IsValid() { - return false, fmt.Errorf("unimplemented kind: " + aField.Kind().String()) + return false, fmt.Errorf("unimplemented kind: %s", aField.Kind().String()) } diff := false