2017-01-12 18:15:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
gocontext "context"
|
2017-02-10 04:32:11 +00:00
|
|
|
"errors"
|
2017-01-12 18:15:27 +00:00
|
|
|
|
2017-02-09 07:31:26 +00:00
|
|
|
"github.com/docker/containerd/api/services/execution"
|
2017-01-12 18:15:27 +00:00
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var deleteCommand = cli.Command{
|
2017-01-25 06:16:13 +00:00
|
|
|
Name: "delete",
|
2017-02-13 18:23:28 +00:00
|
|
|
Usage: "delete an existing container",
|
2017-01-25 06:16:13 +00:00
|
|
|
ArgsUsage: "CONTAINER",
|
2017-01-12 18:15:27 +00:00
|
|
|
Action: func(context *cli.Context) error {
|
2017-02-13 18:23:28 +00:00
|
|
|
containers, err := getExecutionService(context)
|
2017-01-12 18:15:27 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
id := context.Args().First()
|
|
|
|
if id == "" {
|
2017-02-13 18:23:28 +00:00
|
|
|
return errors.New(" id must be provided")
|
2017-01-12 18:15:27 +00:00
|
|
|
}
|
2017-02-13 18:23:28 +00:00
|
|
|
_, err = containers.Delete(gocontext.Background(), &execution.DeleteRequest{
|
2017-01-12 18:15:27 +00:00
|
|
|
ID: id,
|
2017-02-13 18:23:28 +00:00
|
|
|
})
|
|
|
|
return err
|
2017-01-12 18:15:27 +00:00
|
|
|
},
|
|
|
|
}
|