Skip to content

Commit cab8a2e

Browse files
authored
Merge pull request #4982 from vvoland/c8d-multiplatform-list
image/list: Add `--tree` flag
2 parents bbce5a0 + a9b78da commit cab8a2e

4 files changed

Lines changed: 398 additions & 0 deletions

File tree

cli/command/image/list.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package image
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"io"
78

@@ -24,6 +25,7 @@ type imagesOptions struct {
2425
format string
2526
filter opts.FilterOpt
2627
calledAs string
28+
tree bool
2729
}
2830

2931
// NewImagesCommand creates a new `docker images` command
@@ -59,6 +61,10 @@ func NewImagesCommand(dockerCLI command.Cli) *cobra.Command {
5961
flags.StringVar(&options.format, "format", "", flagsHelper.FormatHelp)
6062
flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided")
6163

64+
flags.BoolVar(&options.tree, "tree", false, "List multi-platform images as a tree (EXPERIMENTAL)")
65+
flags.SetAnnotation("tree", "version", []string{"1.47"})
66+
flags.SetAnnotation("tree", "experimentalCLI", nil)
67+
6268
return cmd
6369
}
6470

@@ -75,6 +81,26 @@ func runImages(ctx context.Context, dockerCLI command.Cli, options imagesOptions
7581
filters.Add("reference", options.matchName)
7682
}
7783

84+
if options.tree {
85+
if options.quiet {
86+
return errors.New("--quiet is not yet supported with --tree")
87+
}
88+
if options.noTrunc {
89+
return errors.New("--no-trunc is not yet supported with --tree")
90+
}
91+
if options.showDigests {
92+
return errors.New("--show-digest is not yet supported with --tree")
93+
}
94+
if options.format != "" {
95+
return errors.New("--format is not yet supported with --tree")
96+
}
97+
98+
return runTree(ctx, dockerCLI, treeOptions{
99+
all: options.all,
100+
filters: filters,
101+
})
102+
}
103+
78104
images, err := dockerCLI.Client().ImageList(ctx, image.ListOptions{
79105
All: options.all,
80106
Filters: filters,

0 commit comments

Comments
 (0)