|
6 | 6 | import javax.ws.rs.client.WebTarget; |
7 | 7 | import javax.ws.rs.core.MediaType; |
8 | 8 |
|
| 9 | +import com.fasterxml.jackson.databind.ObjectMapper; |
9 | 10 | import org.glassfish.jersey.client.ClientProperties; |
10 | 11 | import org.glassfish.jersey.client.RequestEntityProcessing; |
11 | 12 | import org.slf4j.Logger; |
|
20 | 21 | import com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier; |
21 | 22 | import com.github.dockerjava.jaxrs.async.POSTCallbackNotifier; |
22 | 23 |
|
| 24 | +import java.io.IOException; |
| 25 | + |
23 | 26 | public class BuildImageCmdExec extends AbstrAsyncDockerCmdExec<BuildImageCmd, BuildResponseItem> implements |
24 | 27 | BuildImageCmd.Exec { |
25 | 28 | private static final Logger LOGGER = LoggerFactory.getLogger(BuildImageCmdExec.class); |
| 29 | + private static final ObjectMapper MAPPER = new ObjectMapper(); |
26 | 30 |
|
27 | 31 | public BuildImageCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { |
28 | 32 | super(baseResource, dockerClientConfig); |
@@ -88,6 +92,18 @@ protected AbstractCallbackNotifier<BuildResponseItem> callbackNotifier(BuildImag |
88 | 92 | webTarget = webTarget.queryParam("cpusetcpus", command.getCpusetcpus()); |
89 | 93 | } |
90 | 94 |
|
| 95 | + if (command.hasRemoveEnabled() == null || !command.hasRemoveEnabled()) { |
| 96 | + webTarget = webTarget.queryParam("rm", "false"); |
| 97 | + } |
| 98 | + |
| 99 | + if (command.getBuildArgs() != null) { |
| 100 | + try { |
| 101 | + webTarget = webTarget.queryParam("buildargs", MAPPER.writeValueAsString(command.getBuildArgs())); |
| 102 | + } catch (IOException e) { |
| 103 | + // pass |
| 104 | + } |
| 105 | + } |
| 106 | + |
91 | 107 | webTarget.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.CHUNKED); |
92 | 108 | webTarget.property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024 * 1024); |
93 | 109 |
|
|
0 commit comments