Skip to content

Commit

Permalink
nydusify: fix errors found by golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: Yadong Ding <ding_yadong@foxmail.com>
  • Loading branch information
Desiki-high committed Dec 14, 2023
1 parent bd89a9f commit 743b31f
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 30 deletions.
2 changes: 1 addition & 1 deletion contrib/nydusify/pkg/backend/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func calcCrc64ECMA(path string) (uint64, error) {

// Upload blob as image layer to oss backend and verify
// integrity by calculate CRC64.
func (b *OSSBackend) Upload(ctx context.Context, blobID, blobPath string, size int64, forcePush bool) (*ocispec.Descriptor, error) {
func (b *OSSBackend) Upload(_ context.Context, blobID, blobPath string, size int64, forcePush bool) (*ocispec.Descriptor, error) {
blobObjectKey := b.objectPrefix + blobID

desc := blobDesc(size, blobID)
Expand Down
12 changes: 6 additions & 6 deletions contrib/nydusify/pkg/backend/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Registry struct {
}

func (r *Registry) Upload(
ctx context.Context, blobID, blobPath string, size int64, forcePush bool,
ctx context.Context, blobID, blobPath string, size int64, _ bool,
) (*ocispec.Descriptor, error) {
// The `forcePush` option is useless for registry backend, because
// the blob existed in registry can't be pushed again.
Expand All @@ -35,26 +35,26 @@ func (r *Registry) Upload(
return &desc, nil
}

func (r *Registry) Finalize(cancel bool) error {
func (r *Registry) Finalize(_ bool) error {
return nil
}

func (r *Registry) Check(blobID string) (bool, error) {
func (r *Registry) Check(_ string) (bool, error) {
return true, nil
}

func (r *Registry) Type() Type {
return RegistryBackend
}

func (r *Registry) Reader(blobID string) (io.ReadCloser, error) {
func (r *Registry) Reader(_ string) (io.ReadCloser, error) {
panic("not implemented")
}

func (r *Registry) Size(blobID string) (int64, error) {
func (r *Registry) Size(_ string) (int64, error) {
panic("not implemented")
}

func newRegistryBackend(rawConfig []byte, remote *remote.Remote) (Backend, error) {
func newRegistryBackend(_ []byte, remote *remote.Remote) (Backend, error) {
return &Registry{remote: remote}, nil
}
6 changes: 1 addition & 5 deletions contrib/nydusify/pkg/checker/rule/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,5 @@ func (rule *FilesystemRule) Validate() error {
}
defer nydusd.Umount(false)

if err := rule.verify(); err != nil {
return err
}

return nil
return rule.verify()
}
6 changes: 1 addition & 5 deletions contrib/nydusify/pkg/checker/tool/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,5 @@ func (builder *Builder) Check(option BuilderOption) error {
cmd.Stdout = builder.stdout
cmd.Stderr = builder.stderr

if err := cmd.Run(); err != nil {
return err
}

return nil
return cmd.Run()
}
2 changes: 1 addition & 1 deletion contrib/nydusify/pkg/converter/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (pvd *Provider) Push(ctx context.Context, desc ocispec.Descriptor, ref stri
return push(ctx, pvd.store, rc, desc, ref)
}

func (pvd *Provider) Image(ctx context.Context, ref string) (*ocispec.Descriptor, error) {
func (pvd *Provider) Image(_ context.Context, ref string) (*ocispec.Descriptor, error) {
pvd.mutex.Lock()
defer pvd.mutex.Unlock()
if desc, ok := pvd.images[ref]; ok {
Expand Down
2 changes: 1 addition & 1 deletion contrib/nydusify/pkg/hook/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (p *Plugin) Server(*plugin.MuxBroker) (interface{}, error) {
return &RPCServer{Impl: p.Impl}, nil
}

func (Plugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error) {
func (Plugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error) {
return &RPC{client: c}, nil
}

Expand Down
6 changes: 3 additions & 3 deletions contrib/nydusify/pkg/packer/pusher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (m *mockBackend) Upload(ctx context.Context, blobID, blobPath string, blobS
return desc.(*ocispec.Descriptor), nil
}

func (m *mockBackend) Finalize(cancel bool) error {
func (m *mockBackend) Finalize(_ bool) error {
return nil
}

Expand All @@ -36,11 +36,11 @@ func (m *mockBackend) Type() backend.Type {
return backend.OssBackend
}

func (m *mockBackend) Reader(blobID string) (io.ReadCloser, error) {
func (m *mockBackend) Reader(_ string) (io.ReadCloser, error) {
panic("not implemented")
}

func (m *mockBackend) Size(blobID string) (int64, error) {
func (m *mockBackend) Size(_ string) (int64, error) {
panic("not implemented")
}

Expand Down
2 changes: 1 addition & 1 deletion contrib/nydusify/pkg/provider/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ProgressLogger interface {

type defaultLogger struct{}

func (logger *defaultLogger) Log(ctx context.Context, msg string, fields LoggerFields) func(err error) error {
func (logger *defaultLogger) Log(_ context.Context, msg string, fields LoggerFields) func(err error) error {
if fields == nil {
fields = make(LoggerFields)
}
Expand Down
6 changes: 3 additions & 3 deletions contrib/nydusify/pkg/provider/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ type defaultSourceLayer struct {
parentChainID *digest.Digest
}

func (sp *defaultSourceProvider) Manifest(ctx context.Context) (*ocispec.Descriptor, error) {
func (sp *defaultSourceProvider) Manifest(_ context.Context) (*ocispec.Descriptor, error) {
return &sp.image.Desc, nil
}

func (sp *defaultSourceProvider) Config(ctx context.Context) (*ocispec.Image, error) {
func (sp *defaultSourceProvider) Config(_ context.Context) (*ocispec.Image, error) {
return &sp.image.Config, nil
}

func (sp *defaultSourceProvider) Layers(ctx context.Context) ([]SourceLayer, error) {
func (sp *defaultSourceProvider) Layers(_ context.Context) ([]SourceLayer, error) {
layers := sp.image.Manifest.Layers
diffIDs := sp.image.Config.RootFS.DiffIDs
if len(layers) != len(diffIDs) {
Expand Down
2 changes: 0 additions & 2 deletions contrib/nydusify/pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ func UnpackFile(reader io.Reader, source, target string) error {
if err != nil {
if err == io.EOF {
break
} else {
return err
}
}
if hdr.Name == source {
Expand Down
4 changes: 2 additions & 2 deletions contrib/nydusify/plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
type LocalHook struct {
}

func (h *LocalHook) BeforePushManifest(info *hook.Info) error {
func (h *LocalHook) BeforePushManifest(_ *hook.Info) error {
return nil
}

func (h *LocalHook) AfterPushManifest(info *hook.Info) error {
func (h *LocalHook) AfterPushManifest(_ *hook.Info) error {
return nil
}

Expand Down

0 comments on commit 743b31f

Please sign in to comment.