summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/images.go21
-rw-r--r--libpod/runtime_img.go16
2 files changed, 23 insertions, 14 deletions
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index 2dcd743cf..846f00c98 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -182,15 +182,20 @@ func getImagesTemplateOutput(runtime *libpod.Runtime, images []inspect.ImageResu
if !opts.noTrunc {
imageID = shortID(img.ID)
}
- params := imagesTemplateParams{
- Repository: img.Repository,
- Tag: img.Tag,
- ID: imageID,
- Digest: img.Digest,
- Created: units.HumanDuration(time.Since((createdTime))) + " ago",
- Size: units.HumanSizeWithPrecision(float64(*img.Size), 3),
+ // get all specified repo:tag pairs and print them separately
+ for repo, tags := range libpod.ReposToMap(img.RepoTags) {
+ for _, tag := range tags {
+ params := imagesTemplateParams{
+ Repository: repo,
+ Tag: tag,
+ ID: imageID,
+ Digest: img.Digest,
+ Created: units.HumanDuration(time.Since((createdTime))) + " ago",
+ Size: units.HumanSizeWithPrecision(float64(*img.Size), 3),
+ }
+ imagesOutput = append(imagesOutput, params)
+ }
}
- imagesOutput = append(imagesOutput, params)
}
return
}
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index 06bd474d6..53d39ffca 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -1298,9 +1298,11 @@ func imageSize(img types.ImageSource) *uint64 {
return nil
}
-func reposToMap(repotags []string) map[string]string {
+// ReposToMap parses the specified repotags and returns a map with repositories
+// as keys and the corresponding arrays of tags as values.
+func ReposToMap(repotags []string) map[string][]string {
// map format is repo -> tag
- repos := make(map[string]string)
+ repos := make(map[string][]string)
for _, repo := range repotags {
var repository, tag string
if len(repo) > 0 {
@@ -1308,10 +1310,10 @@ func reposToMap(repotags []string) map[string]string {
repository = repo[0:li]
tag = repo[li+1:]
}
- repos[repository] = tag
+ repos[repository] = append(repos[repository], tag)
}
if len(repos) == 0 {
- repos["<none>"] = "<none"
+ repos["<none>"] = []string{"<none>"}
}
return repos
}
@@ -1348,18 +1350,20 @@ func (r *Runtime) GetImageResults() ([]inspect.ImageResult, error) {
dangling = true
}
- for repo, tag := range reposToMap(image.Names) {
+ for repo, tags := range ReposToMap(image.Names) {
+ // use the first pair as the image's default repo and tag
results = append(results, inspect.ImageResult{
ID: image.ID,
Repository: repo,
RepoTags: image.Names,
- Tag: tag,
+ Tag: tags[0],
Size: imageSize(img),
Digest: image.Digest,
Created: image.Created,
Labels: imgInspect.Labels,
Dangling: dangling,
})
+ break
}
}