Skip to content

Commit 6cdfb55

Browse files
authored
Merge pull request #1586 from k8s-infra-cherrypick-robot/cherry-pick-1575-to-release-1.29
[release-1.29] test: upgrade golangci/golangci-lint-action to v1.54
2 parents 8a4e906 + 920ddbc commit 6cdfb55

File tree

21 files changed

+71
-68
lines changed

21 files changed

+71
-68
lines changed

.github/workflows/static.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ jobs:
1515
- name: Run linter
1616
uses: golangci/golangci-lint-action@v3
1717
with:
18-
version: v1.51
19-
args: -E=gofmt,deadcode,unused,varcheck,ineffassign,revive,misspell,exportloopref,asciicheck,bodyclose,depguard,dogsled,dupl,durationcheck,errname,forbidigo -D=staticcheck --timeout=30m0s
18+
version: v1.54
19+
args: -E=gofmt,unused,ineffassign,revive,misspell,exportloopref,asciicheck,bodyclose,depguard,dogsled,dupl,durationcheck,errname,forbidigo -D=staticcheck --timeout=30m0s

.golangci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
linters-settings:
2+
depguard:
3+
rules:
4+
main:
5+
files:
6+
- $all
7+
- "!$test"
8+
allow:
9+
- $gostd
10+
- k8s.io
11+
- sigs.k8s.io
12+
- github.com

pkg/azurefile/azure_common_linux.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ func SMBMount(m *mount.SafeFormatAndMount, source, target, fsType string, option
3333
return m.MountSensitive(source, target, fsType, options, sensitiveMountOptions)
3434
}
3535

