diff --git a/.github/workflows/static.yaml b/.github/workflows/static.yaml index dcb7c407e9..ff59ae1b9f 100644 --- a/.github/workflows/static.yaml +++ b/.github/workflows/static.yaml @@ -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 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000000..a7102ad339 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,12 @@ +linters-settings: + depguard: + rules: + main: + files: + - $all + - "!$test" + allow: + - $gostd + - k8s.io + - sigs.k8s.io + - github.com diff --git a/pkg/util/util.go b/pkg/util/util.go index 34936d8e8c..aaa4529779 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -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) @@ -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 { diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index 56354f90f9..5d8af52686 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -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) }