dubee commented on a change in pull request #3616: Use ‘docker.host’ java 
property as a way to set Docker access for Runtime unit tests
URL: 
https://github.com/apache/incubator-openwhisk/pull/3616#discussion_r188406381
 
 

 ##########
 File path: tests/src/test/scala/actionContainers/ActionContainer.scala
 ##########
 @@ -88,14 +88,38 @@ object ActionContainer {
   }
 
   private lazy val dockerCmd: String = {
-    val version = WhiskProperties.getProperty("whisk.version.name")
-    // Check if we are running on docker-machine env.
-    val hostStr = if (version.toLowerCase().contains("mac")) {
-      s" --host tcp://${WhiskProperties.getMainDockerEndpoint} "
-    } else {
-      " "
+    /*
+     * The docker host is set to a provided property 'docker.host' if it's
+     * available; otherwise by the environment variable DOCKER_HOST
+     * (which is usually set, especially for DOCKER_MACHINE).
+     *
+     * The plan is to move builds to using 'gradle-docker-plugin', which know
+     * its docker socket and to have it pass the docker socket implicitly using
+     * 'systemProperty "docker.host", docker.url'.  Eventually, we will also
+     * need to handle TLS certificates here.  Again, 'gradle-docker-plugin'
+     * knows where they are; we will just add system properties to get the
+     * information onto the docker command line.
+     */
+    val dockerCmdString = dockerBin +
+      sys.props
+        .get("docker.host")
+        .orElse(sys.env.get("DOCKER_HOST"))
+        .map(" --host " + _)
+        .getOrElse("")
+    // Test here that this actually works, otherwise throw a somewhat 
understandable error message
+    proc(s"$dockerCmdString info").onComplete {
+      case Success((v, _, _)) if (v != 0) =>
+        throw new RuntimeException("""Unable to connect to docker host using 
'$d' as command string.
 
 Review comment:
   What is `$d`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to