summaryrefslogtreecommitdiff
path: root/cmd/podman/pods
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-06-22 14:29:04 -0700
committerJhon Honce <jhonce@redhat.com>2020-06-26 17:09:24 -0700
commit6fb5f01c736d5cbf11bc7eaad09f6f0c7fd1d0d4 (patch)
treeab64703869f9300d486531f5781d825e2d9aaec7 /cmd/podman/pods
parent673116c063f173ae7ff799a920f9c1ca28194b9d (diff)
downloadpodman-6fb5f01c736d5cbf11bc7eaad09f6f0c7fd1d0d4.tar.gz
podman-6fb5f01c736d5cbf11bc7eaad09f6f0c7fd1d0d4.tar.bz2
podman-6fb5f01c736d5cbf11bc7eaad09f6f0c7fd1d0d4.zip
Fixes --remote flag issues
* --remote, --url and --identity are now anchored to podman command. Subcommands should no longer have issues * TraverseChildren now set to V1 expectations * Latest flag now has helper function. Now has consistent usage. * IsRemote() uses cobra parser to determin if --remote is given * Moved validation functions from parser pkg to validate pkg * Fixes #6598 Fixes #6704 Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'cmd/podman/pods')
-rw-r--r--cmd/podman/pods/inspect.go6
-rw-r--r--cmd/podman/pods/kill.go13
-rw-r--r--cmd/podman/pods/pause.go11
-rw-r--r--cmd/podman/pods/pod.go9
-rw-r--r--cmd/podman/pods/ps.go7
-rw-r--r--cmd/podman/pods/restart.go9
-rw-r--r--cmd/podman/pods/rm.go10
-rw-r--r--cmd/podman/pods/start.go9
-rw-r--r--cmd/podman/pods/stats.go7
-rw-r--r--cmd/podman/pods/stop.go9
-rw-r--r--cmd/podman/pods/top.go9
-rw-r--r--cmd/podman/pods/unpause.go12
12 files changed, 43 insertions, 68 deletions
diff --git a/cmd/podman/pods/inspect.go b/cmd/podman/pods/inspect.go
index 34c07c11b..db2217aea 100644
--- a/cmd/podman/pods/inspect.go
+++ b/cmd/podman/pods/inspect.go
@@ -6,6 +6,7 @@ import (
"github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -36,11 +37,8 @@ func init() {
Parent: podCmd,
})
flags := inspectCmd.Flags()
- flags.BoolVarP(&inspectOptions.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
flags.StringVarP(&inspectOptions.Format, "format", "f", "json", "Format the output to a Go template or json")
- if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
- }
+ validate.AddLatestFlag(inspectCmd, &inspectOptions.Latest)
}
func inspect(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/pods/kill.go b/cmd/podman/pods/kill.go
index 02089016e..d83e4d77e 100644
--- a/cmd/podman/pods/kill.go
+++ b/cmd/podman/pods/kill.go
@@ -4,9 +4,9 @@ import (
"context"
"fmt"
- "github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
)
@@ -21,7 +21,7 @@ var (
Long: podKillDescription,
RunE: kill,
Args: func(cmd *cobra.Command, args []string) error {
- return parse.CheckAllLatestAndCIDFile(cmd, args, false, false)
+ return validate.CheckAllLatestAndCIDFile(cmd, args, false, false)
},
Example: `podman pod kill podID
podman pod kill --signal TERM mywebserver
@@ -41,14 +41,11 @@ func init() {
})
flags := killCommand.Flags()
flags.BoolVarP(&killOpts.All, "all", "a", false, "Kill all containers in all pods")
- flags.BoolVarP(&killOpts.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
flags.StringVarP(&killOpts.Signal, "signal", "s", "KILL", "Signal to send to the containers in the pod")
- if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
- }
-
+ validate.AddLatestFlag(killCommand, &killOpts.Latest)
}
-func kill(cmd *cobra.Command, args []string) error {
+
+func kill(_ *cobra.Command, args []string) error {
var (
errs utils.OutputErrors
)
diff --git a/cmd/podman/pods/pause.go b/cmd/podman/pods/pause.go
index 4ee182661..0ed3db936 100644
--- a/cmd/podman/pods/pause.go
+++ b/cmd/podman/pods/pause.go
@@ -4,9 +4,9 @@ import (
"context"
"fmt"
- "github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
)
@@ -21,7 +21,7 @@ var (
Long: podPauseDescription,
RunE: pause,
Args: func(cmd *cobra.Command, args []string) error {
- return parse.CheckAllLatestAndCIDFile(cmd, args, false, false)
+ return validate.CheckAllLatestAndCIDFile(cmd, args, false, false)
},
Example: `podman pod pause podID1 podID2
podman pod pause --latest
@@ -41,12 +41,9 @@ func init() {
})
flags := pauseCommand.Flags()
flags.BoolVarP(&pauseOptions.All, "all", "a", false, "Pause all running pods")
- flags.BoolVarP(&pauseOptions.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
- if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
- }
+ validate.AddLatestFlag(pauseCommand, &pauseOptions.Latest)
}
-func pause(cmd *cobra.Command, args []string) error {
+func pause(_ *cobra.Command, args []string) error {
var (
errs utils.OutputErrors
)
diff --git a/cmd/podman/pods/pod.go b/cmd/podman/pods/pod.go
index 9dc538c71..ca0283b11 100644
--- a/cmd/podman/pods/pod.go
+++ b/cmd/podman/pods/pod.go
@@ -14,11 +14,10 @@ var (
// Command: podman _pod_
podCmd = &cobra.Command{
- Use: "pod",
- Short: "Manage pods",
- Long: "Pods are a group of one or more containers sharing the same network, pid and ipc namespaces.",
- TraverseChildren: true,
- RunE: validate.SubCommandExists,
+ Use: "pod",
+ Short: "Manage pods",
+ Long: "Pods are a group of one or more containers sharing the same network, pid and ipc namespaces.",
+ RunE: validate.SubCommandExists,
}
containerConfig = util.DefaultContainerConfig()
)
diff --git a/cmd/podman/pods/ps.go b/cmd/podman/pods/ps.go
index 0171bb243..395acd78f 100644
--- a/cmd/podman/pods/ps.go
+++ b/cmd/podman/pods/ps.go
@@ -53,18 +53,15 @@ func init() {
// TODO should we make this a [] ?
flags.StringSliceVarP(&inputFilters, "filter", "f", []string{}, "Filter output based on conditions given")
flags.StringVar(&psInput.Format, "format", "", "Pretty-print pods to JSON or using a Go template")
- flags.BoolVarP(&psInput.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
flags.BoolVar(&psInput.Namespace, "namespace", false, "Display namespace information of the pod")
flags.BoolVar(&psInput.Namespace, "ns", false, "Display namespace information of the pod")
flags.BoolVar(&noTrunc, "no-trunc", false, "Do not truncate pod and container IDs")
flags.BoolVarP(&psInput.Quiet, "quiet", "q", false, "Print the numeric IDs of the pods only")
flags.StringVar(&psInput.Sort, "sort", "created", "Sort output by created, id, name, or number")
- if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
- }
+ validate.AddLatestFlag(psCmd, &psInput.Latest)
}
-func pods(cmd *cobra.Command, args []string) error {
+func pods(cmd *cobra.Command, _ []string) error {
var (
w io.Writer = os.Stdout
row string
diff --git a/cmd/podman/pods/restart.go b/cmd/podman/pods/restart.go
index 1f617a277..8bbbbb05d 100644
--- a/cmd/podman/pods/restart.go
+++ b/cmd/podman/pods/restart.go
@@ -4,9 +4,9 @@ import (
"context"
"fmt"
- "github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
)
@@ -21,7 +21,7 @@ var (
Long: podRestartDescription,
RunE: restart,
Args: func(cmd *cobra.Command, args []string) error {
- return parse.CheckAllLatestAndCIDFile(cmd, args, false, false)
+ return validate.CheckAllLatestAndCIDFile(cmd, args, false, false)
},
Example: `podman pod restart podID1 podID2
podman pod restart --latest
@@ -42,10 +42,7 @@ func init() {
flags := restartCommand.Flags()
flags.BoolVarP(&restartOptions.All, "all", "a", false, "Restart all running pods")
- flags.BoolVarP(&restartOptions.Latest, "latest", "l", false, "Restart the latest pod podman is aware of")
- if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
- }
+ validate.AddLatestFlag(restartCommand, &restartOptions.Latest)
}
func restart(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/pods/rm.go b/cmd/podman/pods/rm.go
index ec8dae1d1..5a5aa699b 100644
--- a/cmd/podman/pods/rm.go
+++ b/cmd/podman/pods/rm.go
@@ -5,9 +5,9 @@ import (
"fmt"
"github.com/containers/libpod/cmd/podman/common"
- "github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
)
@@ -30,7 +30,7 @@ var (
Long: podRmDescription,
RunE: rm,
Args: func(cmd *cobra.Command, args []string) error {
- return parse.CheckAllLatestAndPodIDFile(cmd, args, false, true)
+ return validate.CheckAllLatestAndPodIDFile(cmd, args, false, true)
},
Example: `podman pod rm mywebserverpod
podman pod rm -f 860a4b23
@@ -49,15 +49,15 @@ func init() {
flags.BoolVarP(&rmOptions.All, "all", "a", false, "Remove all running pods")
flags.BoolVarP(&rmOptions.Force, "force", "f", false, "Force removal of a running pod by first stopping all containers, then removing all containers in the pod. The default is false")
flags.BoolVarP(&rmOptions.Ignore, "ignore", "i", false, "Ignore errors when a specified pod is missing")
- flags.BoolVarP(&rmOptions.Latest, "latest", "l", false, "Remove the latest pod podman is aware of")
flags.StringArrayVarP(&rmOptions.PodIDFiles, "pod-id-file", "", nil, "Read the pod ID from the file")
+ validate.AddLatestFlag(rmCommand, &rmOptions.Latest)
+
if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
_ = flags.MarkHidden("ignore")
}
}
-func rm(cmd *cobra.Command, args []string) error {
+func rm(_ *cobra.Command, args []string) error {
ids, err := common.ReadPodIDFiles(rmOptions.PodIDFiles)
if err != nil {
return err
diff --git a/cmd/podman/pods/start.go b/cmd/podman/pods/start.go
index 97020b360..7ca211baa 100644
--- a/cmd/podman/pods/start.go
+++ b/cmd/podman/pods/start.go
@@ -5,9 +5,9 @@ import (
"fmt"
"github.com/containers/libpod/cmd/podman/common"
- "github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
)
@@ -29,7 +29,7 @@ var (
Long: podStartDescription,
RunE: start,
Args: func(cmd *cobra.Command, args []string) error {
- return parse.CheckAllLatestAndPodIDFile(cmd, args, false, true)
+ return validate.CheckAllLatestAndPodIDFile(cmd, args, false, true)
},
Example: `podman pod start podID
podman pod start --latest
@@ -50,11 +50,8 @@ func init() {
flags := startCommand.Flags()
flags.BoolVarP(&startOptions.All, "all", "a", false, "Restart all running pods")
- flags.BoolVarP(&startOptions.Latest, "latest", "l", false, "Restart the latest pod podman is aware of")
flags.StringArrayVarP(&startOptions.PodIDFiles, "pod-id-file", "", nil, "Read the pod ID from the file")
- if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
- }
+ validate.AddLatestFlag(startCommand, &startOptions.Latest)
}
func start(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/pods/stats.go b/cmd/podman/pods/stats.go
index d14632f01..619e49520 100644
--- a/cmd/podman/pods/stats.go
+++ b/cmd/podman/pods/stats.go
@@ -13,6 +13,7 @@ import (
"github.com/buger/goterm"
"github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/containers/libpod/pkg/util/camelcase"
"github.com/spf13/cobra"
@@ -55,13 +56,9 @@ func init() {
flags := statsCmd.Flags()
flags.BoolVarP(&statsOptions.All, "all", "a", false, "Provide stats for all pods")
flags.StringVar(&statsOptions.Format, "format", "", "Pretty-print container statistics to JSON or using a Go template")
- flags.BoolVarP(&statsOptions.Latest, "latest", "l", false, "Provide stats on the latest pod Podman is aware of")
flags.BoolVar(&statsOptions.NoReset, "no-reset", false, "Disable resetting the screen when streaming")
flags.BoolVar(&statsOptions.NoStream, "no-stream", false, "Disable streaming stats and only pull the first result")
-
- if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
- }
+ validate.AddLatestFlag(statsCmd, &statsOptions.Latest)
}
func stats(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/pods/stop.go b/cmd/podman/pods/stop.go
index 628e8a536..cb052575a 100644
--- a/cmd/podman/pods/stop.go
+++ b/cmd/podman/pods/stop.go
@@ -5,9 +5,9 @@ import (
"fmt"
"github.com/containers/libpod/cmd/podman/common"
- "github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
)
@@ -34,7 +34,7 @@ var (
Long: podStopDescription,
RunE: stop,
Args: func(cmd *cobra.Command, args []string) error {
- return parse.CheckAllLatestAndPodIDFile(cmd, args, false, true)
+ return validate.CheckAllLatestAndPodIDFile(cmd, args, false, true)
},
Example: `podman pod stop mywebserverpod
podman pod stop --latest
@@ -51,13 +51,14 @@ func init() {
flags := stopCommand.Flags()
flags.BoolVarP(&stopOptions.All, "all", "a", false, "Stop all running pods")
flags.BoolVarP(&stopOptions.Ignore, "ignore", "i", false, "Ignore errors when a specified pod is missing")
- flags.BoolVarP(&stopOptions.Latest, "latest", "l", false, "Stop the latest pod podman is aware of")
flags.UintVarP(&stopOptions.TimeoutCLI, "time", "t", containerConfig.Engine.StopTimeout, "Seconds to wait for pod stop before killing the container")
flags.StringArrayVarP(&stopOptions.PodIDFiles, "pod-id-file", "", nil, "Read the pod ID from the file")
+ validate.AddLatestFlag(stopCommand, &stopOptions.Latest)
+
if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
_ = flags.MarkHidden("ignore")
}
+
flags.SetNormalizeFunc(utils.AliasFlags)
}
diff --git a/cmd/podman/pods/top.go b/cmd/podman/pods/top.go
index 8df00f92a..d790869a4 100644
--- a/cmd/podman/pods/top.go
+++ b/cmd/podman/pods/top.go
@@ -8,6 +8,7 @@ import (
"text/tabwriter"
"github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
@@ -50,15 +51,11 @@ func init() {
flags := topCommand.Flags()
flags.SetInterspersed(false)
flags.BoolVar(&topOptions.ListDescriptors, "list-descriptors", false, "")
- flags.BoolVarP(&topOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
-
_ = flags.MarkHidden("list-descriptors") // meant only for bash completion
- if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
- }
+ validate.AddLatestFlag(topCommand, &topOptions.Latest)
}
-func top(cmd *cobra.Command, args []string) error {
+func top(_ *cobra.Command, args []string) error {
if topOptions.ListDescriptors {
descriptors, err := util.GetContainerPidInformationDescriptors()
if err != nil {
diff --git a/cmd/podman/pods/unpause.go b/cmd/podman/pods/unpause.go
index b30bd930a..54553e4a8 100644
--- a/cmd/podman/pods/unpause.go
+++ b/cmd/podman/pods/unpause.go
@@ -4,9 +4,9 @@ import (
"context"
"fmt"
- "github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
)
@@ -21,7 +21,7 @@ var (
Long: podUnpauseDescription,
RunE: unpause,
Args: func(cmd *cobra.Command, args []string) error {
- return parse.CheckAllLatestAndCIDFile(cmd, args, false, false)
+ return validate.CheckAllLatestAndCIDFile(cmd, args, false, false)
},
Example: `podman pod unpause podID1 podID2
podman pod unpause --all
@@ -41,12 +41,10 @@ func init() {
})
flags := unpauseCommand.Flags()
flags.BoolVarP(&unpauseOptions.All, "all", "a", false, "Pause all running pods")
- flags.BoolVarP(&unpauseOptions.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
- if registry.IsRemote() {
- _ = flags.MarkHidden("latest")
- }
+ validate.AddLatestFlag(unpauseCommand, &unpauseOptions.Latest)
}
-func unpause(cmd *cobra.Command, args []string) error {
+
+func unpause(_ *cobra.Command, args []string) error {
var (
errs utils.OutputErrors
)