mirror of
https://github.com/containers/podman.git
synced 2025-06-21 09:28:09 +08:00
podman wait accept args > 1
Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
This commit is contained in:
@ -23,7 +23,6 @@ var (
|
|||||||
Short: "Block on one or more containers",
|
Short: "Block on one or more containers",
|
||||||
Long: waitDescription,
|
Long: waitDescription,
|
||||||
RunE: wait,
|
RunE: wait,
|
||||||
Args: validate.IDOrLatestArgs,
|
|
||||||
Example: `podman wait --interval 5000 ctrID
|
Example: `podman wait --interval 5000 ctrID
|
||||||
podman wait ctrID1 ctrID2`,
|
podman wait ctrID1 ctrID2`,
|
||||||
}
|
}
|
||||||
@ -33,7 +32,6 @@ var (
|
|||||||
Short: waitCommand.Short,
|
Short: waitCommand.Short,
|
||||||
Long: waitCommand.Long,
|
Long: waitCommand.Long,
|
||||||
RunE: waitCommand.RunE,
|
RunE: waitCommand.RunE,
|
||||||
Args: validate.IDOrLatestArgs,
|
|
||||||
Example: `podman container wait --interval 5000 ctrID
|
Example: `podman container wait --interval 5000 ctrID
|
||||||
podman container wait ctrID1 ctrID2`,
|
podman container wait ctrID1 ctrID2`,
|
||||||
}
|
}
|
||||||
@ -76,6 +74,13 @@ func wait(cmd *cobra.Command, args []string) error {
|
|||||||
return errors.New("interval must be greater then 0")
|
return errors.New("interval must be greater then 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !waitOptions.Latest && len(args) == 0 {
|
||||||
|
return errors.Errorf("%q requires a name, id, or the \"--latest\" flag", cmd.CommandPath())
|
||||||
|
}
|
||||||
|
if waitOptions.Latest && len(args) > 0 {
|
||||||
|
return errors.New("--latest and containers are not allowed")
|
||||||
|
}
|
||||||
|
|
||||||
waitOptions.Condition, err = define.StringToContainerStatus(waitCondition)
|
waitOptions.Condition, err = define.StringToContainerStatus(waitCondition)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -4,14 +4,15 @@
|
|||||||
podman\-wait - Wait on one or more containers to stop and print their exit codes
|
podman\-wait - Wait on one or more containers to stop and print their exit codes
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
**podman wait** [*options*] *container*
|
**podman wait** [*options*] *container* [...]
|
||||||
|
|
||||||
**podman container wait** [*options*] *container*
|
**podman container wait** [*options*] *container* [...]
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
Waits on one or more containers to stop. The container can be referred to by its
|
Waits on one or more containers to stop. The container can be referred to by its
|
||||||
name or ID. In the case of multiple containers, podman will wait on each consecutively.
|
name or ID. In the case of multiple containers, Podman will wait on each consecutively.
|
||||||
After the container stops, the container's return code is printed.
|
After all specified containers are stopped, the containers' return codes are printed
|
||||||
|
separated by newline in the same order as they were given to the command.
|
||||||
|
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
@ -36,12 +37,17 @@ The latest option is not supported on the remote client.
|
|||||||
|
|
||||||
```
|
```
|
||||||
$ podman wait mywebserver
|
$ podman wait mywebserver
|
||||||
|
0
|
||||||
|
|
||||||
$ podman wait --latest
|
$ podman wait --latest
|
||||||
|
0
|
||||||
|
|
||||||
$ podman wait 860a4b23
|
$ podman wait 860a4b23
|
||||||
|
1
|
||||||
|
|
||||||
$ podman wait mywebserver myftpserver
|
$ podman wait mywebserver myftpserver
|
||||||
|
0
|
||||||
|
125
|
||||||
```
|
```
|
||||||
|
|
||||||
## SEE ALSO
|
## SEE ALSO
|
||||||
|
@ -64,6 +64,7 @@ var _ = Describe("Podman wait", func() {
|
|||||||
session = podmanTest.Podman([]string{"wait", "-l"})
|
session = podmanTest.Podman([]string{"wait", "-l"})
|
||||||
session.Wait(20)
|
session.Wait(20)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman container wait on latest container", func() {
|
It("podman container wait on latest container", func() {
|
||||||
session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"})
|
session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"})
|
||||||
session.Wait(20)
|
session.Wait(20)
|
||||||
@ -71,4 +72,23 @@ var _ = Describe("Podman wait", func() {
|
|||||||
session = podmanTest.Podman([]string{"container", "wait", "-l"})
|
session = podmanTest.Podman([]string{"container", "wait", "-l"})
|
||||||
session.Wait(20)
|
session.Wait(20)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman wait on three containers", func() {
|
||||||
|
session := podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"})
|
||||||
|
session.Wait(20)
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
cid1 := session.OutputToString()
|
||||||
|
session = podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"})
|
||||||
|
session.Wait(20)
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
cid2 := session.OutputToString()
|
||||||
|
session = podmanTest.Podman([]string{"run", "-d", ALPINE, "sleep", "1"})
|
||||||
|
session.Wait(20)
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
cid3 := session.OutputToString()
|
||||||
|
session = podmanTest.Podman([]string{"wait", cid1, cid2, cid3})
|
||||||
|
session.Wait(20)
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
Expect(session.OutputToStringArray()).To(Equal([]string{"0", "0", "0"}))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user