From 69e1a636ac9cb0ed8b49f24a21e76e60c21c4f92 Mon Sep 17 00:00:00 2001 From: Yves Brissaud Date: Wed, 18 Sep 2024 16:27:26 +0200 Subject: [PATCH] display presence of attestations in docker images --tree Signed-off-by: Yves Brissaud --- cli/command/image/tree.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cli/command/image/tree.go b/cli/command/image/tree.go index a8ecd4fc9e..6a2dcc1a76 100644 --- a/cli/command/image/tree.go +++ b/cli/command/image/tree.go @@ -51,6 +51,12 @@ func runTree(ctx context.Context, dockerCLI command.Cli, opts treeOptions) error var totalContent int64 children := make([]subImage, 0, len(img.Manifests)) + attestations := make(map[string]bool) + for _, im := range img.Manifests { + if im.Kind == imagetypes.ManifestKindAttestation { + attestations[im.AttestationData.For.String()] = true + } + } for _, im := range img.Manifests { if im.Kind != imagetypes.ManifestKindImage { continue @@ -65,6 +71,7 @@ func runTree(ctx context.Context, dockerCLI command.Cli, opts treeOptions) error DiskUsage: units.HumanSizeWithPrecision(float64(im.Size.Total), 3), Used: len(im.ImageData.Containers) > 0, ContentSize: units.HumanSizeWithPrecision(float64(im.Size.Content), 3), + Attestation: attestations[im.ID], }, } @@ -102,6 +109,7 @@ type imageDetails struct { DiskUsage string Used bool ContentSize string + Attestation bool } type topImage struct { @@ -162,6 +170,18 @@ func printImageTree(dockerCLI command.Cli, view treeView) error { return stringid.TruncateID(d.ID) }, }, + { + Title: "Attest", + Align: alignLeft, + Width: 6, + Color: &greenColor, + DetailsValue: func(d *imageDetails) string { + if d.Attestation { + return "✔" + } + return " " + }, + }, { Title: "Disk usage", Align: alignRight,