Skip to content

Commit

Permalink
Merge pull request #4236 from camilamacedo86/upgrade-lint-v1-61
Browse files Browse the repository at this point in the history
✨ Upgrade golangci-lint from v1.59 to v1.61 and resolve new lint issues
  • Loading branch information
k8s-ci-robot authored Oct 29, 2024
2 parents f3de87c + ca02865 commit a86d73a
Show file tree
Hide file tree
Showing 28 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.61

yamllint:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ linters:
enable:
- dupl
- errcheck
- exportloopref
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
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.59.1 ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.61.0 ;\
}

.PHONY: apidiff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.61
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ linters:
enable:
- dupl
- errcheck
- exportloopref
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
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 @@ -177,7 +177,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
KUSTOMIZE_VERSION ?= v5.5.0
CONTROLLER_TOOLS_VERSION ?= v0.16.4
ENVTEST_VERSION ?= release-0.19
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.61.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.61
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ linters:
enable:
- dupl
- errcheck
- exportloopref
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
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 @@ -173,7 +173,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
KUSTOMIZE_VERSION ?= v5.5.0
CONTROLLER_TOOLS_VERSION ?= v0.16.4
ENVTEST_VERSION ?= release-0.19
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.61.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.61
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ linters:
enable:
- dupl
- errcheck
- exportloopref
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
KUSTOMIZE_VERSION ?= v5.5.0
CONTROLLER_TOOLS_VERSION ?= v0.16.4
ENVTEST_VERSION ?= release-0.19
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.61.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package cli

import (
"fmt"
"errors"
"strings"

"github.com/spf13/pflag"
Expand Down Expand Up @@ -53,13 +53,13 @@ func (opts resourceOptions) validate() error {
// NOTE: We must do this for all the required flags first or we may output the wrong
// error as flags may seem to be missing because Cobra assigned them to another flag.
if strings.HasPrefix(opts.Group, "-") {
return fmt.Errorf(groupPresent)
return errors.New(groupPresent)
}
if strings.HasPrefix(opts.Version, "-") {
return fmt.Errorf(versionPresent)
return errors.New(versionPresent)
}
if strings.HasPrefix(opts.Kind, "-") {
return fmt.Errorf(kindPresent)
return errors.New(kindPresent)
}

// We do not check here if the GVK values are empty because that would
Expand Down
7 changes: 4 additions & 3 deletions pkg/model/resource/gvk.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package resource

import (
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -44,7 +45,7 @@ type GVK struct {
func (gvk GVK) Validate() error {
// Check if the qualified group has a valid DNS1123 subdomain value
if gvk.QualifiedGroup() == "" {
return fmt.Errorf(groupRequired)
return errors.New(groupRequired)
}
if err := validation.IsDNS1123Subdomain(gvk.QualifiedGroup()); err != nil {
// NOTE: IsDNS1123Subdomain returns a slice of strings instead of an error, so no wrapping
Expand All @@ -53,7 +54,7 @@ func (gvk GVK) Validate() error {

// Check if the version follows the valid pattern
if gvk.Version == "" {
return fmt.Errorf(versionRequired)
return errors.New(versionRequired)
}
errs := validation.IsDNS1123Subdomain(gvk.Version)
if len(errs) > 0 && gvk.Version != versionInternal {
Expand All @@ -62,7 +63,7 @@ func (gvk GVK) Validate() error {

// Check if kind has a valid DNS1035 label value
if gvk.Kind == "" {
return fmt.Errorf(kindRequired)
return errors.New(kindRequired)
}
if errors := validation.IsDNS1035Label(strings.ToLower(gvk.Kind)); len(errors) != 0 {
// NOTE: IsDNS1035Label returns a slice of strings instead of an error, so no wrapping
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/external/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func makePluginRequest(req external.PluginRequest, path string) (*external.Plugi

// Error if the plugin failed.
if res.Error {
return nil, fmt.Errorf(strings.Join(res.ErrorMsgs, "\n"))
return nil, fmt.Errorf("%s", strings.Join(res.ErrorMsgs, "\n"))
}

return &res, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugins/golang/deploy-image/v1alpha1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ type createAPISubcommand struct {
}

func (p *createAPISubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
//nolint: lll
// nolint: lll
subcmdMeta.Description = `Scaffold the code implementation to deploy and manage your Operand which is represented by the API informed and will be reconciled by its controller. This plugin will generate the code implementation to help you out.
Note: In general, it’s recommended to have one controller responsible for managing each API created for the project to properly follow the design goals set by Controller Runtime(https://github.com/kubernetes-sigs/controller-runtime).
This plugin will work as the common behaviour of the flag --force and will scaffold the API and controller always. Use core types or external APIs is not officially support by default with.
`
//nolint: lll
// nolint: lll
subcmdMeta.Examples = fmt.Sprintf(` # Create a frigates API with Group: ship, Version: v1beta1, Kind: Frigate to represent the
Image: example.com/frigate:v0.0.1 and its controller with a code to deploy and manage this Operand.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.61
`
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ linters:
enable:
- dupl
- errcheck
- exportloopref
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
KUSTOMIZE_VERSION ?= {{ .KustomizeVersion }}
CONTROLLER_TOOLS_VERSION ?= {{ .ControllerToolsVersion }}
ENVTEST_VERSION ?= {{ .EnvtestVersion }}
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.61.0
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4-multigroup/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.61
2 changes: 1 addition & 1 deletion testdata/project-v4-multigroup/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ linters:
enable:
- dupl
- errcheck
- exportloopref
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4-multigroup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
KUSTOMIZE_VERSION ?= v5.5.0
CONTROLLER_TOOLS_VERSION ?= v0.16.4
ENVTEST_VERSION ?= release-0.19
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.61.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.61
2 changes: 1 addition & 1 deletion testdata/project-v4-with-plugins/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ linters:
enable:
- dupl
- errcheck
- exportloopref
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4-with-plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
KUSTOMIZE_VERSION ?= v5.5.0
CONTROLLER_TOOLS_VERSION ?= v0.16.4
ENVTEST_VERSION ?= release-0.19
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.61.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.61
2 changes: 1 addition & 1 deletion testdata/project-v4/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ linters:
enable:
- dupl
- errcheck
- exportloopref
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
KUSTOMIZE_VERSION ?= v5.5.0
CONTROLLER_TOOLS_VERSION ?= v0.16.4
ENVTEST_VERSION ?= release-0.19
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.61.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down

0 comments on commit a86d73a

Please sign in to comment.