diff options
author | Jeff Johnston | 2016-05-02 18:32:06 +0000 |
---|---|---|
committer | Jeff Johnston | 2016-05-02 19:07:49 +0000 |
commit | 1f761da853fa55483de517914a67e3e4b7aadb0a (patch) | |
tree | 8d71f4bf2891879d77cb2ec44e66f8f30fe79a74 | |
parent | bb22321667dc282c11204aacbd82051c4c2c0b71 (diff) | |
download | org.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>
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 { |