github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/cli/command/checkpoint/remove.go (about) 1 package checkpoint 2 3 import ( 4 "context" 5 6 "github.com/docker/docker/api/types/checkpoint" 7 "github.com/khulnasoft/cli/cli" 8 "github.com/khulnasoft/cli/cli/command" 9 "github.com/spf13/cobra" 10 ) 11 12 type removeOptions struct { 13 checkpointDir string 14 } 15 16 func newRemoveCommand(dockerCli command.Cli) *cobra.Command { 17 var opts removeOptions 18 19 cmd := &cobra.Command{ 20 Use: "rm [OPTIONS] CONTAINER CHECKPOINT", 21 Aliases: []string{"remove"}, 22 Short: "Remove a checkpoint", 23 Args: cli.ExactArgs(2), 24 RunE: func(cmd *cobra.Command, args []string) error { 25 return runRemove(cmd.Context(), dockerCli, args[0], args[1], opts) 26 }, 27 } 28 29 flags := cmd.Flags() 30 flags.StringVar(&opts.checkpointDir, "checkpoint-dir", "", "Use a custom checkpoint storage directory") 31 32 return cmd 33 } 34 35 func runRemove(ctx context.Context, dockerCli command.Cli, container string, checkpointID string, opts removeOptions) error { 36 return dockerCli.Client().CheckpointDelete(ctx, container, checkpoint.DeleteOptions{ 37 CheckpointID: checkpointID, 38 CheckpointDir: opts.checkpointDir, 39 }) 40 }