Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2016-05-02 18:32:06 +0000
committerJeff Johnston2016-05-02 19:07:49 +0000
commit1f761da853fa55483de517914a67e3e4b7aadb0a (patch)
tree8d71f4bf2891879d77cb2ec44e66f8f30fe79a74
parentbb22321667dc282c11204aacbd82051c4c2c0b71 (diff)
downloadorg.eclipse.linuxtools-1f761da853fa55483de517914a67e3e4b7aadb0a.tar.gz
org.eclipse.linuxtools-1f761da853fa55483de517914a67e3e4b7aadb0a.tar.xz
org.eclipse.linuxtools-1f761da853fa55483de517914a67e3e4b7aadb0a.zip
Bug 492843 - RFE: add copyToContainer method to DockerConnection
Change-Id: Ie41147110cf9e888215f949b1f300adc89357ea3 Reviewed-on: https://git.eclipse.org/r/71813 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java19
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java17
2 files changed, 35 insertions, 1 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java
index 20a462bf7c..36dae1137e 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.linuxtools.docker.core;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
@@ -227,6 +228,24 @@ public interface IDockerConnection {
throws DockerException, InterruptedException;
/**
+ * Copy a directory from the Host into a Container's file system.
+ *
+ * @param directory
+ * the Host directory to copy to the Container
+ * @param id
+ * the Container id
+ * @param path
+ * the directory to place the Host files in the Container
+ *
+ * @throws DockerException
+ * in case of underlying problem
+ * @throws InterruptedException
+ * if the thread was interrupted
+ */
+ void copyToContainer(final String directory, String id, String path)
+ throws DockerException, InterruptedException, IOException;
+
+ /**
* Determine if authorization is valid.
*
* @param config
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
index bcff9e64ce..7884ef7633 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
@@ -1505,7 +1505,7 @@ public class DockerConnection implements IDockerConnection, Closeable {
}
@Override
- public InputStream copyContainer(String id, String path)
+ public InputStream copyContainer(final String id, final String path)
throws DockerException, InterruptedException {
InputStream stream;
try {
@@ -1517,6 +1517,21 @@ public class DockerConnection implements IDockerConnection, Closeable {
}
@Override
+ public void copyToContainer(final String directory, final String id,
+ final String path)
+ throws DockerException, InterruptedException, IOException {
+ try {
+ DockerClient copy = getClientCopy();
+ java.nio.file.Path dirPath = FileSystems.getDefault()
+ .getPath(directory);
+ copy.copyToContainer(dirPath, id, path);
+ copy.close(); /* dispose of client copy now that we are done */
+ } catch (com.spotify.docker.client.DockerException e) {
+ throw new DockerException(e.getMessage(), e.getCause());
+ }
+ }
+
+ @Override
public int auth(DockerAuthConfig config)
throws DockerException, InterruptedException {
try {

Back to the top