From ecae5f7adeb1acea9c090c3d6c43f7470f33ac84 Mon Sep 17 00:00:00 2001
From: Valentin Rothberg <rothberg@redhat.com>
Date: Wed, 16 Sep 2020 12:12:07 +0200
Subject: image list: return all associated names

Always return all associated names / repo tags of an image and fix a bug
with malformed repo tags.

Previously, Podman returned all names only with `--all` but this flag
only instructs to list intermediate images and should not alter
associated names.  With `--all` Podman queried the repo tags of an image
which splits all *tagged* names into repository and tag which is then
reassembled to eventually be parsed again in the frontend.  Lot's of
redundant CPU heat and buggy as the reassembly didn't consider digests
which ultimately broke parsing in the frontend.

Fixes: #7651
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
---
 pkg/domain/infra/abi/images_list.go | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

(limited to 'pkg')

diff --git a/pkg/domain/infra/abi/images_list.go b/pkg/domain/infra/abi/images_list.go
index 7ec84246d..3e47dc67a 100644
--- a/pkg/domain/infra/abi/images_list.go
+++ b/pkg/domain/infra/abi/images_list.go
@@ -23,33 +23,13 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
 
 	summaries := []*entities.ImageSummary{}
 	for _, img := range images {
-		var repoTags []string
-		if opts.All {
-			pairs, err := libpodImage.ReposToMap(img.Names())
-			if err != nil {
-				return nil, err
-			}
-
-			for repo, tags := range pairs {
-				for _, tag := range tags {
-					repoTags = append(repoTags, repo+":"+tag)
-				}
-			}
-		} else {
-			repoTags, err = img.RepoTags()
-			if err != nil {
-				return nil, err
-			}
-		}
-
 		digests := make([]string, len(img.Digests()))
 		for j, d := range img.Digests() {
 			digests[j] = string(d)
 		}
 
 		e := entities.ImageSummary{
-			ID: img.ID(),
-
+			ID:           img.ID(),
 			ConfigDigest: string(img.ConfigDigest),
 			Created:      img.Created().Unix(),
 			Dangling:     img.Dangling(),
@@ -61,7 +41,7 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
 			ReadOnly:     img.IsReadOnly(),
 			SharedSize:   0,
 			VirtualSize:  img.VirtualSize,
-			RepoTags:     repoTags,
+			RepoTags:     img.Names(), // may include tags and digests
 		}
 		e.Labels, _ = img.Labels(context.TODO())
 
-- 
cgit v1.2.3-54-g00ecf