summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-03-08 09:23:36 -0800
committerGitHub <noreply@github.com>2019-03-08 09:23:36 -0800
commit5ae7359184a20859d775bc59f1b1c53348b04ecd (patch)
treee653e18fabdc8013fe73c35d130dd8d91584cdf7 /cmd/podman
parent5fdb8bfcb346f41029b0876bd11477282811642c (diff)
parent15971689e8111427307046fec135a37a30ab5aa1 (diff)
downloadpodman-5ae7359184a20859d775bc59f1b1c53348b04ecd.tar.gz
podman-5ae7359184a20859d775bc59f1b1c53348b04ecd.tar.bz2
podman-5ae7359184a20859d775bc59f1b1c53348b04ecd.zip
Merge pull request #2557 from QiWang19/filter2241
fix bug in podman images list all images with same name
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/images.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index 78dc87ad5..f92e5d44d 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -2,6 +2,7 @@ package main
import (
"context"
+ "fmt"
"reflect"
"sort"
"strings"
@@ -128,7 +129,7 @@ func init() {
func imagesCmd(c *cliconfig.ImagesValues) error {
var (
filterFuncs []imagefilters.ResultFilter
- newImage *adapter.ContainerImage
+ image string
)
runtime, err := adapter.GetRuntime(&c.PodmanCommand)
@@ -137,23 +138,23 @@ func imagesCmd(c *cliconfig.ImagesValues) error {
}
defer runtime.Shutdown(false)
if len(c.InputArgs) == 1 {
- newImage, err = runtime.NewImageFromLocal(c.InputArgs[0])
- if err != nil {
- return err
- }
+ image = c.InputArgs[0]
}
-
if len(c.InputArgs) > 1 {
return errors.New("'podman images' requires at most 1 argument")
}
-
+ if len(c.Filter) > 0 && image != "" {
+ return errors.New("can not specify an image and a filter")
+ }
ctx := getContext()
- if len(c.Filter) > 0 || newImage != nil {
- filterFuncs, err = CreateFilterFuncs(ctx, runtime, c.Filter, newImage)
- if err != nil {
- return err
- }
+ if len(c.Filter) > 0 {
+ filterFuncs, err = CreateFilterFuncs(ctx, runtime, c.Filter, nil)
+ } else {
+ filterFuncs, err = CreateFilterFuncs(ctx, runtime, []string{fmt.Sprintf("reference=%s", image)}, nil)
+ }
+ if err != nil {
+ return err
}
opts := imagesOptions{
@@ -174,7 +175,7 @@ func imagesCmd(c *cliconfig.ImagesValues) error {
var filteredImages []*adapter.ContainerImage
//filter the images
- if len(c.Filter) > 0 || newImage != nil {
+ if len(c.Filter) > 0 || len(c.InputArgs) == 1 {
filteredImages = imagefilters.FilterImages(images, filterFuncs)
} else {
filteredImages = images