You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/10/04 19:23:49 UTC

[GitHub] dubee closed pull request #63: makes current directory for action correct

dubee closed pull request #63: makes current directory for action correct
URL: https://github.com/apache/incubator-openwhisk-runtime-docker/pull/63
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md
index 321a1f9..ed634bb 100644
--- a/core/CHANGELOG.md
+++ b/core/CHANGELOG.md
@@ -22,6 +22,7 @@
 ## Apache 1.13.0 (next release)
 Changes:
   - Update base python image to `python:3.6-alpine`
+  - Update current directory for action to be root of zip
 
 ## 1.3.3 (Apache 1.12.0)
 Changes:
diff --git a/core/actionProxy/actionproxy.py b/core/actionProxy/actionproxy.py
index 9d723a5..1a70708 100644
--- a/core/actionProxy/actionproxy.py
+++ b/core/actionProxy/actionproxy.py
@@ -52,6 +52,7 @@ def __init__(self, source=None, binary=None, zipdest=None):
         self.source = source if source else defaultBinary
         self.binary = binary if binary else defaultBinary
         self.zipdest = zipdest if zipdest else os.path.dirname(self.source)
+        os.chdir(os.path.dirname(self.source))
 
     def preinit(self):
         return
diff --git a/tests/src/test/scala/runtime/actionContainers/ActionProxyContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/ActionProxyContainerTests.scala
index 383f43b..d62c3f5 100644
--- a/tests/src/test/scala/runtime/actionContainers/ActionProxyContainerTests.scala
+++ b/tests/src/test/scala/runtime/actionContainers/ActionProxyContainerTests.scala
@@ -252,4 +252,20 @@ class ActionProxyContainerTests extends BasicActionRunnerTests with WskActorSyst
         e shouldBe empty
     })
   }
+
+  it should "support current directory be action location" in {
+    withActionContainer() { c =>
+      val code = """
+                   |#!/bin/bash
+                   |echo "{\"pwd_env\":\"$PWD\",\"pwd_cmd\":\"$(pwd)\"}"
+                 """.stripMargin.trim
+
+      val (initCode, initRes) = c.init(initPayload(code))
+      initCode should be(200)
+
+      val (_, runRes) = c.run(runPayload(JsObject()))
+      runRes.get.fields.get("pwd_env") shouldBe Some(JsString("/action"))
+      runRes.get.fields.get("pwd_cmd") shouldBe Some(JsString("/action"))
+    }
+  }
 }


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services