mirror of https://github.com/docker/cli.git
Show images digests when "{{.Digest}}" is in format
This patch fixes the following bug: Running "docker image ls --digests" will add images digests to the image table. However, when using "format" to display images digests all of them are "<none>". Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
This commit is contained in:
parent
4b61f560b5
commit
83112f6343
|
@ -79,6 +79,11 @@ func ImageWrite(ctx ImageContext, images []types.ImageSummary) error {
|
|||
return ctx.Write(newImageContext(), render)
|
||||
}
|
||||
|
||||
// needDigest determines whether the image digest should be ignored or not when writing image context
|
||||
func needDigest(ctx ImageContext) bool {
|
||||
return ctx.Digest || ctx.Format.Contains("{{.Digest}}")
|
||||
}
|
||||
|
||||
func imageFormat(ctx ImageContext, images []types.ImageSummary, format func(subContext subContext) error) error {
|
||||
for _, image := range images {
|
||||
images := []*imageContext{}
|
||||
|
@ -121,7 +126,7 @@ func imageFormat(ctx ImageContext, images []types.ImageSummary, format func(subC
|
|||
// Do not display digests as their own row
|
||||
delete(repoDigests, repo)
|
||||
|
||||
if !ctx.Digest {
|
||||
if !needDigest(ctx) {
|
||||
// Ignore digest references, just show tag once
|
||||
digests = nil
|
||||
}
|
||||
|
|
|
@ -137,6 +137,14 @@ image <none>
|
|||
},
|
||||
"REPOSITORY\nimage\nimage\n<none>\n",
|
||||
},
|
||||
{
|
||||
ImageContext{
|
||||
Context: Context{
|
||||
Format: NewImageFormat("table {{.Digest}}", true, false),
|
||||
},
|
||||
},
|
||||
"DIGEST\nsha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf\n<none>\n<none>\n",
|
||||
},
|
||||
{
|
||||
ImageContext{
|
||||
Context: Context{
|
||||
|
|
Loading…
Reference in New Issue