diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-01-26 06:32:31 +0100 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-01-28 16:34:18 -0500 |
commit | 38d2ef0cbd32a68a6d2c74b35d75fd9b14a3867a (patch) | |
tree | ac710a858a59b865a614c699eeff9908cabb71df /cmd | |
parent | bb7f72bbd607c89660ce5bf7fd57234bcf7cfa08 (diff) | |
download | podman-38d2ef0cbd32a68a6d2c74b35d75fd9b14a3867a.tar.gz podman-38d2ef0cbd32a68a6d2c74b35d75fd9b14a3867a.tar.bz2 podman-38d2ef0cbd32a68a6d2c74b35d75fd9b14a3867a.zip |
Throw error on invalid sort value
We define the valid sort values, so we should throw an error
on invalid sort values.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/images.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cmd/podman/images.go b/cmd/podman/images.go index 75cdd3465..115f30d9b 100644 --- a/cmd/podman/images.go +++ b/cmd/podman/images.go @@ -159,6 +159,21 @@ func imagesCmd(c *cliconfig.ImagesValues) error { filters = append(filters, fmt.Sprintf("reference=%s", image)) } + var sortValues = map[string]bool{ + "created": true, + "id": true, + "repository": true, + "size": true, + "tag": true, + } + if !sortValues[c.Sort] { + keys := make([]string, 0, len(sortValues)) + for k := range sortValues { + keys = append(keys, k) + } + return errors.Errorf("invalid sort value %q, required values: %s", c.Sort, strings.Join(keys, ", ")) + } + opts := imagesOptions{ quiet: c.Quiet, noHeading: c.Noheading, |