Skip to content

Commit 94af355

Browse files
committed
Fix double-marshalling of cachefrom
1 parent f6d920f commit 94af355

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/main/java/com/github/dockerjava/core/exec/BuildImageCmdExec.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.github.dockerjava.core.exec;
22

3-
import org.slf4j.Logger;
4-
import org.slf4j.LoggerFactory;
5-
63
import com.fasterxml.jackson.core.type.TypeReference;
74
import com.github.dockerjava.api.async.ResultCallback;
85
import com.github.dockerjava.api.command.BuildImageCmd;
@@ -12,6 +9,9 @@
129
import com.github.dockerjava.core.InvocationBuilder;
1310
import com.github.dockerjava.core.MediaType;
1411
import com.github.dockerjava.core.WebTarget;
12+
import com.google.common.base.Joiner;
13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
1515

1616
import static org.apache.commons.lang.StringUtils.isNotBlank;
1717

@@ -59,7 +59,7 @@ protected Void execute0(BuildImageCmd command, ResultCallback<BuildResponseItem>
5959
}
6060

6161
if (command.getCacheFrom() != null && !command.getCacheFrom().isEmpty()) {
62-
webTarget = webTarget.queryParamsSet("cachefrom", command.getCacheFrom());
62+
webTarget = webTarget.queryParam("cachefrom", "[\"" + Joiner.on("\",\"").join(command.getCacheFrom()) + "\"]");
6363
}
6464

6565
if (command.getRemote() != null) {

src/main/java/com/github/dockerjava/jaxrs/BuildImageCmdExec.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.fasterxml.jackson.databind.ObjectMapper;
1111

12+
import com.google.common.base.Joiner;
1213
import org.glassfish.jersey.client.ClientProperties;
1314
import org.glassfish.jersey.client.RequestEntityProcessing;
1415
import org.slf4j.Logger;
@@ -75,10 +76,8 @@ protected AbstractCallbackNotifier<BuildResponseItem> callbackNotifier(BuildImag
7576
webTarget = webTarget.queryParam("t", command.getTag());
7677
}
7778

78-
if (command.getCacheFrom() != null) {
79-
for (String c: command.getCacheFrom()) {
80-
webTarget = webTarget.queryParam("cachefrom", c);
81-
}
79+
if (command.getCacheFrom() != null && !command.getCacheFrom().isEmpty()) {
80+
webTarget = webTarget.queryParam("cachefrom", "[\"" + Joiner.on("\",\"").join(command.getCacheFrom()) + "\"]");
8281
}
8382

8483
if (command.getRemote() != null) {

src/test/java/com/github/dockerjava/cmd/BuildImageCmdIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,7 @@ public void cacheFrom() throws Exception {
302302
assertThat(inspectImageResponse1, not(nullValue()));
303303

304304
File baseDir2 = fileFromBuildTestResource("CacheFrom/test2");
305-
String cacheImage = String.format("[\"%s\"]", imageId1);
306-
String imageId2 = dockerRule.getClient().buildImageCmd(baseDir2).withCacheFrom(new HashSet<>(Arrays.asList(cacheImage)))
305+
String imageId2 = dockerRule.getClient().buildImageCmd(baseDir2).withCacheFrom(new HashSet<>(Arrays.asList(imageId1)))
307306
.exec(new BuildImageResultCallback())
308307
.awaitImageId();
309308
InspectImageResponse inspectImageResponse2 = dockerRule.getClient().inspectImageCmd(imageId2).exec();

0 commit comments

Comments
 (0)