Skip to content

Commit

Permalink
upgrade golangci/golangci-lint-action to v1.54
Browse files Browse the repository at this point in the history
  • Loading branch information
umagnus committed Nov 20, 2023
1 parent cd1f2b1 commit 728f85f
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
- name: Run linter
uses: golangci/golangci-lint-action@v3
with:
version: v1.51
version: v1.54
args: -E=gofmt,deadcode,unused,varcheck,ineffassign,revive,misspell,exportloopref,asciicheck,bodyclose,depguard,dogsled,dupl,durationcheck,errname,forbidigo -D=staticcheck --timeout=30m0s
12 changes: 12 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
linters-settings:
depguard:
rules:
main:
files:
- $all
- "!$test"
allow:
- $gostd
- k8s.io
- sigs.k8s.io
- github.com
2 changes: 1 addition & 1 deletion pkg/azurefileplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func exportMetrics() {
serve(context.Background(), l, serveMetrics)
}

func serve(ctx context.Context, l net.Listener, serveFunc func(net.Listener) error) {
func serve(_ context.Context, l net.Listener, serveFunc func(net.Listener) error) {
path := l.Addr().String()
klog.V(2).Infof("set up prometheus server on %v", path)
go func() {
Expand Down
6 changes: 3 additions & 3 deletions pkg/csi-common/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ func TestNewNonBlockingGRPCServer(t *testing.T) {
assert.NotNil(t, s)
}

func TestStart(t *testing.T) {
func TestStart(_ *testing.T) {
s := NewNonBlockingGRPCServer()
// sleep a while to avoid race condition in unit test
time.Sleep(time.Millisecond * 500)
s.Start("tcp://127.0.0.1:0", nil, nil, nil, true)
time.Sleep(time.Millisecond * 500)
}

func TestServe(t *testing.T) {
func TestServe(_ *testing.T) {
s := nonBlockingGRPCServer{}
s.server = grpc.NewServer()
s.wg = sync.WaitGroup{}
Expand All @@ -47,7 +47,7 @@ func TestServe(t *testing.T) {
s.serve("tcp://127.0.0.1:0", nil, nil, nil, true)
}

func TestWait(t *testing.T) {
func TestWait(_ *testing.T) {
s := nonBlockingGRPCServer{}
s.server = grpc.NewServer()
s.wg = sync.WaitGroup{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/mounter/safe_mounter_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
utilexec "k8s.io/utils/exec"
)

func NewSafeMounter(enableWindowsHostProcess bool) (*mount.SafeFormatAndMount, error) {
func NewSafeMounter(_ bool) (*mount.SafeFormatAndMount, error) {
return &mount.SafeFormatAndMount{
Interface: mount.New(""),
Exec: utilexec.New(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/os/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func PathExists(path string) (bool, error) {
return pathExists(path)
}

func PathValid(ctx context.Context, path string) (bool, error) {
func PathValid(_ context.Context, path string) (bool, error) {
cmd := `Test-Path $Env:remotepath`
cmdEnv := fmt.Sprintf("remotepath=%s", path)
output, err := util.RunPowershellCmd(cmd, cmdEnv)
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (ac *Azcopy) GetAzcopyJob(dstFileshare string) (AzcopyJobState, string, err
klog.Warningf("failed to get azcopy job with error: %v, jobState: %v", err, AzcopyJobError)
return AzcopyJobError, "", fmt.Errorf("couldn't list jobs in azcopy %v", err)
}
jobid, jobState, err := parseAzcopyJobList(out, dstFileshare)
jobid, jobState, err := parseAzcopyJobList(out)
if err != nil || jobState == AzcopyJobError {
klog.Warningf("failed to get azcopy job with error: %v, jobState: %v", err, jobState)
return AzcopyJobError, "", fmt.Errorf("couldn't parse azcopy job list in azcopy %v", err)
Expand All @@ -153,8 +153,8 @@ func (ac *Azcopy) GetAzcopyJob(dstFileshare string) (AzcopyJobState, string, err
return jobState, percent, nil
}

// parseAzcopyJobList parse command azcopy jobs list, get jobid and state from joblist containing dstFileShareName
func parseAzcopyJobList(joblist string, dstFileShareName string) (string, AzcopyJobState, error) {
// parseAzcopyJobList parse command azcopy jobs list, get jobid and state from joblist
func parseAzcopyJobList(joblist string) (string, AzcopyJobState, error) {
jobid := ""
jobSegments := strings.Split(joblist, "JobId: ")
if len(jobSegments) < 2 {
Expand Down
3 changes: 1 addition & 2 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ func TestParseAzcopyJobList(t *testing.T) {
}

for _, test := range tests {
dstFileShare := "dstFileShare"
jobid, jobState, err := parseAzcopyJobList(test.str, dstFileShare)
jobid, jobState, err := parseAzcopyJobList(test.str)
if jobid != test.expectedJobid || jobState != test.expectedJobState || !reflect.DeepEqual(err, test.expectedErr) {
t.Errorf("test[%s]: unexpected jobid: %v, jobState: %v, err: %v, expected jobid: %v, jobState: %v, err: %v", test.desc, jobid, jobState, err, test.expectedJobid, test.expectedJobState, test.expectedErr)
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/driver/azurefile_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func normalizeProvisioner(provisioner string) string {
return strings.ToLower(strings.ReplaceAll(provisioner, "/", "-"))
}

func (d *AzureFileDriver) GetDynamicProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, allowedTopologyValues []string, namespace string) *storagev1.StorageClass {
func (d *AzureFileDriver) GetDynamicProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, _ []string, namespace string) *storagev1.StorageClass {
provisioner := d.driverName
generateName := fmt.Sprintf("%s-%s-dynamic-sc-", namespace, normalizeProvisioner(provisioner))
return getStorageClass(generateName, provisioner, parameters, mountOptions, reclaimPolicy, bindingMode, nil)
}

func (d *AzureFileDriver) GetPreProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, allowedTopologyValues []string, namespace string) *storagev1.StorageClass {
func (d *AzureFileDriver) GetPreProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, _ []string, namespace string) *storagev1.StorageClass {
provisioner := d.driverName
generateName := fmt.Sprintf("%s-%s-pre-provisioned-sc-", namespace, provisioner)
return getStorageClass(generateName, provisioner, parameters, mountOptions, reclaimPolicy, bindingMode, nil)
Expand Down
4 changes: 2 additions & 2 deletions test/utils/azure/azure_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (az *Client) GetAzureFilesClient() (storage.FileSharesClient, error) {
return az.filesharesClient, nil
}

func (az *Client) EnsureSSHPublicKey(ctx context.Context, subscriptionID, resourceGroupName, location, keyName string) (publicKey string, err error) {
func (az *Client) EnsureSSHPublicKey(ctx context.Context, _, resourceGroupName, location, keyName string) (publicKey string, err error) {
_, err = az.sshPublicKeysClient.Create(ctx, resourceGroupName, keyName, compute.SSHPublicKeyResource{Location: &location})
if err != nil {
return "", err
Expand Down Expand Up @@ -313,7 +313,7 @@ func getCloudConfig(env azure.Environment) cloud.Configuration {
}
}

func getClient(env azure.Environment, subscriptionID, tenantID string, cred *azidentity.ClientSecretCredential, scope string) *Client {
func getClient(env azure.Environment, subscriptionID, _ string, cred *azidentity.ClientSecretCredential, scope string) *Client {
c := &Client{
environment: env,
subscriptionID: subscriptionID,
Expand Down

0 comments on commit 728f85f

Please sign in to comment.