feat(images): include all tags and digest references when listing images

This commit is contained in:
Pasha Sviderski
2026-10-26 20:00:46 +10:00
parent e50c7a0cf6
commit bb8fb3a380
3 changed files with 77 additions and 45 deletions
+23
View File
@@ -2,6 +2,7 @@ package api
import (
"errors"
"slices"
"github.com/distribution/reference"
"github.com/docker/docker/api/types/image"
@@ -42,6 +43,28 @@ type ImageFilter struct {
Name string
}
// ImageReferences returns the image tag and named digest references, sorted and without duplicates.
// References use familiar names such as "alpine:latest" and "alpine@sha256:...".
// Bare digests and invalid references are excluded. It returns nil if there are no named references.
func ImageReferences(img image.Summary) []string {
var refs []string
for _, names := range [][]string{img.RepoTags, img.RepoDigests} {
for _, name := range names {
ref, err := reference.ParseAnyReference(name)
if err != nil {
continue
}
// RepoDigests can contain bare digests. Keep only references with a repository name.
if named, ok := ref.(reference.Named); ok {
refs = append(refs, reference.FamiliarString(named))
}
}
}
slices.Sort(refs)
return slices.Compact(refs)
}
// MachineRemoteImage represents an image in a remote registry fetched by a particular machine.
type MachineRemoteImage struct {
Metadata *pb.Metadata
+1 -1
View File
@@ -61,7 +61,7 @@ func (cli *Client) ListImages(ctx context.Context, filter api.ImageFilter) ([]ap
// Broadcast the image list request to the specified machines or all machines if none specified.
listCtx := ProxyMachinesContext(ctx, filter.Machines)
opts := image.ListOptions{Manifests: true}
opts := image.ListOptions{All: true, Manifests: true}
if filter.Name != "" {
opts.Filters = filters.NewArgs(
filters.Arg("reference", filter.Name),