Add addProcess cli 'exec' command
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
21259f7fec
commit
288b9a0cc3
2 changed files with 59 additions and 9 deletions
|
@ -28,13 +28,13 @@ var ListCheckpointCommand = cli.Command{
|
||||||
|
|
||||||
func listCheckpoints(context *cli.Context) {
|
func listCheckpoints(context *cli.Context) {
|
||||||
var (
|
var (
|
||||||
cli = getClient()
|
c = getClient()
|
||||||
id = context.Args().First()
|
id = context.Args().First()
|
||||||
)
|
)
|
||||||
if id == "" {
|
if id == "" {
|
||||||
fatal("container id cannot be empty", 1)
|
fatal("container id cannot be empty", 1)
|
||||||
}
|
}
|
||||||
resp, err := cli.ListCheckpoint(netcontext.Background(), &types.ListCheckpointRequest{
|
resp, err := c.ListCheckpoint(netcontext.Background(), &types.ListCheckpointRequest{
|
||||||
Id: id,
|
Id: id,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -82,8 +82,8 @@ var CreateCheckpointCommand = cli.Command{
|
||||||
if name == "" {
|
if name == "" {
|
||||||
fatal("checkpoint name cannot be empty", 1)
|
fatal("checkpoint name cannot be empty", 1)
|
||||||
}
|
}
|
||||||
cli := getClient()
|
c := getClient()
|
||||||
if _, err := cli.CreateCheckpoint(netcontext.Background(), &types.CreateCheckpointRequest{
|
if _, err := c.CreateCheckpoint(netcontext.Background(), &types.CreateCheckpointRequest{
|
||||||
Id: containerID,
|
Id: containerID,
|
||||||
Checkpoint: &types.Checkpoint{
|
Checkpoint: &types.Checkpoint{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
@ -108,8 +108,8 @@ var DeleteCheckpointCommand = cli.Command{
|
||||||
if name == "" {
|
if name == "" {
|
||||||
fatal("checkpoint name cannot be empty", 1)
|
fatal("checkpoint name cannot be empty", 1)
|
||||||
}
|
}
|
||||||
cli := getClient()
|
c := getClient()
|
||||||
if _, err := cli.DeleteCheckpoint(netcontext.Background(), &types.DeleteCheckpointRequest{
|
if _, err := c.DeleteCheckpoint(netcontext.Background(), &types.DeleteCheckpointRequest{
|
||||||
Id: containerID,
|
Id: containerID,
|
||||||
Name: name,
|
Name: name,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|
|
@ -27,6 +27,7 @@ var ContainersCommand = cli.Command{
|
||||||
StartCommand,
|
StartCommand,
|
||||||
ListCommand,
|
ListCommand,
|
||||||
KillCommand,
|
KillCommand,
|
||||||
|
ExecCommand,
|
||||||
},
|
},
|
||||||
Action: listContainers,
|
Action: listContainers,
|
||||||
}
|
}
|
||||||
|
@ -38,8 +39,8 @@ var ListCommand = cli.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func listContainers(context *cli.Context) {
|
func listContainers(context *cli.Context) {
|
||||||
cli := getClient()
|
c := getClient()
|
||||||
resp, err := cli.State(netcontext.Background(), &types.StateRequest{})
|
resp, err := c.State(netcontext.Background(), &types.StateRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err.Error(), 1)
|
fatal(err.Error(), 1)
|
||||||
}
|
}
|
||||||
|
@ -114,3 +115,52 @@ var KillCommand = cli.Command{
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ExecCommand = cli.Command{
|
||||||
|
Name: "exec",
|
||||||
|
Usage: "exec another process in an existing container",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "id",
|
||||||
|
Usage: "container id to add the process to",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "cwd",
|
||||||
|
Usage: "current working directory for the process",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "tty,t",
|
||||||
|
Usage: "create a terminal for the process",
|
||||||
|
},
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
Name: "env,e",
|
||||||
|
Value: &cli.StringSlice{},
|
||||||
|
Usage: "environment variables for the process",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "uid,u",
|
||||||
|
Usage: "user id of the user for the process",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "gid,g",
|
||||||
|
Usage: "group id of the user for the process",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: func(context *cli.Context) {
|
||||||
|
p := &types.AddProcessRequest{
|
||||||
|
Args: context.Args(),
|
||||||
|
Cwd: context.String("cwd"),
|
||||||
|
Terminal: context.Bool("tty"),
|
||||||
|
Id: context.String("id"),
|
||||||
|
Env: context.StringSlice("env"),
|
||||||
|
User: &types.User{
|
||||||
|
Uid: uint32(context.Int("uid")),
|
||||||
|
Gid: uint32(context.Int("gid")),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
c := getClient()
|
||||||
|
if _, err := c.AddProcess(netcontext.Background(), p); err != nil {
|
||||||
|
fatal(err.Error(), 1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue