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 d04d8be
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 55 deletions.
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
55 changes: 26 additions & 29 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 @@ -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
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
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,

Check failure on line 74 in pkg/util/csi/volume_snapshot.go

View workflow job for this annotation

GitHub Actions / Run Linter Check

File is not properly formatted (gofmt)
)
}

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
3 changes: 2 additions & 1 deletion pkg/util/kube/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
)

// Client knows how to perform CRUD operations on Kubernetes objects.
// go:generate mockery --name=Client
//
//go:generate mockery --name=Client
type Client interface {
client.Reader
client.Writer
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/kube/pvc_pv.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func WaitPVCBound(ctx context.Context, pvcGetter corev1client.CoreV1Interface,
err := wait.PollUntilContextTimeout(ctx, waitInternal, timeout, true, func(ctx context.Context) (bool, error) {
tmpPVC, err := pvcGetter.PersistentVolumeClaims(namespace).Get(ctx, pvc, metav1.GetOptions{})
if err != nil {
return false, errors.Wrapf(err, fmt.Sprintf("error to get pvc %s/%s", namespace, pvc))
return false, errors.Wrapf(err, "error to get pvc %s/%s", namespace, pvc)
}

if tmpPVC.Spec.VolumeName == "" {
Expand Down Expand Up @@ -318,7 +318,7 @@ func WaitPVBound(ctx context.Context, pvGetter corev1client.CoreV1Interface, pvN
err := wait.PollUntilContextTimeout(ctx, waitInternal, timeout, true, func(ctx context.Context) (bool, error) {
tmpPV, err := pvGetter.PersistentVolumes().Get(ctx, pvName, metav1.GetOptions{})
if err != nil {
return false, errors.Wrapf(err, fmt.Sprintf("failed to get pv %s", pvName))
return false, errors.Wrapf(err, "failed to get pv %s", pvName)
}

if tmpPV.Spec.ClaimRef == nil {
Expand Down

0 comments on commit d04d8be

Please sign in to comment.