feat: replace github.com/pkg/errors to errors

Signed-off-by: haoyun <yun.hao@daocloud.io>
Co-authored-by: zounengren <zouyee1989@gmail.com>
This commit is contained in:
haoyun
2022-01-07 10:19:31 +08:00
parent 3ccd43c8f6
commit bbe46b8c43
299 changed files with 1896 additions and 1874 deletions

View File

@@ -31,7 +31,6 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
"github.com/containerd/typeurl"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
@@ -66,17 +65,17 @@ var createCommand = cli.Command{
if config {
id = context.Args().First()
if context.NArg() > 1 {
return errors.Wrap(errdefs.ErrInvalidArgument, "with spec config file, only container id should be provided")
return fmt.Errorf("with spec config file, only container id should be provided: %w", errdefs.ErrInvalidArgument)
}
} else {
id = context.Args().Get(1)
ref = context.Args().First()
if ref == "" {
return errors.Wrap(errdefs.ErrInvalidArgument, "image ref must be provided")
return fmt.Errorf("image ref must be provided: %w", errdefs.ErrInvalidArgument)
}
}
if id == "" {
return errors.Wrap(errdefs.ErrInvalidArgument, "container id must be provided")
return fmt.Errorf("container id must be provided: %w", errdefs.ErrInvalidArgument)
}
client, ctx, cancel, err := commands.NewClient(context)
if err != nil {
@@ -169,7 +168,7 @@ var deleteCommand = cli.Command{
}
if context.NArg() == 0 {
return errors.Wrap(errdefs.ErrInvalidArgument, "must specify at least one container to delete")
return fmt.Errorf("must specify at least one container to delete: %w", errdefs.ErrInvalidArgument)
}
for _, arg := range context.Args() {
if err := deleteContainer(ctx, client, arg, deleteOpts...); err != nil {
@@ -215,7 +214,7 @@ var setLabelsCommand = cli.Command{
Action: func(context *cli.Context) error {
containerID, labels := commands.ObjectWithLabelArgs(context)
if containerID == "" {
return errors.Wrap(errdefs.ErrInvalidArgument, "container id must be provided")
return fmt.Errorf("container id must be provided: %w", errdefs.ErrInvalidArgument)
}
client, ctx, cancel, err := commands.NewClient(context)
if err != nil {
@@ -257,7 +256,7 @@ var infoCommand = cli.Command{
Action: func(context *cli.Context) error {
id := context.Args().First()
if id == "" {
return errors.Wrap(errdefs.ErrInvalidArgument, "container id must be provided")
return fmt.Errorf("container id must be provided: %w", errdefs.ErrInvalidArgument)
}
client, ctx, cancel, err := commands.NewClient(context)
if err != nil {