Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2016-02-03 19:46:41 +0000
committerJeff Johnston2016-02-05 18:36:27 +0000
commit3414343c299e65a33a928987879869c99863d08d (patch)
tree97a9a7c6a6e58b596a28dc1852fed0154535aebc /containers/org.eclipse.linuxtools.docker.core/src/org/eclipse
parent6e32530e7658ef944a902a1c935ce0d2b898309e (diff)
downloadorg.eclipse.linuxtools-3414343c299e65a33a928987879869c99863d08d.tar.gz
org.eclipse.linuxtools-3414343c299e65a33a928987879869c99863d08d.tar.xz
org.eclipse.linuxtools-3414343c299e65a33a928987879869c99863d08d.zip
Lookup for docker-machine and the VM driver should consult PATH first.
Don't wipe out the PATH set by the system when setting user-specified PATH entry preferences. Instead append additional entries to it. Change-Id: I48bb1b82a6f908e07da0ef85d61fe1e530c5ed63 Reviewed-on: https://git.eclipse.org/r/65843 Tested-by: Hudson CI Reviewed-by: Xavier Coulon <xcoulon@redhat.com> (cherry picked from commit 8e0c5a02c780f16b4708b9f2aff3c3d4fa2f20c7) Reviewed-on: https://git.eclipse.org/r/65887 Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
Diffstat (limited to 'containers/org.eclipse.linuxtools.docker.core/src/org/eclipse')
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerMachine.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerMachine.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerMachine.java
index ece5f92791..2ffe5a7438 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerMachine.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerMachine.java
@@ -15,6 +15,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -92,20 +94,29 @@ public class DockerMachine {
final String[] args, final String... extraPaths) {
try {
final String[] command = new String[args.length + 1];
- command[0] = dockerMachineInstallDir
- + (dockerMachineInstallDir.endsWith(File.separator) ? "" //$NON-NLS-1$
- : File.separator)
- + "docker-machine";
+
+ command[0] = Paths.get(dockerMachineInstallDir, "docker-machine").toString(); //$NON-NLS-1$
+ final String envPath = System.getenv("PATH"); //$NON-NLS-1$
+ if (envPath != null) {
+ for (String dir : envPath.split(File.pathSeparator)) {
+ Path dmPath = Paths.get(dir, "docker-machine"); //$NON-NLS-1$
+ if (dmPath.toFile().exists()) {
+ command[0] = dmPath.toString();
+ break;
+ }
+ }
+ }
+
System.arraycopy(args, 0, command, 1, args.length);
final ProcessBuilder processBuilder = new ProcessBuilder(command);
final Map<String, String> environment = processBuilder
.environment();
- final StringBuilder path = new StringBuilder(
- dockerMachineInstallDir);
+ final StringBuilder path = new StringBuilder();
for (String extraPath : extraPaths) {
path.append(File.pathSeparator).append(extraPath);
}
- environment.put("PATH", path.toString());
+ String newEnvPath = environment.get("PATH") + path.toString(); //$NON-NLS-1$
+ environment.put("PATH", newEnvPath); //$NON-NLS-1$
final Process p = processBuilder.start();
p.waitFor();
if (p.exitValue() == 0) {

Back to the top