summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-05-20 20:46:43 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-05-21 09:28:42 -0400
commita4c8198afd2b92b40b95c6fe01756cf2d0076cb6 (patch)
treebc447a449a45e27a73579e762f48fc0e05cd2e9b /pkg
parent8db7b9ea219ef06c50919dcfabdfdca5676e1456 (diff)
downloadpodman-a4c8198afd2b92b40b95c6fe01756cf2d0076cb6.tar.gz
podman-a4c8198afd2b92b40b95c6fe01756cf2d0076cb6.tar.bz2
podman-a4c8198afd2b92b40b95c6fe01756cf2d0076cb6.zip
Fix remote handling of podman images calls
Enable three more tests Fix handling of image filters Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/utils/images.go33
-rw-r--r--pkg/domain/entities/images.go5
-rw-r--r--pkg/domain/infra/abi/images_list.go24
-rw-r--r--pkg/domain/infra/tunnel/images.go9
4 files changed, 52 insertions, 19 deletions
diff --git a/pkg/api/handlers/utils/images.go b/pkg/api/handlers/utils/images.go
index 1c67de9db..7fb31a177 100644
--- a/pkg/api/handlers/utils/images.go
+++ b/pkg/api/handlers/utils/images.go
@@ -62,7 +62,6 @@ func GetImages(w http.ResponseWriter, r *http.Request) ([]*image.Image, error) {
}{
// This is where you can override the golang default value for one of fields
}
- // TODO I think all is implemented with a filter?
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
return nil, err
@@ -71,6 +70,10 @@ func GetImages(w http.ResponseWriter, r *http.Request) ([]*image.Image, error) {
if _, found := r.URL.Query()["digests"]; found && query.Digests {
UnSupportedParameter("digests")
}
+ var (
+ images []*image.Image
+ err error
+ )
if len(query.Filters) > 0 {
for k, v := range query.Filters {
@@ -78,11 +81,33 @@ func GetImages(w http.ResponseWriter, r *http.Request) ([]*image.Image, error) {
filters = append(filters, fmt.Sprintf("%s=%s", k, val))
}
}
- return runtime.ImageRuntime().GetImagesWithFilters(filters)
+ images, err = runtime.ImageRuntime().GetImagesWithFilters(filters)
+ if err != nil {
+ return images, err
+ }
} else {
- return runtime.ImageRuntime().GetImages()
+ images, err = runtime.ImageRuntime().GetImages()
+ if err != nil {
+ return images, err
+ }
}
-
+ if query.All {
+ return images, nil
+ }
+ var returnImages []*image.Image
+ for _, img := range images {
+ if len(img.Names()) == 0 {
+ parent, err := img.IsParent(r.Context())
+ if err != nil {
+ return nil, err
+ }
+ if parent {
+ continue
+ }
+ }
+ returnImages = append(returnImages, img)
+ }
+ return returnImages, nil
}
func GetImage(r *http.Request, name string) (*image.Image, error) {
diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go
index cce3001eb..9d5fd5cc9 100644
--- a/pkg/domain/entities/images.go
+++ b/pkg/domain/entities/images.go
@@ -221,9 +221,8 @@ type ImageSearchReport struct {
// Image List Options
type ImageListOptions struct {
- All bool `json:"all" schema:"all"`
- Filter []string `json:"Filter,omitempty"`
- Filters url.Values `json:"filters" schema:"filters"`
+ All bool `json:"all" schema:"all"`
+ Filter []string `json:"Filter,omitempty"`
}
type ImagePruneOptions struct {
diff --git a/pkg/domain/infra/abi/images_list.go b/pkg/domain/infra/abi/images_list.go
index c559e250c..3034e36ec 100644
--- a/pkg/domain/infra/abi/images_list.go
+++ b/pkg/domain/infra/abi/images_list.go
@@ -13,14 +13,7 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
err error
)
- // TODO: Future work support for domain.Filters
- // filters := utils.ToLibpodFilters(opts.Filters)
-
- if len(opts.Filter) > 0 {
- images, err = ir.Libpod.ImageRuntime().GetImagesWithFilters(opts.Filter)
- } else {
- images, err = ir.Libpod.ImageRuntime().GetImages()
- }
+ images, err = ir.Libpod.ImageRuntime().GetImagesWithFilters(opts.Filter)
if err != nil {
return nil, err
}
@@ -40,9 +33,18 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
}
}
} else {
- repoTags, _ = img.RepoTags()
- if len(repoTags) == 0 {
- continue
+ repoTags, err = img.RepoTags()
+ if err != nil {
+ return nil, err
+ }
+ if len(img.Names()) == 0 {
+ parent, err := img.IsParent(ctx)
+ if err != nil {
+ return nil, err
+ }
+ if parent {
+ continue
+ }
}
}
diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go
index 4d00d331b..a547a24d7 100644
--- a/pkg/domain/infra/tunnel/images.go
+++ b/pkg/domain/infra/tunnel/images.go
@@ -4,6 +4,7 @@ import (
"context"
"io/ioutil"
"os"
+ "strings"
"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/docker/reference"
@@ -25,8 +26,13 @@ func (ir *ImageEngine) Remove(ctx context.Context, imagesArg []string, opts enti
}
func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) ([]*entities.ImageSummary, error) {
- images, err := images.List(ir.ClientCxt, &opts.All, opts.Filters)
+ filters := make(map[string][]string, len(opts.Filter))
+ for _, filter := range opts.Filter {
+ f := strings.Split(filter, "=")
+ filters[f[0]] = f[1:]
+ }
+ images, err := images.List(ir.ClientCxt, &opts.All, filters)
if err != nil {
return nil, err
}
@@ -61,6 +67,7 @@ func (ir *ImageEngine) History(ctx context.Context, nameOrId string, opts entiti
}
func (ir *ImageEngine) Prune(ctx context.Context, opts entities.ImagePruneOptions) (*entities.ImagePruneReport, error) {
+
results, err := images.Prune(ir.ClientCxt, &opts.All, opts.Filters)
if err != nil {
return nil, err