38 lines
949 B
Go
38 lines
949 B
Go
package checkpoint
|
|
|
|
import (
|
|
"github.com/docker/cli/cli"
|
|
"github.com/docker/cli/cli/command"
|
|
"github.com/moby/moby/client"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type removeOptions struct {
|
|
checkpointDir string
|
|
}
|
|
|
|
func newRemoveCommand(dockerCLI command.Cli) *cobra.Command {
|
|
var opts removeOptions
|
|
|
|
cmd := &cobra.Command{
|
|
Use: "rm [OPTIONS] CONTAINER CHECKPOINT",
|
|
Aliases: []string{"remove"},
|
|
Short: "Remove a checkpoint",
|
|
Args: cli.ExactArgs(2),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
containerID, checkpointID := args[0], args[1]
|
|
_, err := dockerCLI.Client().CheckpointRemove(cmd.Context(), containerID, client.CheckpointRemoveOptions{
|
|
CheckpointID: checkpointID,
|
|
CheckpointDir: opts.checkpointDir,
|
|
})
|
|
return err
|
|
},
|
|
DisableFlagsInUseLine: true,
|
|
}
|
|
|
|
flags := cmd.Flags()
|
|
flags.StringVar(&opts.checkpointDir, "checkpoint-dir", "", "Use a custom checkpoint storage directory")
|
|
|
|
return cmd
|
|
}
|