36-
func CleanupMountPoint(m *mount.SafeFormatAndMount, target string, extensiveMountCheck bool) error {
36+
func CleanupMountPoint(m *mount.SafeFormatAndMount, target string, _ bool) error {
3737
return mount.CleanupMountPoint(target, m.Interface, true /*extensiveMountPointCheck*/)
3838
}
3939

40-
func preparePublishPath(path string, m *mount.SafeFormatAndMount) error {
40+
func preparePublishPath(_ string, _ *mount.SafeFormatAndMount) error {
4141
return nil
4242
}
4343

44-
func prepareStagePath(path string, m *mount.SafeFormatAndMount) error {
44+
func prepareStagePath(_ string, _ *mount.SafeFormatAndMount) error {
4545
return nil
4646
}
4747

4848
// GetVolumeStats returns volume stats based on the given path.
49-
func GetVolumeStats(path string, enableWindowsHostProcess bool) (*csi.NodeGetVolumeStatsResponse, error) {
49+
func GetVolumeStats(path string, _ bool) (*csi.NodeGetVolumeStatsResponse, error) {
5050
volumeMetrics, err := volume.NewMetricsStatFS(path).GetMetrics()
5151
if err != nil {
5252
return nil, status.Errorf(codes.Internal, "failed to get metrics: %v", err)

pkg/azurefile/azurefile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,8 @@ func (d *Driver) ResizeFileShare(ctx context.Context, subsID, resourceGroup, acc
903903
})
904904
}
905905

906-
// CopyFileShare copies a fileshare in the same storage account
907-
func (d *Driver) copyFileShare(ctx context.Context, req *csi.CreateVolumeRequest, accountKey string, shareOptions *fileclient.ShareOptions, storageEndpointSuffix string) error {
906+
// copyFileShare copies a fileshare in the same storage account
907+
func (d *Driver) copyFileShare(req *csi.CreateVolumeRequest, accountKey string, shareOptions *fileclient.ShareOptions, storageEndpointSuffix string) error {
908908
if shareOptions.Protocol == storage.EnabledProtocolsNFS {
909909
return fmt.Errorf("protocol nfs is not supported for volume cloning")
910910
}

pkg/azurefile/controllerserver.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
575575
if err != nil {
576576
return nil, status.Errorf(codes.Internal, "failed to GetStorageAccesskey on account(%s) rg(%s), error: %v", accountOptions.Name, accountOptions.ResourceGroup, err)
577577
}
578-
if err := d.copyVolume(ctx, req, accountKeyCopy, shareOptions, storageEndpointSuffix); err != nil {
578+
if err := d.copyVolume(req, accountKeyCopy, shareOptions, storageEndpointSuffix); err != nil {
579579
return nil, err
580580
}
581581
// storeAccountKey is not needed here since copy volume is only using SAS token
@@ -725,13 +725,14 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
725725
return &csi.DeleteVolumeResponse{}, nil
726726
}
727727

728-
func (d *Driver) copyVolume(ctx context.Context, req *csi.CreateVolumeRequest, accountKey string, shareOptions *fileclient.ShareOptions, storageEndpointSuffix string) error {
728+
// copyVolume copy an azure file
729+
func (d *Driver) copyVolume(req *csi.CreateVolumeRequest, accountKey string, shareOptions *fileclient.ShareOptions, storageEndpointSuffix string) error {
729730
vs := req.VolumeContentSource
730731
switch vs.Type.(type) {
731732
case *csi.VolumeContentSource_Snapshot:
732733
return status.Errorf(codes.InvalidArgument, "copy volume from volumeSnapshot is not supported")
733734
case *csi.VolumeContentSource_Volume:
734-
return d.copyFileShare(ctx, req, accountKey, shareOptions, storageEndpointSuffix)
735+
return d.copyFileShare(req, accountKey, shareOptions, storageEndpointSuffix)
735736
default:
736737
return status.Errorf(codes.InvalidArgument, "%v is not a proper volume source", vs)
737738
}
@@ -783,19 +784,19 @@ func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.Valida
783784
}
784785

785786
// ControllerGetCapabilities returns the capabilities of the Controller plugin
786-
func (d *Driver) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) {
787+
func (d *Driver) ControllerGetCapabilities(_ context.Context, _ *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) {
787788
return &csi.ControllerGetCapabilitiesResponse{
788789
Capabilities: d.Cap,
789790
}, nil
790791
}
791792

792793
// GetCapacity returns the capacity of the total available storage pool
793-
func (d *Driver) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) {
794+
func (d *Driver) GetCapacity(_ context.Context, _ *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) {
794795
return nil, status.Error(codes.Unimplemented, "")
795796
}
796797

797798
// ListVolumes return all available volumes
798-
func (d *Driver) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) {
799+
func (d *Driver) ListVolumes(_ context.Context, _ *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) {
799800
return nil, status.Error(codes.Unimplemented, "")
800801
}
801802

@@ -1083,7 +1084,7 @@ func (d *Driver) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequ
10831084
}
10841085

10851086
// ListSnapshots list all snapshots (todo)
1086-
func (d *Driver) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) {
1087+
func (d *Driver) ListSnapshots(_ context.Context, _ *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) {
10871088
return nil, status.Error(codes.Unimplemented, "")
10881089
}
10891090

pkg/azurefile/controllerserver_test.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,10 +1646,9 @@ func TestCopyVolume(t *testing.T) {
16461646
}
16471647

16481648
d := NewFakeDriver()
1649-
ctx := context.Background()
16501649

16511650
expectedErr := status.Errorf(codes.InvalidArgument, "copy volume from volumeSnapshot is not supported")
1652-
err := d.copyVolume(ctx, req, "", nil, "core.windows.net")
1651+
err := d.copyVolume(req, "", nil, "core.windows.net")
16531652
if !reflect.DeepEqual(err, expectedErr) {
16541653
t.Errorf("Unexpected error: %v", err)
16551654
}
@@ -1679,10 +1678,9 @@ func TestCopyVolume(t *testing.T) {
16791678
}
16801679

16811680
d := NewFakeDriver()
1682-
ctx := context.Background()
16831681

16841682
expectedErr := fmt.Errorf("protocol nfs is not supported for volume cloning")
1685-
err := d.copyVolume(ctx, req, "", &fileclient.ShareOptions{Protocol: storage.EnabledProtocolsNFS}, "core.windows.net")
1683+
err := d.copyVolume(req, "", &fileclient.ShareOptions{Protocol: storage.EnabledProtocolsNFS}, "core.windows.net")
16861684
if !reflect.DeepEqual(err, expectedErr) {
16871685
t.Errorf("Unexpected error: %v", err)
16881686
}
@@ -1712,10 +1710,9 @@ func TestCopyVolume(t *testing.T) {
17121710
}
17131711

17141712
d := NewFakeDriver()
1715-
ctx := context.Background()
17161713

17171714
expectedErr := status.Errorf(codes.NotFound, "error parsing volume id: \"unit-test\", should at least contain two #")
1718-
err := d.copyVolume(ctx, req, "", &fileclient.ShareOptions{Name: "dstFileshare"}, "core.windows.net")
1715+
err := d.copyVolume(req, "", &fileclient.ShareOptions{Name: "dstFileshare"}, "core.windows.net")
17191716
if !reflect.DeepEqual(err, expectedErr) {
17201717
t.Errorf("Unexpected error: %v", err)
17211718
}
@@ -1745,10 +1742,9 @@ func TestCopyVolume(t *testing.T) {
17451742
}
17461743

17471744
d := NewFakeDriver()
1748-
ctx := context.Background()
17491745

17501746
expectedErr := fmt.Errorf("srcFileShareName() or dstFileShareName(dstFileshare) is empty")
1751-
err := d.copyVolume(ctx, req, "", &fileclient.ShareOptions{Name: "dstFileshare"}, "core.windows.net")
1747+
err := d.copyVolume(req, "", &fileclient.ShareOptions{Name: "dstFileshare"}, "core.windows.net")
17521748
if !reflect.DeepEqual(err, expectedErr) {
17531749
t.Errorf("Unexpected error: %v", err)
17541750
}
@@ -1778,10 +1774,9 @@ func TestCopyVolume(t *testing.T) {
17781774
}
17791775

17801776
d := NewFakeDriver()
1781-
ctx := context.Background()
17821777

17831778
expectedErr := fmt.Errorf("srcFileShareName(fileshare) or dstFileShareName() is empty")
1784-
err := d.copyVolume(ctx, req, "", &fileclient.ShareOptions{}, "core.windows.net")
1779+
err := d.copyVolume(req, "", &fileclient.ShareOptions{}, "core.windows.net")
17851780
if !reflect.DeepEqual(err, expectedErr) {
17861781
t.Errorf("Unexpected error: %v", err)
17871782
}
@@ -1822,10 +1817,8 @@ func TestCopyVolume(t *testing.T) {
18221817

18231818
d.azcopy.ExecCmd = m
18241819

1825-
ctx := context.Background()
1826-
18271820
var expectedErr error
1828-
err := d.copyVolume(ctx, req, "", &fileclient.ShareOptions{Name: "dstFileshare"}, "core.windows.net")
1821+
err := d.copyVolume(req, "", &fileclient.ShareOptions{Name: "dstFileshare"}, "core.windows.net")
18291822
if !reflect.DeepEqual(err, expectedErr) {
18301823
t.Errorf("Unexpected error: %v", err)
18311824
}
@@ -1867,10 +1860,8 @@ func TestCopyVolume(t *testing.T) {
18671860

18681861
d.azcopy.ExecCmd = m
18691862

1870-
ctx := context.Background()
1871-
18721863
var expectedErr error
1873-
err := d.copyVolume(ctx, req, "", &fileclient.ShareOptions{Name: "dstFileshare"}, "core.windows.net")
1864+
err := d.copyVolume(req, "", &fileclient.ShareOptions{Name: "dstFileshare"}, "core.windows.net")
18741865
if !reflect.DeepEqual(err, expectedErr) {
18751866
t.Errorf("Unexpected error: %v", err)
18761867
}

pkg/azurefile/fake_mounter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type fakeMounter struct {
3030
}
3131

3232
// Mount overrides mount.FakeMounter.Mount.
33-
func (f *fakeMounter) Mount(source string, target string, fstype string, options []string) error {
33+
func (f *fakeMounter) Mount(source string, target string, _ string, _ []string) error {
3434
if strings.Contains(source, "error_mount") {
3535
return fmt.Errorf("fake Mount: source error")
3636
} else if strings.Contains(target, "error_mount") {
@@ -41,7 +41,7 @@ func (f *fakeMounter) Mount(source string, target string, fstype string, options
4141
}
4242

4343
// MountSensitive overrides mount.FakeMounter.MountSensitive.
44-
func (f *fakeMounter) MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
44+
func (f *fakeMounter) MountSensitive(source string, target string, _ string, _ []string, _ []string) error {
4545
if strings.Contains(source, "error_mount_sens") {
4646
return fmt.Errorf("fake MountSensitive: source error")
4747
} else if strings.Contains(target, "error_mount_sens") {

pkg/azurefile/identityserver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
// GetPluginInfo return the version and name of the plugin
30-
func (f *Driver) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
30+
func (f *Driver) GetPluginInfo(_ context.Context, _ *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
3131
if f.Name == "" {
3232
return nil, status.Error(codes.Unavailable, "Driver name not configured")
3333
}
@@ -46,12 +46,12 @@ func (f *Driver) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoReques
4646
// This method does not need to return anything.
4747
// Currently the spec does not dictate what you should return either.
4848
// Hence, return an empty response
49-
func (f *Driver) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) {
49+
func (f *Driver) Probe(_ context.Context, _ *csi.ProbeRequest) (*csi.ProbeResponse, error) {
5050
return &csi.ProbeResponse{Ready: &wrappers.BoolValue{Value: true}}, nil
5151
}
5252

5353
// GetPluginCapabilities returns the capabilities of the plugin
54-
func (f *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
54+
func (f *Driver) GetPluginCapabilities(_ context.Context, _ *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
5555
return &csi.GetPluginCapabilitiesResponse{
5656
Capabilities: []*csi.PluginCapability{
5757
{

pkg/azurefile/nodeserver.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
120120
}
121121

122122
// NodeUnpublishVolume unmount the volume from the target path
123-
func (d *Driver) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
123+
func (d *Driver) NodeUnpublishVolume(_ context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
124124
if len(req.GetVolumeId()) == 0 {
125125
return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request")
126126
}
@@ -382,7 +382,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
382382
}
383383

384384
// NodeUnstageVolume unmount the volume from the staging path
385-
func (d *Driver) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) {
385+
func (d *Driver) NodeUnstageVolume(_ context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) {
386386
volumeID := req.GetVolumeId()
387387
if len(volumeID) == 0 {
388388
return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request")
@@ -420,21 +420,21 @@ func (d *Driver) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolu
420420
}
421421

422422
// NodeGetCapabilities return the capabilities of the Node plugin
423-
func (d *Driver) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
423+
func (d *Driver) NodeGetCapabilities(_ context.Context, _ *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
424424
return &csi.NodeGetCapabilitiesResponse{
425425
Capabilities: d.NSCap,
426426
}, nil
427427
}
428428

429429
// NodeGetInfo return info of the node on which this plugin is running
430-
func (d *Driver) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
430+
func (d *Driver) NodeGetInfo(_ context.Context, _ *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
431431
return &csi.NodeGetInfoResponse{
432432
NodeId: d.NodeID,
433433
}, nil
434434
}
435435

436436
// NodeGetVolumeStats get volume stats
437-
func (d *Driver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
437+
func (d *Driver) NodeGetVolumeStats(_ context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
438438
if len(req.VolumeId) == 0 {
439439
return nil, status.Error(codes.InvalidArgument, "NodeGetVolumeStats volume ID was empty")
440440
}
@@ -513,7 +513,7 @@ func (d *Driver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeS
513513

514514
// NodeExpandVolume node expand volume
515515
// N/A for azure file
516-
func (d *Driver) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) {
516+
func (d *Driver) NodeExpandVolume(_ context.Context, _ *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) {
517517
return nil, status.Error(codes.Unimplemented, "")
518518
}
519519

pkg/azurefile/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ func (l *VolumeMounter) CanMount() error {
197197
return nil
198198
}
199199

200-
func (l *VolumeMounter) SetUp(mounterArgs volume.MounterArgs) error {
200+
func (l *VolumeMounter) SetUp(_ volume.MounterArgs) error {
201201
return nil
202202
}
203203

204-
func (l *VolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs) error {
204+
func (l *VolumeMounter) SetUpAt(_ string, _ volume.MounterArgs) error {
205205
return nil
206206
}
207207

0 commit comments

Comments
 (0)