Skip to content

Commit

Permalink
✨ Upgrade golangci from 1.54 to 1.57 (#3846)
Browse files Browse the repository at this point in the history
* Upgrade golangci from 1.54 to 1.57
* Fix lint issues after upgrade by:

a) Ensure that in all places we are ignoring the exception equally

```go
         // nolint:revive
	. "github.com/onsi/ginkgo/v2"
	// nolint:revive
	. "github.com/onsi/gomega"
```

b) Ensure that we use `_` for args not explicit called in the funcs. Example

```go
PreRunE: func(_ *cobra.Command, _ []string) error {
```
  • Loading branch information
camilamacedo86 committed Apr 6, 2024
1 parent 6bcd440 commit a7f6e03
Show file tree
Hide file tree
Showing 194 changed files with 366 additions and 78 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint-sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v4
with:
version: v1.54
version: v1.57
working-directory: testdata/project-v4-with-deploy-image
args: --config .golangci.yml ./...
skip-cache: true # first lint action will handle
- name: Run linter
uses: golangci/golangci-lint-action@v4
with:
version: v1.54
version: v1.57
working-directory: testdata/project-v4-multigroup-with-deploy-image
args: --config .golangci.yml ./...
skip-cache: true # first lint action will handle
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v4
with:
version: v1.54
version: v1.57

yamllint:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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.54.2 ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.57.2 ;\
}

.PHONY: apidiff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
ENVTEST_VERSION ?= release-0.17
GOLANGCI_LINT_VERSION ?= v1.54.2
GOLANGCI_LINT_VERSION ?= v1.57.2

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"fmt"
"testing"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"os/exec"
"time"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

"tutorial.kubebuilder.io/project/test/utils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os/exec"
"strings"

// nolint:revive
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive
)

Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/cronjob-tutorial/testdata/project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
ENVTEST_VERSION ?= release-0.17
GOLANGCI_LINT_VERSION ?= v1.54.2
GOLANGCI_LINT_VERSION ?= v1.57.2

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1

import (
// nolint:revive
. "github.com/onsi/ginkgo/v2"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ import (
"testing"
"time"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

admissionv1 "k8s.io/api/admission/v1"

//+kubebuilder:scaffold:imports
apimachineryruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import (
"reflect"
"time"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"
batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ import (

ctrl "sigs.k8s.io/controller-runtime"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

"k8s.io/client-go/kubernetes/scheme"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"fmt"
"testing"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"os/exec"
"time"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

"tutorial.kubebuilder.io/project/test/utils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os/exec"
"strings"

// nolint:revive
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive
)

Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/getting-started/testdata/project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
ENVTEST_VERSION ?= release-0.17
GOLANGCI_LINT_VERSION ?= v1.54.2
GOLANGCI_LINT_VERSION ?= v1.57.2

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (
"time"

//nolint:golint
// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
"runtime"
"testing"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

"k8s.io/client-go/kubernetes/scheme"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"fmt"
"testing"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"os/exec"
"time"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

"example.com/memcached/test/utils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os/exec"
"strings"

// nolint:revive
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1

import (
// nolint:revive
. "github.com/onsi/ginkgo/v2"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (
"testing"
"time"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

admissionv1 "k8s.io/api/admission/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (
"testing"
"time"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

admissionv1 "k8s.io/api/admission/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import (

ctrl "sigs.k8s.io/controller-runtime"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

"k8s.io/client-go/kubernetes/scheme"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"fmt"
"testing"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"os/exec"
"time"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

"tutorial.kubebuilder.io/project/test/utils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os/exec"
"strings"

// nolint:revive
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ import (
"reflect"
"time"
// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"
batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/alpha/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ using the current version of KubeBuilder binary available.
$ kubebuilder alpha generate --input-dir="./test" --output-dir="./my-output"
Then we will re-scaffold the project by Kubebuilder in the directory specified by 'output-dir'.
`,
PreRunE: func(cmd *cobra.Command, _ []string) error {
PreRunE: func(_ *cobra.Command, _ []string) error {
return opts.Validate()
},
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
if err := opts.Rescaffold(); err != nil {
log.Fatalf("Failed to rescaffold %s", err)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
"os"
"strings"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"
"github.com/spf13/afero"
"github.com/spf13/cobra"
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Linux:
MacOS:
$ %[1]s completion bash > /usr/local/etc/bash_completion.d/%[1]s
`, c.commandName),
RunE: func(cmd *cobra.Command, cmdArgs []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Root().GenBashCompletion(os.Stdout)
},
}
Expand All @@ -55,7 +55,7 @@ $ %[1]s completion zsh > "${fpath[1]}/_%[1]s"
# You will need to start a new shell for this setup to take effect.
`, c.commandName),
RunE: func(cmd *cobra.Command, cmdArgs []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Root().GenZshCompletion(os.Stdout)
},
}
Expand All @@ -71,7 +71,7 @@ $ %[1]s completion fish | source
# To load completions for each session, execute once:
$ %[1]s completion fish > ~/.config/fish/completions/%[1]s.fish
`, c.commandName),
RunE: func(cmd *cobra.Command, cmdArgs []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Root().GenFishCompletion(os.Stdout, true)
},
}
Expand All @@ -81,7 +81,7 @@ func (CLI) newPowerShellCmd() *cobra.Command {
return &cobra.Command{
Use: "powershell",
Short: "Load powershell completions",
RunE: func(cmd *cobra.Command, cmdArgs []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Root().GenPowerShellCompletion(os.Stdout)
},
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ limitations under the License.
package cli

import (
// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (c CLI) newInitCmd() *cobra.Command {
For further help about a specific plugin, set --plugins.
`,
Example: c.getInitHelpExamples(),
Run: func(cmd *cobra.Command, args []string) {},
Run: func(_ *cobra.Command, _ []string) {},
}

// Register --project-version on the dynamically created command
Expand Down
6 changes: 4 additions & 2 deletions pkg/cli/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (
"path/filepath"
"runtime"

// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"
"github.com/spf13/afero"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -383,7 +385,7 @@ var _ = Describe("Discover external plugins", func() {

It("should fail if pluginsroot is empty", func() {
errPluginsRoot := errors.New("could not retrieve plugins root")
retrievePluginsRoot = func(host string) (string, error) {
retrievePluginsRoot = func(_ string) (string, error) {
return "", errPluginsRoot
}

Expand All @@ -394,7 +396,7 @@ var _ = Describe("Discover external plugins", func() {
})

It("should skip parsing of directories if plugins root is not a directory", func() {
retrievePluginsRoot = func(host string) (string, error) {
retrievePluginsRoot = func(_ string) (string, error) {
return "externalplugin.sh", nil
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ limitations under the License.
package cli

import (
// nolint:revive
. "github.com/onsi/ginkgo/v2"
// nolint:revive
. "github.com/onsi/gomega"

"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
Expand Down
Loading

0 comments on commit a7f6e03

Please sign in to comment.