From 0c365abb70fa57dfb449d0ae59ab1b3b1f9a917e Mon Sep 17 00:00:00 2001 From: Yoann Dubreuil Date: Mon, 16 Jun 2014 13:22:54 +0200 Subject: [PATCH 1/2] add paused field in ContainerInspectResponse --- .../kpelykh/docker/client/model/ContainerInspectResponse.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java b/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java index d686f9ebf..8a2946301 100644 --- a/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java +++ b/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java @@ -249,6 +249,7 @@ public class ContainerState { @JsonProperty("Running") public boolean running; @JsonProperty("Pid") public int pid; + @JsonProperty("Paused") public boolean paused; @JsonProperty("ExitCode") public int exitCode; @JsonProperty("StartedAt") public String startedAt; @JsonProperty("Ghost") public boolean ghost; @@ -259,6 +260,7 @@ public String toString() { return "ContainerState{" + "running=" + running + ", pid=" + pid + + ", paused=" + paused + ", exitCode=" + exitCode + ", startedAt='" + startedAt + '\'' + ", ghost=" + ghost + From 938aea540fea0eb796b44935a010f2748a58f83c Mon Sep 17 00:00:00 2001 From: Yoann Dubreuil Date: Tue, 17 Jun 2014 10:24:29 +0200 Subject: [PATCH 2/2] split DockerClient.build in two methods, the new one accepting the tar as an inputstream --- .../kpelykh/docker/client/DockerClient.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/kpelykh/docker/client/DockerClient.java b/src/main/java/com/kpelykh/docker/client/DockerClient.java index 101d7209d..9a38222df 100644 --- a/src/main/java/com/kpelykh/docker/client/DockerClient.java +++ b/src/main/java/com/kpelykh/docker/client/DockerClient.java @@ -870,15 +870,6 @@ public ClientResponse build(File dockerFolder, String tag, boolean noCache) thro Preconditions.checkArgument(dockerFolder.exists(), "Folder %s doesn't exist", dockerFolder); Preconditions.checkState(new File(dockerFolder, "Dockerfile").exists(), "Dockerfile doesn't exist in " + dockerFolder); - //We need to use Jersey HttpClient here, since ApacheHttpClient4 will not add boundary filed to - //Content-Type: multipart/form-data; boundary=Boundary_1_372491238_1372806136625 - - MultivaluedMap params = new MultivaluedMapImpl(); - params.add("t", tag); - if (noCache) { - params.add("nocache", "true"); - } - // ARCHIVE TAR String archiveNameWithOutExtension = UUID.randomUUID().toString(); @@ -931,6 +922,25 @@ public ClientResponse build(File dockerFolder, String tag, boolean noCache) thro throw new DockerException("Error occurred while preparing Docker context folder.", ex); } + try { + return build(FileUtils.openInputStream(dockerFolderTar), tag, noCache); + } catch (IOException e) { + throw new DockerException(e); + } finally { + FileUtils.deleteQuietly(dockerFolderTar); + } + } + + public ClientResponse build(InputStream tarStream, String tag, boolean noCache) throws DockerException { + //We need to use Jersey HttpClient here, since ApacheHttpClient4 will not add boundary filed to + //Content-Type: multipart/form-data; boundary=Boundary_1_372491238_1372806136625 + + MultivaluedMap params = new MultivaluedMapImpl(); + params.add("t", tag); + if (noCache) { + params.add("nocache", "true"); + } + WebResource webResource = client.resource(restEndpointUrl + "/build").queryParams(params); try { @@ -938,17 +948,13 @@ public ClientResponse build(File dockerFolder, String tag, boolean noCache) thro return webResource .type("application/tar") .accept(MediaType.TEXT_PLAIN) - .post(ClientResponse.class, FileUtils.openInputStream(dockerFolderTar)); + .post(ClientResponse.class, tarStream); } catch (UniformInterfaceException exception) { if (exception.getResponse().getStatus() == 500) { throw new DockerException("Server error", exception); } else { throw new DockerException(exception); } - } catch (IOException e) { - throw new DockerException(e); - } finally { - FileUtils.deleteQuietly(dockerFolderTar); } } }