summaryrefslogtreecommitdiff
path: root/cmd/podman/images.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-10-29 20:58:51 +0100
committerGitHub <noreply@github.com>2019-10-29 20:58:51 +0100
commite7540d0406c49b22de245246d16ebc6e1778df37 (patch)
treed25a5f8d259d19f2c0017d9987e93d065e577f89 /cmd/podman/images.go
parent5918f3a5f1d11862fbaaca94ff25f1d9cc1309e2 (diff)
parent66c126d6dee178f96f8a120f13372802d46ea9b5 (diff)
downloadpodman-e7540d0406c49b22de245246d16ebc6e1778df37.tar.gz
podman-e7540d0406c49b22de245246d16ebc6e1778df37.tar.bz2
podman-e7540d0406c49b22de245246d16ebc6e1778df37.zip
Merge pull request #4310 from nalind/manifest-lists
Move to containers/image v5, support manifest lists
Diffstat (limited to 'cmd/podman/images.go')
-rw-r--r--cmd/podman/images.go30
1 files changed, 19 insertions, 11 deletions
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index e363fa3bb..6157fda2a 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -27,6 +27,7 @@ type imagesTemplateParams struct {
Tag string
ID string
Digest digest.Digest
+ Digests []digest.Digest
Created string
CreatedTime time.Time
Size string
@@ -34,12 +35,13 @@ type imagesTemplateParams struct {
}
type imagesJSONParams struct {
- ID string `json:"id"`
- Name []string `json:"names"`
- Digest digest.Digest `json:"digest"`
- Created time.Time `json:"created"`
- Size *uint64 `json:"size"`
- ReadOnly bool `json:"readonly"`
+ ID string `json:"id"`
+ Name []string `json:"names"`
+ Digest digest.Digest `json:"digest"`
+ Digests []digest.Digest `json:"digests"`
+ Created time.Time `json:"created"`
+ Size *uint64 `json:"size"`
+ ReadOnly bool `json:"readonly"`
}
type imagesOptions struct {
@@ -204,9 +206,9 @@ func (i imagesOptions) setOutputFormat() string {
if i.quiet {
return formats.IDString
}
- format := "table {{.Repository}}\t{{.Tag}}\t"
+ format := "table {{.Repository}}\t{{if .Tag}}{{.Tag}}{{else}}<none>{{end}}\t"
if i.noHeading {
- format = "{{.Repository}}\t{{.Tag}}\t"
+ format = "{{.Repository}}\t{{if .Tag}}{{.Tag}}{{else}}<none>{{end}}\t"
}
if i.digests {
format += "{{.Digest}}\t"
@@ -268,7 +270,7 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
imageID = shortID(img.ID())
}
- // get all specified repo:tag pairs and print them separately
+ // get all specified repo:tag and repo@digest pairs and print them separately
repopairs, err := image.ReposToMap(img.Names())
if err != nil {
logrus.Errorf("error finding tag/digest for %s", img.ID())
@@ -285,11 +287,17 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
lastNumIdx := strings.LastIndexFunc(sizeStr, unicode.IsNumber)
sizeStr = sizeStr[:lastNumIdx+1] + " " + sizeStr[lastNumIdx+1:]
}
+ var imageDigest digest.Digest
+ if len(tag) == 71 && strings.HasPrefix(tag, "sha256:") {
+ imageDigest = digest.Digest(tag)
+ tag = ""
+ }
params := imagesTemplateParams{
Repository: repo,
Tag: tag,
ID: imageID,
- Digest: img.Digest(),
+ Digest: imageDigest,
+ Digests: img.Digests(),
CreatedTime: createdTime,
Created: units.HumanDuration(time.Since(createdTime)) + " ago",
Size: sizeStr,
@@ -299,7 +307,6 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
if opts.quiet { // Show only one image ID when quiet
break outer
}
-
}
}
}
@@ -321,6 +328,7 @@ func getImagesJSONOutput(ctx context.Context, images []*adapter.ContainerImage)
ID: img.ID(),
Name: img.Names(),
Digest: img.Digest(),
+ Digests: img.Digests(),
Created: img.Created(),
Size: size,
ReadOnly: img.IsReadOnly(),