Merge pull request #7929 from Iceber/ctr_run
ctr/run: flags --detach and --rm cannot be specified together
This commit is contained in:
commit
54ec1919f3
@ -93,7 +93,7 @@ var Command = cli.Command{
|
|||||||
Flags: append([]cli.Flag{
|
Flags: append([]cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "rm",
|
Name: "rm",
|
||||||
Usage: "remove the container after running",
|
Usage: "remove the container after running, cannot be used with --detach",
|
||||||
},
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "null-io",
|
Name: "null-io",
|
||||||
@ -105,7 +105,7 @@ var Command = cli.Command{
|
|||||||
},
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "detach,d",
|
Name: "detach,d",
|
||||||
Usage: "detach from the task after it has started execution",
|
Usage: "detach from the task after it has started execution, cannot be used with --rm",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "fifo-dir",
|
Name: "fifo-dir",
|
||||||
@ -132,6 +132,7 @@ var Command = cli.Command{
|
|||||||
id string
|
id string
|
||||||
ref string
|
ref string
|
||||||
|
|
||||||
|
rm = context.Bool("rm")
|
||||||
tty = context.Bool("tty")
|
tty = context.Bool("tty")
|
||||||
detach = context.Bool("detach")
|
detach = context.Bool("detach")
|
||||||
config = context.IsSet("config")
|
config = context.IsSet("config")
|
||||||
@ -154,6 +155,10 @@ var Command = cli.Command{
|
|||||||
if id == "" {
|
if id == "" {
|
||||||
return errors.New("container id must be provided")
|
return errors.New("container id must be provided")
|
||||||
}
|
}
|
||||||
|
if rm && detach {
|
||||||
|
return errors.New("flags --detach and --rm cannot be specified together")
|
||||||
|
}
|
||||||
|
|
||||||
client, ctx, cancel, err := commands.NewClient(context)
|
client, ctx, cancel, err := commands.NewClient(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -163,7 +168,7 @@ var Command = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if context.Bool("rm") && !detach {
|
if rm && !detach {
|
||||||
defer container.Delete(ctx, containerd.WithSnapshotCleanup)
|
defer container.Delete(ctx, containerd.WithSnapshotCleanup)
|
||||||
}
|
}
|
||||||
var con console.Console
|
var con console.Console
|
||||||
|
Loading…
Reference in New Issue
Block a user