summaryrefslogtreecommitdiff
path: root/cmd/podman/validate/args.go
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2020-09-14 15:19:34 -0600
committerEd Santiago <santiago@redhat.com>2020-09-14 15:49:28 -0600
commit2583948f72a05cf38dc9f0c4ec1feef64ab9c9af (patch)
treeafd22aba6b816495c6b764f59e84ea6c1406a192 /cmd/podman/validate/args.go
parentfd7cdb25027bb33c33eacb99f1a02838eca5d684 (diff)
downloadpodman-2583948f72a05cf38dc9f0c4ec1feef64ab9c9af.tar.gz
podman-2583948f72a05cf38dc9f0c4ec1feef64ab9c9af.tar.bz2
podman-2583948f72a05cf38dc9f0c4ec1feef64ab9c9af.zip
Usability: prevent "-l" with arguments
Add new system check confirming that "podman foo -l arg" throws an error; and fix lots of instances where code was not doing this check. I'll probably need to add something similar for --all but that can wait. Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'cmd/podman/validate/args.go')
-rw-r--r--cmd/podman/validate/args.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd/podman/validate/args.go b/cmd/podman/validate/args.go
index aacb41e69..ab6460e93 100644
--- a/cmd/podman/validate/args.go
+++ b/cmd/podman/validate/args.go
@@ -37,6 +37,9 @@ func IDOrLatestArgs(cmd *cobra.Command, args []string) error {
if len(args) == 0 && !given {
return fmt.Errorf("%q requires a name, id, or the \"--latest\" flag", cmd.CommandPath())
}
+ if len(args) > 0 && given {
+ return fmt.Errorf("--latest and containers cannot be used together")
+ }
}
return nil
}
@@ -83,7 +86,7 @@ func CheckAllLatestAndCIDFile(c *cobra.Command, args []string, ignoreArgLen bool
if argLen > 0 {
if specifiedLatest {
- return errors.Errorf("no arguments are needed with --latest")
+ return errors.Errorf("--latest and containers cannot be used together")
} else if cidfile && (specifiedLatest || specifiedCIDFile) {
return errors.Errorf("no arguments are needed with --latest or --cidfile")
}
@@ -138,7 +141,7 @@ func CheckAllLatestAndPodIDFile(c *cobra.Command, args []string, ignoreArgLen bo
if argLen > 0 {
if specifiedLatest {
- return errors.Errorf("no arguments are needed with --latest")
+ return errors.Errorf("--latest and pods cannot be used together")
} else if withIDFile && (specifiedLatest || specifiedPodIDFile) {
return errors.Errorf("no arguments are needed with --latest or --pod-id-file")
}