From 18ba01d44de926280a90e24e1bdc4e4894b478c9 Mon Sep 17 00:00:00 2001 From: Yadong Ding Date: Tue, 13 Feb 2024 12:56:50 +0800 Subject: [PATCH 1/2] chore: bump golangci-lint-action v4 Signed-off-by: Yadong Ding --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2da76a80c..1a4c878f0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,9 +23,9 @@ jobs: go-version-file: 'go.mod' cache-dependency-path: "go.sum" - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: - version: v1.55.2 + version: v1.56.1 skip-cache: true - name: Build run: | From 730b88b38e20f87fd0b624190179f02f248fb532 Mon Sep 17 00:00:00 2001 From: Yadong Ding Date: Tue, 13 Feb 2024 13:04:36 +0800 Subject: [PATCH 2/2] lint: fix error with golanglint-ci v1.56.1 Signed-off-by: Yadong Ding --- cmd/containerd-nydus-grpc/main.go | 2 +- cmd/optimizer-nri-plugin/main.go | 2 +- cmd/prefetchfiles-nri-plugin/main.go | 2 +- internal/logging/setup_test.go | 2 +- pkg/auth/kubesecret.go | 2 +- pkg/converter/convert_unix.go | 2 +- pkg/daemon/client_test.go | 2 +- pkg/remote/remote.go | 2 +- pkg/system/system.go | 6 +++--- pkg/utils/retry/retry.go | 2 +- pkg/utils/transport/pool_test.go | 2 +- snapshot/snapshot.go | 4 ++-- tests/converter_test.go | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cmd/containerd-nydus-grpc/main.go b/cmd/containerd-nydus-grpc/main.go index 3128609a5a..535a1637a9 100644 --- a/cmd/containerd-nydus-grpc/main.go +++ b/cmd/containerd-nydus-grpc/main.go @@ -30,7 +30,7 @@ func main() { Version: version.Version, Flags: flags.F, HideVersion: true, - Action: func(c *cli.Context) error { + Action: func(_ *cli.Context) error { if flags.Args.PrintVersion { fmt.Println("Version: ", version.Version) fmt.Println("Revision: ", version.Revision) diff --git a/cmd/optimizer-nri-plugin/main.go b/cmd/optimizer-nri-plugin/main.go index 13c51dffb9..6b3f13b366 100644 --- a/cmd/optimizer-nri-plugin/main.go +++ b/cmd/optimizer-nri-plugin/main.go @@ -229,7 +229,7 @@ func main() { Version: version.Version, Flags: flags.F, HideVersion: true, - Action: func(c *cli.Context) error { + Action: func(_ *cli.Context) error { var ( opts []stub.Option err error diff --git a/cmd/prefetchfiles-nri-plugin/main.go b/cmd/prefetchfiles-nri-plugin/main.go index 2cfdc73712..b338a5bfbf 100644 --- a/cmd/prefetchfiles-nri-plugin/main.go +++ b/cmd/prefetchfiles-nri-plugin/main.go @@ -140,7 +140,7 @@ func main() { Version: version.Version, Flags: flags.Flag, HideVersion: true, - Action: func(c *cli.Context) error { + Action: func(_ *cli.Context) error { var ( opts []stub.Option err error diff --git a/internal/logging/setup_test.go b/internal/logging/setup_test.go index a28a23f02a..f6bb724908 100644 --- a/internal/logging/setup_test.go +++ b/internal/logging/setup_test.go @@ -25,7 +25,7 @@ const ( func GetRotateLogFileNumbers(testLogDir string, suffix string) int { i := 0 - err := filepath.Walk(testLogDir, func(fname string, fi os.FileInfo, err error) error { + err := filepath.Walk(testLogDir, func(fname string, fi os.FileInfo, _ error) error { if !fi.IsDir() && strings.HasSuffix(fname, suffix) { i++ } diff --git a/pkg/auth/kubesecret.go b/pkg/auth/kubesecret.go index 9073a178df..dc7c451b14 100644 --- a/pkg/auth/kubesecret.go +++ b/pkg/auth/kubesecret.go @@ -125,7 +125,7 @@ func (kubelistener *KubeSecretListener) SyncKubeSecrets(ctx context.Context, cli return } }, - UpdateFunc: func(old, new interface{}) { + UpdateFunc: func(_, new interface{}) { key, err := cache.MetaNamespaceKeyFunc(new) if err != nil { logrus.WithError(err).Errorf("failed to get key for secret from cache") diff --git a/pkg/converter/convert_unix.go b/pkg/converter/convert_unix.go index 9cbc2a9036..2583cd0542 100644 --- a/pkg/converter/convert_unix.go +++ b/pkg/converter/convert_unix.go @@ -108,7 +108,7 @@ func unpackOciTar(ctx context.Context, dst string, reader io.Reader) error { ctx, dst, ds, - archive.WithConvertWhiteout(func(hdr *tar.Header, file string) (bool, error) { + archive.WithConvertWhiteout(func(_ *tar.Header, _ string) (bool, error) { // Keep to extract all whiteout files. return true, nil }), diff --git a/pkg/daemon/client_test.go b/pkg/daemon/client_test.go index 1566dcd5ae..954ff1e7bc 100644 --- a/pkg/daemon/client_test.go +++ b/pkg/daemon/client_test.go @@ -37,7 +37,7 @@ func prepareNydusServer(t *testing.T) (string, func()) { if err == nil { _ = os.Remove(mockSocket) } - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(200) info := types.DaemonInfo{ ID: "testid", diff --git a/pkg/remote/remote.go b/pkg/remote/remote.go index 193bfbe30d..cbcd0a08b7 100644 --- a/pkg/remote/remote.go +++ b/pkg/remote/remote.go @@ -78,7 +78,7 @@ func New(keyChain *auth.PassKeyChain, insecure bool) *Remote { ), ), docker.WithClient(newClient(insecure)), - docker.WithPlainHTTP(func(host string) (bool, error) { + docker.WithPlainHTTP(func(_ string) (bool, error) { return plainHTTP, nil }), ) diff --git a/pkg/system/system.go b/pkg/system/system.go index c255236bab..1c866d22ee 100644 --- a/pkg/system/system.go +++ b/pkg/system/system.go @@ -217,7 +217,7 @@ func (sc *Controller) getBackend() func(w http.ResponseWriter, r *http.Request) } func (sc *Controller) setPrefetchConfiguration() func(w http.ResponseWriter, r *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { + return func(_ http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) if err != nil { log.L.Errorf("Failed to read prefetch list: %v", err) @@ -231,7 +231,7 @@ func (sc *Controller) setPrefetchConfiguration() func(w http.ResponseWriter, r * } func (sc *Controller) describeDaemons() func(w http.ResponseWriter, r *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { info := make([]daemonInfo, 0, 10) for _, manager := range sc.managers { @@ -282,7 +282,7 @@ func (sc *Controller) describeDaemons() func(w http.ResponseWriter, r *http.Requ // TODO: Implement me! func (sc *Controller) getDaemonRecords() func(w http.ResponseWriter, r *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { m := newErrorMessage("not implemented") http.Error(w, m.encode(), http.StatusNotImplemented) } diff --git a/pkg/utils/retry/retry.go b/pkg/utils/retry/retry.go index 7dc017813d..c8f496b123 100644 --- a/pkg/utils/retry/retry.go +++ b/pkg/utils/retry/retry.go @@ -19,7 +19,7 @@ var ( DefaultAttempts = uint(10) DefaultDelay = 100 * time.Millisecond DefaultMaxJitter = 100 * time.Millisecond - DefaultOnRetry = func(n uint, err error) {} + DefaultOnRetry = func(_ uint, _ error) {} DefaultRetryIf = IsRecoverable DefaultDelayType = CombineDelay(FixedDelay, RandomDelay) DefaultLastErrorOnly = false diff --git a/pkg/utils/transport/pool_test.go b/pkg/utils/transport/pool_test.go index 4cd41793f0..601875ff05 100644 --- a/pkg/utils/transport/pool_test.go +++ b/pkg/utils/transport/pool_test.go @@ -41,7 +41,7 @@ func (t FakeReference) Scope(action string) string { func TestResolve(t *testing.T) { var callCount int failed := false - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { callCount++ if !failed { fmt.Fprintf(w, "ok") diff --git a/snapshot/snapshot.go b/snapshot/snapshot.go index c2e7f43523..f829d3132c 100644 --- a/snapshot/snapshot.go +++ b/snapshot/snapshot.go @@ -708,13 +708,13 @@ func (o *snapshotter) workPath(id string) string { } func (o *snapshotter) findReferrerLayer(ctx context.Context, key string) (string, snapshots.Info, error) { - return snapshot.IterateParentSnapshots(ctx, o.ms, key, func(id string, info snapshots.Info) bool { + return snapshot.IterateParentSnapshots(ctx, o.ms, key, func(_ string, info snapshots.Info) bool { return o.fs.CheckReferrer(ctx, info.Labels) }) } func (o *snapshotter) findMetaLayer(ctx context.Context, key string) (string, snapshots.Info, error) { - return snapshot.IterateParentSnapshots(ctx, o.ms, key, func(id string, i snapshots.Info) bool { + return snapshot.IterateParentSnapshots(ctx, o.ms, key, func(_ string, i snapshots.Info) bool { return label.IsNydusMetaLayer(i.Labels) }) } diff --git a/tests/converter_test.go b/tests/converter_test.go index ded911ea64..bb4baf81a8 100644 --- a/tests/converter_test.go +++ b/tests/converter_test.go @@ -443,7 +443,7 @@ func buildChunkDict(t *testing.T, workDir, fsVersion string, n int) (string, str require.Equal(t, []digest.Digest{lowerNydusBlobDigest}, blobDigests) dictBlobPath := "" - err = filepath.WalkDir(blobDir, func(path string, entry fs.DirEntry, err error) error { + err = filepath.WalkDir(blobDir, func(path string, _ fs.DirEntry, err error) error { require.NoError(t, err) if path == blobDir { return nil