Skip to content

Commit

Permalink
Bump golangci-lint from v1.57.2 to v1.63.4
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 committed Jan 22, 2025
1 parent a9031eb commit 29874e2
Show file tree
Hide file tree
Showing 31 changed files with 82 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Codespell
uses: codespell-project/actions-codespell@master
with:
# ignore the config/.../crd.go file as it's generated binary data that is edited elswhere.
# ignore the config/.../crd.go file as it's generated binary data that is edited elsewhere.
skip: .git,*.png,*.jpg,*.woff,*.ttf,*.gif,*.ico,./config/crd/v1beta1/crds/crds.go,./config/crd/v1/crds/crds.go,./config/crd/v2alpha1/crds/crds.go,./go.sum,./LICENSE
ignore_words_list: iam,aks,ist,bridget,ue,shouldnot,atleast,notin,sme,optin
check_filenames: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-linter-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
- name: Linter check
uses: golangci/golangci-lint-action@v6
with:
version: v1.57.2
version: v1.63.4
args: --verbose
57 changes: 27 additions & 30 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ run:
# exit code when at least one issue was found, default is 1
issues-exit-code: 1


# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
Expand Down Expand Up @@ -46,12 +41,16 @@ output:
# print linter name in the end of issue text, default is true
print-linter-name: true

# make issues output unique by line, default is true
uniq-by-line: true


# all available settings of specific linters
linters-settings:
depguard:
list-type: blacklist # Velero.io word list : ignore
include-go-root: false
packages:
- github.com/sirupsen/logrus
packages-with-error-message:
# specify an error message to output when a denylisted package is used
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
dogsled:
# checks assignments with too many blank identifiers; default is 2
max-blank-identifiers: 2
Expand Down Expand Up @@ -160,6 +159,9 @@ linters-settings:
# - github.com/mitchellh/go-homedir: # Blocked module with version constraint
# version: "< 1.1.0" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
gosec:
excludes:
- G115
govet:
# report about shadowed variables
# check-shadowing: true
Expand All @@ -180,14 +182,6 @@ linters-settings:
disable:
- shadow
disable-all: false
depguard:
list-type: blacklist # Velero.io word list : ignore
include-go-root: false
packages:
- github.com/sirupsen/logrus
packages-with-error-message:
# specify an error message to output when a denylisted package is used
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
Expand Down Expand Up @@ -333,7 +327,7 @@ linters-settings:
force-case-trailing-whitespace: 0
# Force cuddling of err checks with err var assignment
force-err-cuddling: false
# Allow leading comments to be separated with empty liens
# Allow leading comments to be separated with empty lines
allow-separated-leading-comment: false

linters:
Expand All @@ -343,11 +337,11 @@ linters:
- asciicheck
- bidichk
- bodyclose
- copyloopvar
- dogsled
- durationcheck
- dupword
- errcheck
- exportloopref
- errchkjson
- goconst
- gofmt
Expand Down Expand Up @@ -380,8 +374,16 @@ linters:
- whitespace
fast: false


