-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
image/list: Add --tree
flag
#4982
Changes from all commits
be11b74
ea8aafc
18ab788
b1a08f7
d417d06
0242a1e
a9b78da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package image | |
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"io" | ||
|
||
|
@@ -24,6 +25,7 @@ type imagesOptions struct { | |
format string | ||
filter opts.FilterOpt | ||
calledAs string | ||
tree bool | ||
} | ||
|
||
// NewImagesCommand creates a new `docker images` command | ||
|
@@ -59,6 +61,10 @@ func NewImagesCommand(dockerCLI command.Cli) *cobra.Command { | |
flags.StringVar(&options.format, "format", "", flagsHelper.FormatHelp) | ||
flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided") | ||
|
||
flags.BoolVar(&options.tree, "tree", false, "List multi-platform images as a tree (EXPERIMENTAL)") | ||
flags.SetAnnotation("tree", "version", []string{"1.47"}) | ||
flags.SetAnnotation("tree", "experimentalCLI", nil) | ||
|
||
return cmd | ||
} | ||
|
||
|
@@ -75,6 +81,26 @@ func runImages(ctx context.Context, dockerCLI command.Cli, options imagesOptions | |
filters.Add("reference", options.matchName) | ||
} | ||
|
||
if options.tree { | ||
if options.quiet { | ||
return errors.New("--quiet is not yet supported with --tree") | ||
} | ||
if options.noTrunc { | ||
return errors.New("--no-trunc is not yet supported with --tree") | ||
} | ||
if options.showDigests { | ||
return errors.New("--show-digest is not yet supported with --tree") | ||
} | ||
if options.format != "" { | ||
return errors.New("--format is not yet supported with --tree") | ||
} | ||
Comment on lines
+94
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also slightly wondering if we should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Depends a bit on how it's implemented. For the default ( docker image ls --format=table
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-cli-dev latest 88c125e27aee 21 hours ago 749MB
docker-dev latest 60f88d03ca84 4 days ago 2.21GB
golang 1.22 2bd56f00ff47 6 days ago 1.21GB
docker image ls --format "table {{.Tag}}\t{{.ID}}"
TAG IMAGE ID
latest 88c125e27aee
latest 60f88d03ca84
1.22 2bd56f00ff47 |
||
|
||
return runTree(ctx, dockerCLI, treeOptions{ | ||
all: options.all, | ||
filters: filters, | ||
}) | ||
} | ||
|
||
images, err := dockerCLI.Client().ImageList(ctx, image.ListOptions{ | ||
All: options.all, | ||
Filters: filters, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably OK for now (i.e., producing an error); we may have to look what we want the behavior to be. I think for other cases we made the
quiet
always work; i.e.--format .... --quiet
would continue to just print theID
(digest) of the image.