summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-03-20 14:00:05 -0500
committerBrent Baude <bbaude@redhat.com>2020-03-20 14:33:33 -0500
commitc81e065149da73ae904aa19ee46a23d1ab8ce55c (patch)
tree52a8692894690a8f09e025f90d6d2b5045259e4f /cmd
parent4a00409bf8c88174cbdbc12760d3f8ddce9621de (diff)
downloadpodman-c81e065149da73ae904aa19ee46a23d1ab8ce55c.tar.gz
podman-c81e065149da73ae904aa19ee46a23d1ab8ce55c.tar.bz2
podman-c81e065149da73ae904aa19ee46a23d1ab8ce55c.zip
podmanv2 enable remote wait
enable remote container wait with condition Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podmanV2/containers/exists.go6
-rw-r--r--cmd/podmanV2/containers/inspect.go2
-rw-r--r--cmd/podmanV2/containers/wait.go22
-rw-r--r--cmd/podmanV2/root.go2
4 files changed, 23 insertions, 9 deletions
diff --git a/cmd/podmanV2/containers/exists.go b/cmd/podmanV2/containers/exists.go
index 93989b54a..3aff150be 100644
--- a/cmd/podmanV2/containers/exists.go
+++ b/cmd/podmanV2/containers/exists.go
@@ -10,7 +10,9 @@ import (
)
var (
- containerExistsCommand = &cobra.Command{
+ containerExistsDescription = `If the named container exists in local storage, podman container exists exits with 0, otherwise the exit code will be 1.`
+
+ existsCommand = &cobra.Command{
Use: "exists CONTAINER",
Short: "Check if a container exists in local storage",
Long: containerExistsDescription,
@@ -23,7 +25,7 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
- Command: containerExistsCommand,
+ Command: existsCommand,
Parent: containerCmd,
})
}
diff --git a/cmd/podmanV2/containers/inspect.go b/cmd/podmanV2/containers/inspect.go
index 355924984..635be4789 100644
--- a/cmd/podmanV2/containers/inspect.go
+++ b/cmd/podmanV2/containers/inspect.go
@@ -7,8 +7,6 @@ import (
)
var (
- containerExistsDescription = `If the named container exists in local storage, podman container exists exits with 0, otherwise the exit code will be 1.`
-
// podman container _inspect_
inspectCmd = &cobra.Command{
Use: "inspect [flags] CONTAINER",
diff --git a/cmd/podmanV2/containers/wait.go b/cmd/podmanV2/containers/wait.go
index d18064c3c..27acb3348 100644
--- a/cmd/podmanV2/containers/wait.go
+++ b/cmd/podmanV2/containers/wait.go
@@ -6,6 +6,7 @@ import (
"time"
"github.com/containers/libpod/cmd/podmanV2/registry"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -25,7 +26,10 @@ var (
}
)
-var waitFlags = entities.WaitOptions{}
+var (
+ waitFlags = entities.WaitOptions{}
+ waitCondition string
+)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
@@ -34,15 +38,20 @@ func init() {
Parent: containerCmd,
})
- waitCommand.SetHelpTemplate(registry.HelpTemplate())
- waitCommand.SetUsageTemplate(registry.UsageTemplate())
flags := waitCommand.Flags()
flags.DurationVarP(&waitFlags.Interval, "interval", "i", time.Duration(250), "Milliseconds to wait before polling for completion")
flags.BoolVarP(&waitFlags.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
- flags.StringVar(&waitFlags.Condition, "condition", "stopped", "Condition to wait on")
+ flags.StringVar(&waitCondition, "condition", "stopped", "Condition to wait on")
+ if registry.EngineOpts.EngineMode == entities.ABIMode {
+ // TODO: This is the same as V1. We could skip creating the flag altogether in V2...
+ _ = flags.MarkHidden("latest")
+ }
}
func wait(cmd *cobra.Command, args []string) error {
+ var (
+ err error
+ )
if waitFlags.Latest && len(args) > 0 {
return errors.New("cannot combine latest flag and arguments")
}
@@ -50,6 +59,11 @@ func wait(cmd *cobra.Command, args []string) error {
return errors.New("interval must be greater then 0")
}
+ waitFlags.Condition, err = define.StringToContainerStatus(waitCondition)
+ if err != nil {
+ return err
+ }
+
responses, err := registry.ContainerEngine().ContainerWait(context.Background(), args, waitFlags)
if err != nil {
return err
diff --git a/cmd/podmanV2/root.go b/cmd/podmanV2/root.go
index 92805ff30..24b083b9f 100644
--- a/cmd/podmanV2/root.go
+++ b/cmd/podmanV2/root.go
@@ -25,7 +25,7 @@ func init() {
var dummyVersion bool
rootCmd.PersistentFlags().BoolVarP(&dummyVersion, "version", "v", false, "Version of podman")
rootCmd.PersistentFlags().StringVarP(&registry.EngineOpts.Uri, "remote", "r", "", "URL to access podman service")
- rootCmd.PersistentFlags().StringSliceVarP(&registry.EngineOpts.Identities, "identity", "i", []string{}, "path to SSH identity file")
+ rootCmd.PersistentFlags().StringSliceVar(&registry.EngineOpts.Identities, "identity", []string{}, "path to SSH identity file")
}
func Execute() {