Since go 1.7, "context" is a standard package. Since go 1.9, x/net/context merely provides some types aliased to those in the standard context package. The changes were performed by the following script: for f in $(git ls-files \*.go | grep -v ^vendor/); do sed -i 's|golang.org/x/net/context|context|' $f goimports -w $f for i in 1 2; do awk '/^$/ {e=1; next;} /\t"context"$/ {e=0;} {if (e) {print ""; e=0}; print;}' < $f > $f.new && \ mv $f.new $f goimports -w $f done done [v2: do awk/goimports fixup twice] Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package checkpoint
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/docker/cli/cli"
|
|
"github.com/docker/cli/cli/command"
|
|
"github.com/docker/docker/api/types"
|
|
"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 {
|
|
return runRemove(dockerCli, args[0], args[1], opts)
|
|
},
|
|
}
|
|
|
|
flags := cmd.Flags()
|
|
flags.StringVarP(&opts.checkpointDir, "checkpoint-dir", "", "", "Use a custom checkpoint storage directory")
|
|
|
|
return cmd
|
|
}
|
|
|
|
func runRemove(dockerCli command.Cli, container string, checkpoint string, opts removeOptions) error {
|
|
client := dockerCli.Client()
|
|
|
|
removeOpts := types.CheckpointDeleteOptions{
|
|
CheckpointID: checkpoint,
|
|
CheckpointDir: opts.checkpointDir,
|
|
}
|
|
|
|
return client.CheckpointDelete(context.Background(), container, removeOpts)
|
|
}
|