issues:
# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
exclude-dirs:
- pkg/plugin/generated/*

exclude-rules:
- linters:
- staticcheck
Expand Down Expand Up @@ -425,17 +427,12 @@ issues:
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

# Show only new issues created after git revision `REV`
# new-from-rev: origin/main
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
exclude-dirs:
- pkg/plugin/generated/*
# make issues output unique by line, default is true
uniq-by-line: true

severity:
# Default value is empty string.
Expand Down
2 changes: 1 addition & 1 deletion hack/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ RUN ARCH=$(go env GOARCH) && \
chmod +x /usr/bin/goreleaser

# get golangci-lint
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.57.2
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.63.4

# install kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/$(go env GOARCH)/kubectl
Expand Down
5 changes: 2 additions & 3 deletions internal/delete/actions/csi/volumesnapshot_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package csi

import (
"context"
"fmt"

snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
"github.com/pkg/errors"
Expand Down Expand Up @@ -89,8 +88,8 @@ func (p *volumeSnapshotDeleteItemAction) Execute(
if err != nil && !apierrors.IsNotFound(err) {
return errors.Wrapf(
err,
fmt.Sprintf("failed to patch DeletionPolicy of volume snapshot %s/%s",
vs.Namespace, vs.Name),
"failed to patch DeletionPolicy of volume snapshot %s/%s",
vs.Namespace, vs.Name,
)
}

Expand Down
5 changes: 2 additions & 3 deletions internal/delete/actions/csi/volumesnapshotcontent_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package csi

import (
"context"
"fmt"

snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
"github.com/pkg/errors"
Expand Down Expand Up @@ -93,9 +92,9 @@ func (p *volumeSnapshotContentDeleteItemAction) Execute(
snapCont.Name, input.Backup.Name, *snapCont.Status.SnapshotHandle)
return nil
}
return errors.Wrapf(err, fmt.Sprintf(
return errors.Wrapf(err,
"failed to set DeletionPolicy on volumesnapshotcontent %s. Skipping deletion",
snapCont.Name))
snapCont.Name)
}

if err := p.crClient.Delete(
Expand Down
2 changes: 0 additions & 2 deletions internal/resourcepolicies/volume_resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func TestParseCapacity(t *testing.T) {
}

for _, test := range tests {
test := test // capture range variable
t.Run(test.input, func(t *testing.T) {
actual, actualErr := parseCapacity(test.input)
if test.expected != emptyCapacity {
Expand Down Expand Up @@ -79,7 +78,6 @@ func TestCapacityIsInRange(t *testing.T) {
}

for _, test := range tests {
test := test // capture range variable
t.Run(fmt.Sprintf("%v with %v", test.capacity, test.quantity), func(t *testing.T) {
t.Parallel()

Expand Down
3 changes: 1 addition & 2 deletions internal/storage/storagelocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package storage

import (
"context"
"fmt"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -98,7 +97,7 @@ func GetDefaultBackupStorageLocations(ctx context.Context, kbClient client.Clien
locations := new(velerov1api.BackupStorageLocationList)
defaultLocations := new(velerov1api.BackupStorageLocationList)
if err := kbClient.List(context.Background(), locations, &client.ListOptions{Namespace: namespace}); err != nil {
return defaultLocations, errors.Wrapf(err, fmt.Sprintf("failed to list backup storage locations in namespace %s", namespace))
return defaultLocations, errors.Wrapf(err, "failed to list backup storage locations in namespace %s", namespace)
}

for _, location := range locations.Items {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/util/downloadrequest/downloadrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func download(
if err != nil {
if urlErr, ok := err.(*url.Error); ok {
if _, ok := urlErr.Err.(x509.UnknownAuthorityError); ok {
return fmt.Errorf(err.Error() + "\n\nThe --insecure-skip-tls-verify flag can also be used to accept any TLS certificate for the download, but it is susceptible to man-in-the-middle attacks.")
return fmt.Errorf("%s\n\nThe --insecure-skip-tls-verify flag can also be used to accept any TLS certificate for the download, but it is susceptible to man-in-the-middle attacks", err.Error())
}
}
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/backup_deletion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ func (r *backupDeletionReconciler) deleteMovedSnapshots(ctx context.Context, bac
directSnapshots := map[string][]repotypes.SnapshotIdentifier{}
for i := range list.Items {
cm := list.Items[i]
if cm.Data == nil || len(cm.Data) == 0 {
if len(cm.Data) == 0 {
errs = append(errs, errors.New("no snapshot info in config"))
continue
}
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/backup_sync_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,6 @@ var _ = Describe("Backup Sync Reconciler", func() {
},
}
for _, test := range testCases {
test := test
It(test.name, func() {
logger := velerotest.NewLogger()
b := backupSyncReconciler{
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/data_download_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,12 @@ func TestDataDownloadReconcile(t *testing.T) {
}
if test.dd.Namespace == velerov1api.DefaultNamespace {
if controllerutil.ContainsFinalizer(test.dd, DataUploadDownloadFinalizer) {
assert.True(t, true, apierrors.IsNotFound(err))
assert.True(t, apierrors.IsNotFound(err))
} else {
require.NoError(t, err)
}
} else {
assert.True(t, true, apierrors.IsNotFound(err))
assert.True(t, apierrors.IsNotFound(err))
}

if !test.needCreateFSBR {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/restore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,10 @@ func (r *restoreReconciler) validateAndComplete(restore *api.Restore) (backupInf
}
resourceModifiers, err = resourcemodifiers.GetResourceModifiersFromConfig(ResourceModifierConfigMap)
if err != nil {
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, errors.Wrapf(err, fmt.Sprintf("Error in parsing resource modifiers provided in configmap %s/%s", restore.Namespace, restore.Spec.ResourceModifier.Name)).Error())
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, errors.Wrapf(err, "Error in parsing resource modifiers provided in configmap %s/%s", restore.Namespace, restore.Spec.ResourceModifier.Name).Error())
return backupInfo{}, nil
} else if err = resourceModifiers.Validate(); err != nil {
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, errors.Wrapf(err, fmt.Sprintf("Validation error in resource modifiers provided in configmap %s/%s", restore.Namespace, restore.Spec.ResourceModifier.Name)).Error())
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, errors.Wrapf(err, "Validation error in resource modifiers provided in configmap %s/%s", restore.Namespace, restore.Spec.ResourceModifier.Name).Error())
return backupInfo{}, nil
}
r.logger.Infof("Retrieved Resource modifiers provided in configmap %s/%s", restore.Namespace, restore.Spec.ResourceModifier.Name)
Expand Down
9 changes: 5 additions & 4 deletions pkg/restore/actions/csi/pvc_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,18 +503,19 @@ func restoreFromVolumeSnapshot(
vs,
); err != nil {
return errors.Wrapf(err,
fmt.Sprintf("Failed to get Volumesnapshot %s/%s to restore PVC %s/%s",
newNamespace, volumeSnapshotName, newNamespace, pvc.Name),
"Failed to get Volumesnapshot %s/%s to restore PVC %s/%s",
newNamespace, volumeSnapshotName, newNamespace, pvc.Name,
)
}

if _, exists := vs.Annotations[velerov1api.VolumeSnapshotRestoreSize]; exists {
restoreSize, err := resource.ParseQuantity(
vs.Annotations[velerov1api.VolumeSnapshotRestoreSize])
if err != nil {
return errors.Wrapf(err, fmt.Sprintf(
return errors.Wrapf(err,
"Failed to parse %s from annotation on Volumesnapshot %s/%s into restore size",
vs.Annotations[velerov1api.VolumeSnapshotRestoreSize], vs.Namespace, vs.Name))
vs.Annotations[velerov1api.VolumeSnapshotRestoreSize], vs.Namespace, vs.Name,
)
}
// It is possible that the volume provider allocated a larger
// capacity volume than what was requested in the backed up PVC.
Expand Down
7 changes: 3 additions & 4 deletions pkg/restore/actions/csi/volumesnapshot_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,13 @@ func TestResetVolumeSnapshotSpecForRestore(t *testing.T) {
before := tc.vs.DeepCopy()
resetVolumeSnapshotSpecForRestore(&tc.vs, &tc.vscName)

assert.Equalf(t, tc.vs.Name, before.Name, "unexpected change to Object.Name, Want: %s; Got %s", tc.name, before.Name, tc.vs.Name)
assert.Equal(t, tc.vs.Namespace, before.Namespace, "unexpected change to Object.Namespace, Want: %s; Got %s", tc.name, before.Namespace, tc.vs.Namespace)
assert.Equal(t, tc.vs.Name, before.Name, "unexpected change to Object.Name")
assert.Equal(t, tc.vs.Namespace, before.Namespace, "unexpected change to Object.Namespace")
assert.NotNil(t, tc.vs.Spec.Source)
assert.Nil(t, tc.vs.Spec.Source.PersistentVolumeClaimName)
assert.NotNil(t, tc.vs.Spec.Source.VolumeSnapshotContentName)
assert.Equal(t, *tc.vs.Spec.Source.VolumeSnapshotContentName, tc.vscName)
assert.Equal(t, *tc.vs.Spec.VolumeSnapshotClassName, *before.Spec.VolumeSnapshotClassName, "unexpected value for Spec.VolumeSnapshotClassName, Want: %s, Got: %s",
*tc.vs.Spec.VolumeSnapshotClassName, *before.Spec.VolumeSnapshotClassName)
assert.Equal(t, *tc.vs.Spec.VolumeSnapshotClassName, *before.Spec.VolumeSnapshotClassName, "unexpected value for Spec.VolumeSnapshotClassName")
assert.Nil(t, tc.vs.Status)
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/test/fake_discovery_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (di *FakeServerResourcesInterface) ServerPreferredResources() ([]*metav1.AP
if di.ReturnError != nil {
return di.ResourceList, di.ReturnError
}
if di.FailedGroups == nil || len(di.FailedGroups) == 0 {
if len(di.FailedGroups) == 0 {
return di.ResourceList, nil
}
return di.ResourceList, &discovery.ErrGroupDiscoveryFailed{Groups: di.FailedGroups}
Expand All @@ -168,7 +168,7 @@ func (di *FakeServerResourcesInterface) ServerGroupsAndResources() ([]*metav1.AP
if di.ReturnError != nil {
return di.APIGroup, di.ResourceList, di.ReturnError
}
if di.FailedGroups == nil || len(di.FailedGroups) == 0 {
if len(di.FailedGroups) == 0 {
return di.APIGroup, di.ResourceList, nil
}
return di.APIGroup, di.ResourceList, &discovery.ErrGroupDiscoveryFailed{Groups: di.FailedGroups}
Expand Down
18 changes: 9 additions & 9 deletions pkg/util/csi/volume_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func WaitVolumeSnapshotReady(
if err != nil {
return false, errors.Wrapf(
err,
fmt.Sprintf("error to get VolumeSnapshot %s/%s",
volumeSnapshotNS, volumeSnapshot),
"error to get VolumeSnapshot %s/%s",
volumeSnapshotNS, volumeSnapshot,
)
}

Expand Down Expand Up @@ -175,7 +175,7 @@ func EnsureDeleteVS(ctx context.Context, snapshotClient snapshotter.SnapshotV1In
return true, nil
}

return false, errors.Wrapf(err, fmt.Sprintf("error to get VolumeSnapshot %s", vsName))
return false, errors.Wrapf(err, "error to get VolumeSnapshot %s", vsName)
}

updated = vs
Expand Down Expand Up @@ -234,7 +234,7 @@ func EnsureDeleteVSC(ctx context.Context, snapshotClient snapshotter.SnapshotV1I
return true, nil
}

return false, errors.Wrapf(err, fmt.Sprintf("error to get VolumeSnapshotContent %s", vscName))
return false, errors.Wrapf(err, "error to get VolumeSnapshotContent %s", vscName)
}

updated = vsc
Expand Down Expand Up @@ -632,7 +632,7 @@ func recreateVolumeSnapshotContent(
}
return false, errors.Wrapf(
err,
fmt.Sprintf("failed to get VolumeSnapshotContent %s", vsc.Name),
"failed to get VolumeSnapshotContent %s", vsc.Name,
)
}
return false, nil
Expand Down Expand Up @@ -715,9 +715,9 @@ func WaitUntilVSCHandleIsReady(
vs,
); err != nil {
return false,
errors.Wrapf(err, fmt.Sprintf(
errors.Wrapf(err,
"failed to get volumesnapshot %s/%s",
volSnap.Namespace, volSnap.Name),
volSnap.Namespace, volSnap.Name,
)
}

Expand All @@ -737,8 +737,8 @@ func WaitUntilVSCHandleIsReady(
return false,
errors.Wrapf(
err,
fmt.Sprintf("failed to get VolumeSnapshotContent %s for VolumeSnapshot %s/%s",
*vs.Status.BoundVolumeSnapshotContentName, vs.Namespace, vs.Name),
"failed to get VolumeSnapshotContent %s for VolumeSnapshot %s/%s",
*vs.Status.BoundVolumeSnapshotContentName, vs.Namespace, vs.Name,
)
}

Expand Down
Loading

0 comments on commit 29874e2

Please sign in to comment.