github.com/olljanat/moby@v1.13.1/cli/command/checkpoint/remove.go (about)

     1  package checkpoint
     2  
     3  import (
     4  	"golang.org/x/net/context"
     5  
     6  	"github.com/docker/docker/api/types"
     7  	"github.com/docker/docker/cli"
     8  	"github.com/docker/docker/cli/command"
     9  	"github.com/spf13/cobra"
    10  )
    11  
    12  type removeOptions struct {
    13  	checkpointDir string
    14  }
    15  
    16  func newRemoveCommand(dockerCli *command.DockerCli) *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(dockerCli, args[0], args[1], opts)
    26  		},
    27  	}
    28  
    29  	flags := cmd.Flags()
    30  	flags.StringVarP(&opts.checkpointDir, "checkpoint-dir", "", "", "Use a custom checkpoint storage directory")
    31  
    32  	return cmd
    33  }
    34  
    35  func runRemove(dockerCli *command.DockerCli, container string, checkpoint string, opts removeOptions) error {
    36  	client := dockerCli.Client()
    37  
    38  	removeOpts := types.CheckpointDeleteOptions{
    39  		CheckpointID:  checkpoint,
    40  		CheckpointDir: opts.checkpointDir,
    41  	}
    42  
    43  	return client.CheckpointDelete(context.Background(), container, removeOpts)
    44  }