summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorAdrian Reber <areber@redhat.com>2018-10-16 11:50:10 +0000
committerAdrian Reber <adrian@lisas.de>2018-10-23 17:01:30 +0200
commit9d9493e41a2d9fb79221986507d1789265355d2d (patch)
tree191141d4f9a9f03bb1cf18a4d254516c5a10bc17 /cmd/podman
parent95c93577cd3c96b5b2d2e7945723bda218073d8f (diff)
downloadpodman-9d9493e41a2d9fb79221986507d1789265355d2d.tar.gz
podman-9d9493e41a2d9fb79221986507d1789265355d2d.tar.bz2
podman-9d9493e41a2d9fb79221986507d1789265355d2d.zip
Add checkAllAndLatest() function
The check about the --all and --latest option is used and repeated and some commands. Factor it out and put it into common. Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index 8ae1c9e0f..3401b1a93 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -89,6 +89,21 @@ func validateFlags(c *cli.Context, flags []cli.Flag) error {
return nil
}
+// checkAllAndLatest checks that --all and --latest are used correctly
+func checkAllAndLatest(c *cli.Context) error {
+ argLen := len(c.Args())
+ if (c.Bool("all") || c.Bool("latest")) && argLen > 0 {
+ return errors.Errorf("no arguments are needed with --all or --latest")
+ }
+ if c.Bool("all") && c.Bool("latest") {
+ return errors.Errorf("--all and --latest cannot be used together")
+ }
+ if argLen < 1 && !c.Bool("all") && !c.Bool("latest") {
+ return errors.Errorf("you must provide at least one pod name or id")
+ }
+ return nil
+}
+
// getContext returns a non-nil, empty context
func getContext() context.Context {
return context.TODO()