diff options
author | Nalin Dahyabhai <nalin@redhat.com> | 2019-10-16 12:01:30 -0400 |
---|---|---|
committer | Nalin Dahyabhai <nalin@redhat.com> | 2019-10-29 13:35:19 -0400 |
commit | 248bb61b14a3f0d4e1d244eff85b30f48554a6a8 (patch) | |
tree | bbaa162a20177f96a0fc03a48faaa49dcfc89215 /cmd/podman/images.go | |
parent | 07195ff09fdcb0d2d3a044c92665b082d6e742b1 (diff) | |
download | podman-248bb61b14a3f0d4e1d244eff85b30f48554a6a8.tar.gz podman-248bb61b14a3f0d4e1d244eff85b30f48554a6a8.tar.bz2 podman-248bb61b14a3f0d4e1d244eff85b30f48554a6a8.zip |
images: distinguish between tags and digests
Generate an image's RepoDigests list using all applicable digests, and
refrain from outputting a digest in the tag column of the "images"
output.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Diffstat (limited to 'cmd/podman/images.go')
-rw-r--r-- | cmd/podman/images.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/cmd/podman/images.go b/cmd/podman/images.go index 6bb08e195..6157fda2a 100644 --- a/cmd/podman/images.go +++ b/cmd/podman/images.go @@ -206,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" @@ -270,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()) @@ -287,11 +287,16 @@ 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", @@ -302,7 +307,6 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma if opts.quiet { // Show only one image ID when quiet break outer } - } } } |