mirror of
https://github.com/containers/podman
synced 2024-10-19 08:44:11 +00:00
podman wait accept args > 1
Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
This commit is contained in:
parent
fd7cdb2502
commit
685ef847dd
|
@ -23,7 +23,6 @@ var (
|
|||
Short: "Block on one or more containers",
|
||||
Long: waitDescription,
|
||||
RunE: wait,
|
||||
Args: validate.IDOrLatestArgs,
|
||||
Example: `podman wait --interval 5000 ctrID
|
||||
podman wait ctrID1 ctrID2`,
|
||||
}
|
||||
|
@ -33,7 +32,6 @@ var (
|
|||
Short: waitCommand.Short,
|
||||
Long: waitCommand.Long,
|
||||
RunE: waitCommand.RunE,
|
||||
Args: validate.IDOrLatestArgs,
|
||||
Example: `podman container wait --interval 5000 ctrID
|
||||
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")
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -4,14 +4,15 @@
|
|||
podman\-wait - Wait on one or more containers to stop and print their exit codes
|
||||
|
||||
## SYNOPSIS
|
||||
**podman wait** [*options*] *container*
|
||||
**podman wait** [*options*] *container* [...]
|
||||
|
||||
**podman container wait** [*options*] *container*
|
||||
**podman container wait** [*options*] *container* [...]
|
||||
|
||||
## DESCRIPTION
|
||||
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.
|
||||
After the container stops, the container's return code is printed.
|
||||
name or ID. In the case of multiple containers, Podman will wait on each consecutively.
|
||||
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
|
||||
|
||||
|
@ -36,12 +37,17 @@ The latest option is not supported on the remote client.
|
|||
|
||||
```
|
||||
$ podman wait mywebserver
|
||||
0
|
||||
|
||||
$ podman wait --latest
|
||||
0
|
||||
|
||||
$ podman wait 860a4b23
|
||||
1
|
||||
|
||||
$ podman wait mywebserver myftpserver
|
||||
0
|
||||
125
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
|
|
|
@ -64,6 +64,7 @@ var _ = Describe("Podman wait", func() {
|
|||
session = podmanTest.Podman([]string{"wait", "-l"})
|
||||
session.Wait(20)
|
||||
})
|
||||
|
||||
It("podman container wait on latest container", func() {
|
||||
session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"})
|
||||
session.Wait(20)
|
||||
|
@ -71,4 +72,23 @@ var _ = Describe("Podman wait", func() {
|
|||
session = podmanTest.Podman([]string{"container", "wait", "-l"})
|
||||
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"}))
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue