-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Added imageName filter for ListImagesCmd #297
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
Changes from all commits
f70dcfe
23224f5
34b3a5f
85bf86a
a60d9fc
caf07d2
4d61fee
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 |
|---|---|---|
|
|
@@ -18,12 +18,16 @@ public interface ListImagesCmd extends SyncDockerCmd<List<Image>> { | |
|
|
||
| @CheckForNull | ||
| public String getFilters(); | ||
|
|
||
| public String getImageNameFilter(); | ||
|
|
||
| @CheckForNull | ||
| public Boolean hasShowAllEnabled(); | ||
|
|
||
| public ListImagesCmd withShowAll(Boolean showAll); | ||
|
|
||
| public ListImagesCmd withImageNameFilter(String imageName); | ||
|
Member
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. keep new line after
Author
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. Fixed in latest commit. |
||
|
|
||
| public ListImagesCmd withFilters(String filters); | ||
|
|
||
| public static interface Exec extends DockerCmdSyncExec<ListImagesCmd, List<Image>> { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| */ | ||
| public class ListImagesCmdImpl extends AbstrDockerCmd<ListImagesCmd, List<Image>> implements ListImagesCmd { | ||
|
|
||
| private String imageNameFilter; | ||
|
Member
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. wrong intent
Author
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. Fixed in latest commit. |
||
| private String filters; | ||
|
|
||
| private Boolean showAll = false; | ||
|
|
@@ -48,4 +49,22 @@ public ListImagesCmd withFilters(String filter) { | |
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return new StringBuilder("images ").append(showAll ? "--all=true" : "") | ||
| .append(filters != null ? "--filters " + filters : "") | ||
| .append(imageNameFilter != null ? "--filter " + imageNameFilter : "").toString(); | ||
| } | ||
|
Member
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. Just do toString from helpers (see some class), it was old idea to emulate command line. |
||
|
|
||
| @Override | ||
| public ListImagesCmd withImageNameFilter(String imageNameFilter) { | ||
|
Member
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.
|
||
| checkNotNull(imageNameFilter, "image name filter not specified"); | ||
|
Member
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. @marcuslinke why enforce non null if it has null check later?
Contributor
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. Maybe it was OK to check in exec as it coudn't "know" that this was checked already. When introducing
Member
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. No, annotation is source level, real check is runtime check.
Contributor
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. 👍 |
||
| this.imageNameFilter = imageNameFilter; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public String getImageNameFilter() { | ||
| return this.imageNameFilter; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,8 +27,13 @@ protected List<Image> execute(ListImagesCmd command) { | |
|
|
||
| webTarget = booleanQueryParam(webTarget, "all", command.hasShowAllEnabled()); | ||
|
|
||
| if (command.getFilters() != null) | ||
| webTarget = webTarget.queryParam("filters", urlPathSegmentEscaper().escape(command.getFilters())); | ||
| if (command.getFilters() != null) { | ||
| webTarget = webTarget.queryParam("filters", urlPathSegmentEscaper().escape(command.getFilters())); | ||
| } | ||
|
|
||
| if (command.getImageNameFilter() != null) { | ||
|
Member
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. So null allowed? |
||
| webTarget = webTarget.queryParam("filter", urlPathSegmentEscaper().escape(command.getImageNameFilter())); | ||
| } | ||
|
|
||
| LOGGER.trace("GET: {}", webTarget); | ||
|
|
||
|
|
||
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.
keep new line before