-
Notifications
You must be signed in to change notification settings - Fork 13
/
checkpoint.go
53 lines (51 loc) · 1.05 KB
/
checkpoint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"github.com/crosbymichael/boss/api/v1"
"github.com/urfave/cli"
)
var checkpointCommand = cli.Command{
Name: "checkpoint",
Usage: "checkpoint a container",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "live",
Usage: "enable live checkpoint(criu must be installed)",
},
cli.BoolFlag{
Name: "exit",
Usage: "exit the container after a successful checkpoint",
},
cli.StringFlag{
Name: "ref",
Usage: "ref name of the created checkpoint",
},
cli.BoolFlag{
Name: "push",
Usage: "push the successful checkpoint",
},
},
Action: func(clix *cli.Context) error {
ctx := Context()
agent, err := Agent(clix)
if err != nil {
return err
}
defer agent.Close()
ref := clix.String("ref")
if _, err := agent.Checkpoint(ctx, &v1.CheckpointRequest{
ID: clix.Args().First(),
Ref: ref,
Live: clix.Bool("live"),
Exit: clix.Bool("exit"),
}); err != nil {
return err
}
if clix.Bool("push") {
_, err = agent.Push(ctx, &v1.PushRequest{
Ref: ref,
})
return err
}
return nil
},
}