Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display presence of attestations in docker images --tree #5451

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cli/command/image/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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],
},
}

Expand Down Expand Up @@ -102,6 +109,7 @@ type imageDetails struct {
DiskUsage string
Used bool
ContentSize string
Attestation bool
}

type topImage struct {
Expand Down Expand Up @@ -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,
Expand Down
Loading