Merge pull request #1306 from estesp/error-no-container
Delete command should require at least one container ID
This commit is contained in:
		| @@ -2,6 +2,7 @@ package main | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
|  | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  |  | ||||||
| 	"github.com/containerd/containerd" | 	"github.com/containerd/containerd" | ||||||
| @@ -11,8 +12,8 @@ import ( | |||||||
|  |  | ||||||
| var containersDeleteCommand = cli.Command{ | var containersDeleteCommand = cli.Command{ | ||||||
| 	Name:      "delete", | 	Name:      "delete", | ||||||
| 	Usage:     "delete an existing container", | 	Usage:     "deletes one or more existing containers", | ||||||
| 	ArgsUsage: "CONTAINER", | 	ArgsUsage: "CONTAINER [CONTAINER, ...]", | ||||||
| 	Aliases:   []string{"del", "rm"}, | 	Aliases:   []string{"del", "rm"}, | ||||||
| 	Flags: []cli.Flag{ | 	Flags: []cli.Flag{ | ||||||
| 		cli.BoolFlag{ | 		cli.BoolFlag{ | ||||||
| @@ -33,6 +34,9 @@ var containersDeleteCommand = cli.Command{ | |||||||
| 			deleteOpts = append(deleteOpts, containerd.WithSnapshotCleanup) | 			deleteOpts = append(deleteOpts, containerd.WithSnapshotCleanup) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		if context.NArg() == 0 { | ||||||
|  | 			return errors.New("must specify at least one container to delete") | ||||||
|  | 		} | ||||||
| 		for _, arg := range context.Args() { | 		for _, arg := range context.Args() { | ||||||
| 			if err := deleteContainer(ctx, client, arg, deleteOpts...); err != nil { | 			if err := deleteContainer(ctx, client, arg, deleteOpts...); err != nil { | ||||||
| 				if exitErr == nil { | 				if exitErr == nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Crosby
					Michael Crosby