diff --git a/.github/workflows/lint-sample.yml b/.github/workflows/lint-sample.yml index ee4ac33a410..e7839eb8652 100644 --- a/.github/workflows/lint-sample.yml +++ b/.github/workflows/lint-sample.yml @@ -32,7 +32,7 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v6 with: - version: v1.61.0 + version: v1.62.2 working-directory: ${{ matrix.folder }} args: --config .golangci.yml ./... - name: Run linter via makefile target diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 16664976e60..8f84da91633 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,7 +24,7 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v6 with: - version: v1.61 + version: v1.62.2 yamllint: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 31b9c58ec19..acdc7fce14d 100644 --- a/Makefile +++ b/Makefile @@ -114,7 +114,7 @@ GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint golangci-lint: @[ -f $(GOLANGCI_LINT) ] || { \ set -e ;\ - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.61.0 ;\ + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.62.2 ;\ } .PHONY: apidiff diff --git a/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml b/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml index 874cc333728..46511063a49 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml +++ b/docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml @@ -20,4 +20,4 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v6 with: - version: v1.61.0 + version: v1.62.2 diff --git a/docs/book/src/cronjob-tutorial/testdata/project/Makefile b/docs/book/src/cronjob-tutorial/testdata/project/Makefile index edc52bcaa50..b1c2661bc45 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/Makefile +++ b/docs/book/src/cronjob-tutorial/testdata/project/Makefile @@ -178,7 +178,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.16.5 ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}') #ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31) ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}') -GOLANGCI_LINT_VERSION ?= v1.61.0 +GOLANGCI_LINT_VERSION ?= v1.62.2 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. diff --git a/docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml b/docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml index 874cc333728..46511063a49 100644 --- a/docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml +++ b/docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml @@ -20,4 +20,4 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v6 with: - version: v1.61.0 + version: v1.62.2 diff --git a/docs/book/src/getting-started/testdata/project/Makefile b/docs/book/src/getting-started/testdata/project/Makefile index 861ac7b71c3..221ae92d1fe 100644 --- a/docs/book/src/getting-started/testdata/project/Makefile +++ b/docs/book/src/getting-started/testdata/project/Makefile @@ -174,7 +174,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.16.5 ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}') #ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31) ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}') -GOLANGCI_LINT_VERSION ?= v1.61.0 +GOLANGCI_LINT_VERSION ?= v1.62.2 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. diff --git a/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml b/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml index 874cc333728..46511063a49 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml +++ b/docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml @@ -20,4 +20,4 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v6 with: - version: v1.61.0 + version: v1.62.2 diff --git a/docs/book/src/multiversion-tutorial/testdata/project/Makefile b/docs/book/src/multiversion-tutorial/testdata/project/Makefile index edc52bcaa50..b1c2661bc45 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/Makefile +++ b/docs/book/src/multiversion-tutorial/testdata/project/Makefile @@ -178,7 +178,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.16.5 ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}') #ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31) ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}') -GOLANGCI_LINT_VERSION ?= v1.61.0 +GOLANGCI_LINT_VERSION ?= v1.62.2 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. diff --git a/pkg/plugin/util/util.go b/pkg/plugin/util/util.go index 6cd0d325707..29619c3d385 100644 --- a/pkg/plugin/util/util.go +++ b/pkg/plugin/util/util.go @@ -227,7 +227,7 @@ func EnsureExistAndReplace(input, match, replace string) (string, error) { } // ReplaceInFile replaces all instances of old with new in the file at path. -func ReplaceInFile(path, old, new string) error { +func ReplaceInFile(path, oldValue, newValue string) error { info, err := os.Stat(path) if err != nil { return err @@ -238,10 +238,10 @@ func ReplaceInFile(path, old, new string) error { if err != nil { return err } - if !strings.Contains(string(b), old) { + if !strings.Contains(string(b), oldValue) { return errors.New("unable to find the content to be replaced") } - s := strings.Replace(string(b), old, new, -1) + s := strings.Replace(string(b), oldValue, newValue, -1) err = os.WriteFile(path, []byte(s), info.Mode()) if err != nil { return err diff --git a/pkg/plugins/golang/go_version.go b/pkg/plugins/golang/go_version.go index 9823863fc9d..82b27514c54 100644 --- a/pkg/plugins/golang/go_version.go +++ b/pkg/plugins/golang/go_version.go @@ -125,15 +125,15 @@ func (v GoVersion) Compare(other GoVersion) int { } // ValidateGoVersion verifies that Go is installed and the current go version is supported by a plugin. -func ValidateGoVersion(min, max GoVersion) error { - err := fetchAndCheckGoVersion(min, max) +func ValidateGoVersion(minVersion, maxVersion GoVersion) error { + err := fetchAndCheckGoVersion(minVersion, maxVersion) if err != nil { return fmt.Errorf("%s. You can skip this check using the --skip-go-version-check flag", err) } return nil } -func fetchAndCheckGoVersion(min, max GoVersion) error { +func fetchAndCheckGoVersion(minVersion, maxVersion GoVersion) error { cmd := exec.Command("go", "version") out, err := cmd.Output() if err != nil { @@ -145,20 +145,20 @@ func fetchAndCheckGoVersion(min, max GoVersion) error { return fmt.Errorf("found invalid Go version: %q", string(out)) } goVer := split[2] - if err := checkGoVersion(goVer, min, max); err != nil { + if err := checkGoVersion(goVer, minVersion, maxVersion); err != nil { return fmt.Errorf("go version '%s' is incompatible because '%s'", goVer, err) } return nil } -func checkGoVersion(verStr string, min, max GoVersion) error { +func checkGoVersion(verStr string, minVersion, maxVersion GoVersion) error { var version GoVersion if err := version.parse(verStr); err != nil { return err } - if version.Compare(min) < 0 || version.Compare(max) >= 0 { - return fmt.Errorf("plugin requires %s <= version < %s", min, max) + if version.Compare(minVersion) < 0 || version.Compare(maxVersion) >= 0 { + return fmt.Errorf("plugin requires %s <= version < %s", minVersion, maxVersion) } return nil diff --git a/pkg/plugins/golang/v4/scaffolds/init.go b/pkg/plugins/golang/v4/scaffolds/init.go index 004290582e8..dc5ff085735 100644 --- a/pkg/plugins/golang/v4/scaffolds/init.go +++ b/pkg/plugins/golang/v4/scaffolds/init.go @@ -37,7 +37,7 @@ import ( const ( // GolangciLintVersion is the golangci-lint version to be used in the project - GolangciLintVersion = "v1.61.0" + GolangciLintVersion = "v1.62.2" // ControllerRuntimeVersion is the kubernetes-sigs/controller-runtime version to be used in the project ControllerRuntimeVersion = "v0.19.1" // ControllerToolsVersion is the kubernetes-sigs/controller-tools version to be used in the project diff --git a/testdata/project-v4-multigroup/.github/workflows/lint.yml b/testdata/project-v4-multigroup/.github/workflows/lint.yml index 874cc333728..46511063a49 100644 --- a/testdata/project-v4-multigroup/.github/workflows/lint.yml +++ b/testdata/project-v4-multigroup/.github/workflows/lint.yml @@ -20,4 +20,4 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v6 with: - version: v1.61.0 + version: v1.62.2 diff --git a/testdata/project-v4-multigroup/Makefile b/testdata/project-v4-multigroup/Makefile index 5d936e43e30..83b9bca464d 100644 --- a/testdata/project-v4-multigroup/Makefile +++ b/testdata/project-v4-multigroup/Makefile @@ -174,7 +174,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.16.5 ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}') #ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31) ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}') -GOLANGCI_LINT_VERSION ?= v1.61.0 +GOLANGCI_LINT_VERSION ?= v1.62.2 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. diff --git a/testdata/project-v4-with-plugins/.github/workflows/lint.yml b/testdata/project-v4-with-plugins/.github/workflows/lint.yml index 874cc333728..46511063a49 100644 --- a/testdata/project-v4-with-plugins/.github/workflows/lint.yml +++ b/testdata/project-v4-with-plugins/.github/workflows/lint.yml @@ -20,4 +20,4 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v6 with: - version: v1.61.0 + version: v1.62.2 diff --git a/testdata/project-v4-with-plugins/Makefile b/testdata/project-v4-with-plugins/Makefile index 884584f75e6..27768e9f3ef 100644 --- a/testdata/project-v4-with-plugins/Makefile +++ b/testdata/project-v4-with-plugins/Makefile @@ -174,7 +174,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.16.5 ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}') #ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31) ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}') -GOLANGCI_LINT_VERSION ?= v1.61.0 +GOLANGCI_LINT_VERSION ?= v1.62.2 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. diff --git a/testdata/project-v4/.github/workflows/lint.yml b/testdata/project-v4/.github/workflows/lint.yml index 874cc333728..46511063a49 100644 --- a/testdata/project-v4/.github/workflows/lint.yml +++ b/testdata/project-v4/.github/workflows/lint.yml @@ -20,4 +20,4 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v6 with: - version: v1.61.0 + version: v1.62.2 diff --git a/testdata/project-v4/Makefile b/testdata/project-v4/Makefile index a7af4752249..9b3ac1740de 100644 --- a/testdata/project-v4/Makefile +++ b/testdata/project-v4/Makefile @@ -174,7 +174,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.16.5 ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}') #ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31) ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}') -GOLANGCI_LINT_VERSION ?= v1.61.0 +GOLANGCI_LINT_VERSION ?= v1.62.2 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.