@@ -28,9 +28,9 @@ import (
2828 "github.com/containerd/containerd/cmd/ctr/commands"
2929 "github.com/containerd/containerd/cmd/ctr/commands/run"
3030 "github.com/containerd/containerd/containers"
31+ "github.com/containerd/containerd/errdefs"
3132 "github.com/containerd/containerd/log"
3233 "github.com/containerd/typeurl"
33- "github.com/pkg/errors"
3434 "github.com/urfave/cli"
3535)
3636
@@ -65,17 +65,17 @@ var createCommand = cli.Command{
6565 if config {
6666 id = context .Args ().First ()
6767 if context .NArg () > 1 {
68- return errors . New ( "with spec config file, only container id should be provided" )
68+ return errdefs . ErrArgConfigFile
6969 }
7070 } else {
7171 id = context .Args ().Get (1 )
7272 ref = context .Args ().First ()
7373 if ref == "" {
74- return errors . New ( "image ref must be provided" )
74+ return errdefs . ErrUnprovidedImageRef
7575 }
7676 }
7777 if id == "" {
78- return errors . New ( "container id must be provided" )
78+ return errdefs . ErrEmptyContainerId
7979 }
8080 client , ctx , cancel , err := commands .NewClient (context )
8181 if err != nil {
@@ -168,7 +168,7 @@ var deleteCommand = cli.Command{
168168 }
169169
170170 if context .NArg () == 0 {
171- return errors . New ( "must specify at least one container to delete" )
171+ return errdefs . ErrDeleteNoneContainer
172172 }
173173 for _ , arg := range context .Args () {
174174 if err := deleteContainer (ctx , client , arg , deleteOpts ... ); err != nil {
@@ -214,7 +214,7 @@ var setLabelsCommand = cli.Command{
214214 Action : func (context * cli.Context ) error {
215215 containerID , labels := commands .ObjectWithLabelArgs (context )
216216 if containerID == "" {
217- return errors . New ( "container id must be provided" )
217+ return errdefs . ErrEmptyContainerId
218218 }
219219 client , ctx , cancel , err := commands .NewClient (context )
220220 if err != nil {
@@ -250,7 +250,7 @@ var infoCommand = cli.Command{
250250 Action : func (context * cli.Context ) error {
251251 id := context .Args ().First ()
252252 if id == "" {
253- return errors . New ( "container id must be provided" )
253+ return errdefs . ErrEmptyContainerId
254254 }
255255 client , ctx , cancel , err := commands .NewClient (context )
256256 if err != nil {
0 commit comments