You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by al...@apache.org on 2020/07/15 04:31:35 UTC
[openwhisk-wskdebug] 01/01: support custom docker host IPs via the
DOCKER_HOST_IP environment variable
This is an automated email from the ASF dual-hosted git repository.
alexkli pushed a commit to branch custom-host-ip
in repository https://gitbox.apache.org/repos/asf/openwhisk-wskdebug.git
commit d740ed492bbffccb49bd374d022da5d5eb6ef7c8
Author: Alexander Klimetschek <ak...@adobe.com>
AuthorDate: Tue Jul 14 21:30:49 2020 -0700
support custom docker host IPs via the DOCKER_HOST_IP environment variable
---
src/invoker.js | 3 ++-
test/nodejs.test.js | 21 +++++++++++++++++++++
test/test.js | 1 +
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/invoker.js b/src/invoker.js
index 0fcd536..f39c747 100644
--- a/src/invoker.js
+++ b/src/invoker.js
@@ -273,7 +273,8 @@ class OpenWhiskInvoker {
const containerRuntimePort = `${RUNTIME_PORT}/tcp`;
const hostRuntimePort = await getPort();
- this.containerURL = `http://0.0.0.0:${hostRuntimePort}`;
+ const ipAddress = process.env.DOCKER_HOST_IP || "0.0.0.0";
+ this.containerURL = `http://${ipAddress}:${hostRuntimePort}`;
const containerDebugPort = `${this.debug.internalPort}/tcp`;
const createContainerConfig = {
diff --git a/test/nodejs.test.js b/test/nodejs.test.js
index 625e276..7369529 100644
--- a/test/nodejs.test.js
+++ b/test/nodejs.test.js
@@ -576,6 +576,27 @@ describe('nodejs', function() {
test.assertAllNocksInvoked();
});
+ it("should run an action with custom DOCKER_HOST_IP env var set", async function() {
+ test.mockActionAndInvocation(
+ "myaction",
+ `function main(params) {
+ return {
+ msg: 'CORRECT',
+ input: params.input
+ }
+ }`,
+ { input: "test-input" },
+ { msg: "CORRECT", input: "test-input" }
+ );
+
+ // 0.0.0.0 (default) or 127.0.0.1 should work if we are on the docker host
+ process.env.DOCKER_HOST_IP = "127.0.0.1";
+
+ await wskdebug(`myaction -p ${test.port}`);
+
+ test.assertAllNocksInvoked();
+ });
+
// TODO: test -l livereload connection
// TODO: test agents - conditions (unit test agent code locally)
diff --git a/test/test.js b/test/test.js
index 0aaeed6..3d501ea 100644
--- a/test/test.js
+++ b/test/test.js
@@ -55,6 +55,7 @@ async function beforeEach() {
function afterEach() {
delete process.env.WSK_CONFIG_FILE;
+ delete process.env.DOCKER_HOST_IP;
nock.cleanAll();
// restore working dir from beforeEach()