summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-01-08 14:40:29 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-08 22:44:38 +0000
commit245a338f5a6519f5729749be646abbefd12701d8 (patch)
treef40a53649ffd2e67beae4036c029a46b0f1d5c66 /cmd
parentda7556de4ad1d89bd97e1f6c5a146eee00e8c040 (diff)
downloadpodman-245a338f5a6519f5729749be646abbefd12701d8.tar.gz
podman-245a338f5a6519f5729749be646abbefd12701d8.tar.bz2
podman-245a338f5a6519f5729749be646abbefd12701d8.zip
Add latest to wait
It is desirable to have a --latest switch on the podman wait command so we can wait on the latest container created to end. Also, fixes a panic with latest where no containers are available. Signed-off-by: baude <bbaude@redhat.com> Closes: #201 Approved by: baude
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/wait.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd/podman/wait.go b/cmd/podman/wait.go
index 27cfecac9..2b2a07738 100644
--- a/cmd/podman/wait.go
+++ b/cmd/podman/wait.go
@@ -14,11 +14,12 @@ var (
Block until one or more containers stop and then print their exit codes
`
-
+ waitFlags = []cli.Flag{LatestFlag}
waitCommand = cli.Command{
Name: "wait",
Usage: "Block on one or more containers",
Description: waitDescription,
+ Flags: waitFlags,
Action: waitCmd,
ArgsUsage: "CONTAINER-NAME [CONTAINER-NAME ...]",
}
@@ -26,7 +27,7 @@ var (
func waitCmd(c *cli.Context) error {
args := c.Args()
- if len(args) < 1 {
+ if len(args) < 1 && !c.Bool("latest") {
return errors.Errorf("you must provide at least one container name or id")
}
@@ -41,7 +42,15 @@ func waitCmd(c *cli.Context) error {
}
var lastError error
- for _, container := range c.Args() {
+ if c.Bool("latest") {
+ latestCtr, err := runtime.GetLatestContainer()
+ if err != nil {
+ return errors.Wrapf(err, "unable to wait on latest container")
+ }
+ args = append(args, latestCtr.ID())
+ }
+
+ for _, container := range args {
ctr, err := runtime.LookupContainer(container)
if err != nil {
return errors.Wrapf(err, "unable to find container %s", container)