From 96dd57ca50de54e82cea177c317b92612ed1cf81 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 4 Jul 2022 07:13:51 -0400 Subject: podman wait can take multiple conditions Podman wait should not be defaulting to just stopped. By default wait API waits for stopped and exited. We should not override this on the client side. Signed-off-by: Daniel J Walsh --- cmd/podman/containers/wait.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/containers/wait.go b/cmd/podman/containers/wait.go index 5b8480781..be92a3cbe 100644 --- a/cmd/podman/containers/wait.go +++ b/cmd/podman/containers/wait.go @@ -41,9 +41,9 @@ var ( ) var ( - waitOptions = entities.WaitOptions{} - waitCondition string - waitInterval string + waitOptions = entities.WaitOptions{} + waitConditions []string + waitInterval string ) func waitFlags(cmd *cobra.Command) { @@ -54,7 +54,7 @@ func waitFlags(cmd *cobra.Command) { _ = cmd.RegisterFlagCompletionFunc(intervalFlagName, completion.AutocompleteNone) conditionFlagName := "condition" - flags.StringVar(&waitCondition, conditionFlagName, "stopped", "Condition to wait on") + flags.StringSliceVar(&waitConditions, conditionFlagName, []string{}, "Condition to wait on") _ = cmd.RegisterFlagCompletionFunc(conditionFlagName, common.AutocompleteWaitCondition) } @@ -92,11 +92,13 @@ func wait(cmd *cobra.Command, args []string) error { return errors.New("--latest and containers cannot be used together") } - cond, err := define.StringToContainerStatus(waitCondition) - if err != nil { - return err + for _, condition := range waitConditions { + cond, err := define.StringToContainerStatus(condition) + if err != nil { + return err + } + waitOptions.Condition = append(waitOptions.Condition, cond) } - waitOptions.Condition = []define.ContainerStatus{cond} responses, err := registry.ContainerEngine().ContainerWait(context.Background(), args, waitOptions) if err != nil { -- cgit v1.2.3-54-g00ecf