mirror of
https://github.com/containers/podman.git
synced 2025-12-03 19:59:39 +08:00
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>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user