2017-01-12 18:15:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
gocontext "context"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/docker/containerd/api/execution"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var deleteCommand = cli.Command{
|
2017-01-25 06:16:13 +00:00
|
|
|
Name: "delete",
|
|
|
|
Usage: "delete a process from containerd store",
|
|
|
|
ArgsUsage: "CONTAINER",
|
2017-01-12 18:15:27 +00:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "pid, p",
|
2017-01-25 06:16:13 +00:00
|
|
|
Usage: "process id to be deleted",
|
2017-01-12 18:15:27 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Action: func(context *cli.Context) error {
|
|
|
|
executionService, err := getExecutionService(context)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
id := context.Args().First()
|
|
|
|
if id == "" {
|
|
|
|
return fmt.Errorf("container id must be provided")
|
|
|
|
}
|
|
|
|
|
|
|
|
pid := context.String("pid")
|
|
|
|
if pid != "" {
|
|
|
|
_, err = executionService.DeleteProcess(gocontext.Background(), &execution.DeleteProcessRequest{
|
|
|
|
ContainerID: id,
|
|
|
|
ProcessID: pid,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := executionService.Delete(gocontext.Background(), &execution.DeleteContainerRequest{
|
|
|
|
ID: id,
|
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|