Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f6edaaa

Browse filesBrowse files
committed
Adds namefilteer to netty's ListimagesCmdExec
Previously just jaxrs had implemented the feature of filtering by image name. Even though the `withFilter` was exposed, netty's implemntation didn't checked for its presence. The commits adds a test for such feature and the correctionn to the mentioned problem.
1 parent 1f85b7d commit f6edaaa
Copy full SHA for f6edaaa

2 files changed

+16Lines changed: 16 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/main/java/com/github/dockerjava/netty/exec/ListImagesCmdExec.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/github/dockerjava/netty/exec/ListImagesCmdExec.java
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ protected List<Image> execute(ListImagesCmd command) {
3333
webTarget = webTarget.queryParam("filters", urlPathSegmentEscaper().escape(FiltersEncoder.jsonEncode(command.getFilters())));
3434
}
3535

36+
if (command.getImageNameFilter() != null) {
37+
webTarget = webTarget.queryParam("filter", urlPathSegmentEscaper().escape(command.getImageNameFilter()));
38+
}
39+
3640
LOGGER.trace("GET: {}", webTarget);
3741

3842
List<Image> images = webTarget.request().accept(MediaType.APPLICATION_JSON)
Collapse file

‎src/test/java/com/github/dockerjava/netty/exec/ListImagesCmdExecTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/com/github/dockerjava/netty/exec/ListImagesCmdExecTest.java
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ public void listImagesWithDanglingFilter() throws DockerException {
7575
assertTrue(imageInFilteredList);
7676
}
7777

78+
@Test
79+
public void listImagesWithNameFilter() throws DockerException {
80+
String imageId = createDanglingImage();
81+
dockerClient.tagImageCmd(imageId, "test_repository", "latest").exec();
82+
List<Image> images = dockerClient.listImagesCmd().withImageNameFilter("test_repository:latest").exec();
83+
assertThat(images, notNullValue());
84+
LOG.info("Images List: {}", images);
85+
assertThat(images.size(), is(equalTo(1)));
86+
Boolean imageInFilteredList = isImageInFilteredList(images, imageId);
87+
assertTrue(imageInFilteredList);
88+
}
89+
7890
private boolean isImageInFilteredList(List<Image> images, String expectedImageId) {
7991
for (Image image : images) {
8092
if (expectedImageId.equals(image.getId())) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.