Skip to content

Commit c356da2

Browse files
authored
Merge pull request #63 from csantanapr/os_chdir
makes current directory for action correct
2 parents 2de1d29 + 6fbd349 commit c356da2

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
## Apache 1.13.0 (next release)
2323
Changes:
2424
- Update base python image to `python:3.6-alpine`
25+
- Update current directory for action to be root of zip
2526

2627
## 1.3.3 (Apache 1.12.0)
2728
Changes:

core/actionProxy/actionproxy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def __init__(self, source=None, binary=None, zipdest=None):
5252
self.source = source if source else defaultBinary
5353
self.binary = binary if binary else defaultBinary
5454
self.zipdest = zipdest if zipdest else os.path.dirname(self.source)
55+
os.chdir(os.path.dirname(self.source))
5556

5657
def preinit(self):
5758
return

tests/src/test/scala/runtime/actionContainers/ActionProxyContainerTests.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,20 @@ class ActionProxyContainerTests extends BasicActionRunnerTests with WskActorSyst
252252
e shouldBe empty
253253
})
254254
}
255+
256+
it should "support current directory be action location" in {
257+
withActionContainer() { c =>
258+
val code = """
259+
|#!/bin/bash
260+
|echo "{\"pwd_env\":\"$PWD\",\"pwd_cmd\":\"$(pwd)\"}"
261+
""".stripMargin.trim
262+
263+
val (initCode, initRes) = c.init(initPayload(code))
264+
initCode should be(200)
265+
266+
val (_, runRes) = c.run(runPayload(JsObject()))
267+
runRes.get.fields.get("pwd_env") shouldBe Some(JsString("/action"))
268+
runRes.get.fields.get("pwd_cmd") shouldBe Some(JsString("/action"))
269+
}
270+
}
255271
}

0 commit comments

Comments
 (0)