2016-05-12 10:52:00 -04:00
|
|
|
package checkpoint
|
|
|
|
|
|
|
|
import (
|
2018-05-03 21:02:44 -04:00
|
|
|
"context"
|
2016-05-12 10:52:00 -04:00
|
|
|
|
2017-04-17 18:07:56 -04:00
|
|
|
"github.com/docker/cli/cli"
|
|
|
|
"github.com/docker/cli/cli/command"
|
2023-08-28 06:06:35 -04:00
|
|
|
"github.com/docker/docker/api/types/checkpoint"
|
2016-05-12 10:52:00 -04:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2016-09-19 12:01:16 -04:00
|
|
|
type removeOptions struct {
|
|
|
|
checkpointDir string
|
|
|
|
}
|
|
|
|
|
2017-05-03 17:58:52 -04:00
|
|
|
func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
|
2016-09-19 12:01:16 -04:00
|
|
|
var opts removeOptions
|
|
|
|
|
|
|
|
cmd := &cobra.Command{
|
2016-11-08 03:15:09 -05:00
|
|
|
Use: "rm [OPTIONS] CONTAINER CHECKPOINT",
|
2016-05-12 10:52:00 -04:00
|
|
|
Aliases: []string{"remove"},
|
|
|
|
Short: "Remove a checkpoint",
|
|
|
|
Args: cli.ExactArgs(2),
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2023-09-09 18:27:44 -04:00
|
|
|
return runRemove(cmd.Context(), dockerCli, args[0], args[1], opts)
|
2016-05-12 10:52:00 -04:00
|
|
|
},
|
|
|
|
}
|
2016-09-19 12:01:16 -04:00
|
|
|
|
|
|
|
flags := cmd.Flags()
|
2024-01-29 05:16:14 -05:00
|
|
|
flags.StringVar(&opts.checkpointDir, "checkpoint-dir", "", "Use a custom checkpoint storage directory")
|
2016-09-19 12:01:16 -04:00
|
|
|
|
|
|
|
return cmd
|
2016-05-12 10:52:00 -04:00
|
|
|
}
|
|
|
|
|
2023-09-09 18:27:44 -04:00
|
|
|
func runRemove(ctx context.Context, dockerCli command.Cli, container string, checkpointID string, opts removeOptions) error {
|
|
|
|
return dockerCli.Client().CheckpointDelete(ctx, container, checkpoint.DeleteOptions{
|
2023-08-28 06:06:35 -04:00
|
|
|
CheckpointID: checkpointID,
|
2016-09-19 12:01:16 -04:00
|
|
|
CheckpointDir: opts.checkpointDir,
|
2023-08-28 06:06:35 -04:00
|
|
|
})
|
2016-05-12 10:52:00 -04:00
|
|
|
}
|