Move specific errors to their respective packages

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2019-07-15 20:21:11 +00:00
parent abc152d14c
commit 61d930ad5b
9 changed files with 118 additions and 37 deletions

View File

@@ -28,7 +28,6 @@ import (
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/cmd/ctr/commands/run"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
"github.com/containerd/typeurl"
"github.com/urfave/cli"
@@ -65,17 +64,17 @@ var createCommand = cli.Command{
if config {
id = context.Args().First()
if context.NArg() > 1 {
return errdefs.ErrArgConfigFile
return commands.ErrArgConfigFile
}
} else {
id = context.Args().Get(1)
ref = context.Args().First()
if ref == "" {
return errdefs.ErrUnprovidedImageRef
return commands.ErrUnprovidedImageRef
}
}
if id == "" {
return errdefs.ErrEmptyContainerID
return commands.ErrEmptyContainerID
}
client, ctx, cancel, err := commands.NewClient(context)
if err != nil {
@@ -168,7 +167,7 @@ var deleteCommand = cli.Command{
}
if context.NArg() == 0 {
return errdefs.ErrDeleteNoneContainer
return commands.ErrDeleteNoneContainer
}
for _, arg := range context.Args() {
if err := deleteContainer(ctx, client, arg, deleteOpts...); err != nil {
@@ -214,7 +213,7 @@ var setLabelsCommand = cli.Command{
Action: func(context *cli.Context) error {
containerID, labels := commands.ObjectWithLabelArgs(context)
if containerID == "" {
return errdefs.ErrEmptyContainerID
return commands.ErrEmptyContainerID
}
client, ctx, cancel, err := commands.NewClient(context)
if err != nil {
@@ -250,7 +249,7 @@ var infoCommand = cli.Command{
Action: func(context *cli.Context) error {
id := context.Args().First()
if id == "" {
return errdefs.ErrEmptyContainerID
return commands.ErrEmptyContainerID
}
client, ctx, cancel, err := commands.NewClient(context)
if err != nil {