-
Notifications
You must be signed in to change notification settings - Fork 2k
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
images: print hint when invoking "docker images" with ambiguous argument #4849
Conversation
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The `docker images` top-level subcommand predates the `docker <object> <verb>` convention (e.g. `docker image ls`), but accepts a positional argument to search/filter images by name (globbing). It's common for users to accidentally mistake these commands, and to use (e.g.) `docker images ls`, expecting to see all images, but ending up with an empty list because no image named "ls" was found. Disallowing these search-terms would be a breaking change, but we can print and informational message to help the users correct their mistake. Before this patch: docker images ls REPOSITORY TAG IMAGE ID CREATED SIZE With this patch applied: docker images ls REPOSITORY TAG IMAGE ID CREATED SIZE No images found matching "ls": did you mean "docker image ls"? Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #4849 +/- ##
==========================================
+ Coverage 59.58% 61.28% +1.69%
==========================================
Files 288 287 -1
Lines 24821 20038 -4783
==========================================
- Hits 14790 12280 -2510
+ Misses 9145 6866 -2279
- Partials 886 892 +6 |
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.
Overall LGTM.
Glad to have something in place for this.
Format: formatter.NewImageFormat(format, options.quiet, options.showDigests), | ||
Trunc: !options.noTrunc, | ||
}, | ||
Digest: options.showDigests, | ||
} | ||
return formatter.ImageWrite(imageCtx, images) | ||
if err := formatter.ImageWrite(imageCtx, images); err != nil { |
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.
Why print the empty image list before checking if its ambiguous?
I guess it can make it a little more obvious what could be happening.
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.
I continued treating as a regular search that didn't return a result. eg, a search for an image named build
could still be legit, so keeping the behavior as usual, just the extra message on stderr
@laurazard @jalonsogo ptal 🤗 |
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.
LGTM!
Thanks all! Let me bring this in; we can tweak the hint if we want to in follow ups. |
docker volumes
alias #4601docker volumes
does not exist #4600cli/command/images: runImages: inline intermediate var
cli/command/images: runImages: use proper camel-case for dockerCLI
images: print hint when invoking "docker images" with ambiguous argument
The
docker images
top-level subcommand predates thedocker <object> <verb>
convention (e.g.
docker image ls
), but accepts a positional argument tosearch/filter images by name (globbing). It's common for users to accidentally
mistake these commands, and to use (e.g.)
docker images ls
, expectingto see all images, but ending up with an empty list because no image named
"ls" was found.
Disallowing these search-terms would be a breaking change, but we can print
and informational message to help the users correct their mistake.
Before this patch:
With this patch applied:
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)