You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ra...@apache.org on 2019/12/14 23:22:40 UTC

[openwhisk-runtime-php] branch master updated (0db49c9 -> 71c5821)

This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-runtime-php.git.


    from 0db49c9  Update for action version. (#71)
     new c05b859  travis - dist:xenial and language:java
     new d91e35d  The parameters need to be set up as environment variables so that getenv() can retrieve them too
     new 3e89f42  Add test for getenv/$_ENV equivalence.
     new a2f3ad3  Add getenv support to PHP 7.1 and 7.2 runtimes
     new 71c5821  Update changelog for getenv() support

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .travis.yml                                        |  8 +--
 core/php7.1Action/CHANGELOG.md                     |  1 +
 core/php7.1Action/router.php                       |  5 +-
 core/php7.2Action/CHANGELOG.md                     |  3 +-
 core/php7.2Action/router.php                       |  5 +-
 core/php7.3Action/CHANGELOG.md                     |  1 +
 core/php7.3Action/Dockerfile                       | 18 ++++---
 core/php7.3Action/runner.php                       |  8 +--
 .../Php7ActionContainerTests.scala                 | 57 ++++++++++++++++++++++
 9 files changed, 85 insertions(+), 21 deletions(-)


[openwhisk-runtime-php] 04/05: Add getenv support to PHP 7.1 and 7.2 runtimes

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-runtime-php.git

commit a2f3ad3bf9cddc8e13c08f0bb797ad4fb8f4adb1
Author: Rob Allen <ro...@akrabat.com>
AuthorDate: Sat Dec 14 19:33:27 2019 +0000

    Add getenv support to PHP 7.1 and 7.2 runtimes
---
 core/php7.1Action/router.php | 4 +++-
 core/php7.2Action/router.php | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/core/php7.1Action/router.php b/core/php7.1Action/router.php
index eadc153..db63b7d 100644
--- a/core/php7.1Action/router.php
+++ b/core/php7.1Action/router.php
@@ -199,7 +199,9 @@ function run() : array
     $env['PHP_VERSION'] = $_ENV['PHP_VERSION'];
     foreach (array_keys($post) as $param) {
         if ($param !== "value") {
-            $env['__OW_' . strtoupper($param)] = $post[$param];
+            $envKeyName = '__OW_' . strtoupper($param);
+            $env[$envKeyName] = $post[$param];
+            putenv($envKeyName . '=' . $post[$param]);
         }
     }
 
diff --git a/core/php7.2Action/router.php b/core/php7.2Action/router.php
index 3bf01a1..78c5108 100644
--- a/core/php7.2Action/router.php
+++ b/core/php7.2Action/router.php
@@ -220,7 +220,9 @@ function run() : array
     // assign environment variables from the posted data
     foreach (array_keys($post) as $param) {
         if ($param !== "value") {
-            $_ENV['__OW_' . strtoupper($param)] = $post[$param];
+            $envKeyName = '__OW_' . strtoupper($param);
+            $_ENV[$envKeyName] = $post[$param];
+            putenv($envKeyName . '=' . $post[$param]);
         }
     }
 


[openwhisk-runtime-php] 03/05: Add test for getenv/$_ENV equivalence.

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-runtime-php.git

commit 3e89f427d000c1bda97fb9dc2e42ffcfd17097f8
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Sat Dec 14 13:34:33 2019 -0500

    Add test for getenv/$_ENV equivalence.
---
 core/php7.3Action/Dockerfile                       | 18 ++++---
 .../Php7ActionContainerTests.scala                 | 57 ++++++++++++++++++++++
 2 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/core/php7.3Action/Dockerfile b/core/php7.3Action/Dockerfile
index a7663e5..d601299 100644
--- a/core/php7.3Action/Dockerfile
+++ b/core/php7.3Action/Dockerfile
@@ -15,14 +15,16 @@
 # limitations under the License.
 #
 
-FROM golang:1.11 as builder
-ENV PROXY_SOURCE=https://github.com/apache/openwhisk-runtime-go/archive/golang1.11@1.13.0-incubating.tar.gz
-RUN curl -L "$PROXY_SOURCE" | tar xzf - \
-  && mkdir -p src/github.com/apache \
-  && mv openwhisk-runtime-go-golang1.11-1.13.0-incubating \
-     src/github.com/apache/incubator-openwhisk-runtime-go \
-  && cd src/github.com/apache/incubator-openwhisk-runtime-go/main \
-  && CGO_ENABLED=0 go build -o /bin/proxy
+FROM golang:1.12 as builder
+RUN env CGO_ENABLED=0 go get github.com/apache/openwhisk-runtime-go/main && mv /go/bin/main /bin/proxy
+#ENV PROXY_SOURCE=https://github.com/apache/openwhisk-runtime-go/archive/golang1.11@1.13.0-incubating.tar.gz
+#RUN curl -L "$PROXY_SOURCE" | tar xzf - \
+#  && mkdir -p src/github.com/apache \
+#  && mv openwhisk-runtime-go-golang1.11-1.13.0-incubating \
+#     src/github.com/apache/incubator-openwhisk-runtime-go \
+#  && cd src/github.com/apache/incubator-openwhisk-runtime-go/main \
+#  && CGO_ENABLED=0 go build -o /bin/proxy
+
 FROM php:7.3.6-cli-stretch
 
 # install dependencies
diff --git a/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
index 0af4983..f8446e5 100644
--- a/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
+++ b/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
@@ -24,6 +24,7 @@ import actionContainers.{ActionContainer, BasicActionRunnerTests}
 import actionContainers.ActionContainer.withContainer
 import actionContainers.ResourceHelpers.ZipBuilder
 import spray.json._
+import spray.json.DefaultJsonProtocol._
 
 @RunWith(classOf[JUnitRunner])
 abstract class Php7ActionContainerTests extends BasicActionRunnerTests with WskActorSystem {
@@ -158,6 +159,62 @@ abstract class Php7ActionContainerTests extends BasicActionRunnerTests with WskA
 
   }
 
+  it should s"confirm getenv can read environment variables" in {
+    val config = {
+      TestConfig(
+        """
+          |<?php
+          |function main(array $args) : array {
+          |    return [
+          |       "api_host" => getenv('__OW_API_HOST'),
+          |       "api_key" => getenv('__OW_API_KEY'),
+          |       "namespace" => getenv('__OW_NAMESPACE'),
+          |       "action_name" => getenv('__OW_ACTION_NAME'),
+          |       "action_version" => getenv('__OW_ACTION_VERSION'),
+          |       "activation_id" => getenv('__OW_ACTIVATION_ID'),
+          |       "deadline" => getenv('__OW_DEADLINE'),
+          |    ];
+          |}
+        """.stripMargin.trim,
+        enforceEmptyOutputStream = enforceEmptyOutputStream)
+    }
+
+    val props = Seq(
+      "api_host" -> "xyz",
+      "api_key" -> "abc",
+      "namespace" -> "zzz",
+      "action_name" -> "xxx",
+      "action_version" -> "0.0.1",
+      "activation_id" -> "iii",
+      "deadline" -> "123")
+
+    val env = props.map { case (k, v) => s"__OW_${k.toUpperCase()}" -> v }
+
+    // the api host is sent as a docker run environment parameter
+    val (out, err) = withActionContainer(env.take(1).toMap) { c =>
+      val (initCode, _) = c.init(initPayload(config.code, config.main))
+      initCode should be(200)
+
+      // we omit the api host from the run payload so the docker run env var is used
+      val (runCode, out) = c.run(runPayload(JsObject.empty, Some(props.drop(1).toMap.toJson.asJsObject)))
+      runCode should be(200)
+      out shouldBe defined
+      props.map {
+        case (k, v) =>
+          withClue(k) {
+            out.get.fields(k) shouldBe JsString(v)
+          }
+
+      }
+    }
+
+    checkStreams(out, err, {
+      case (o, e) =>
+        if (config.enforceEmptyOutputStream) o shouldBe empty
+        if (config.enforceEmptyErrorStream) e shouldBe empty
+    })
+  }
+
   it should "support application errors" in {
     withPhp7Container { c =>
       val code = """


[openwhisk-runtime-php] 01/05: travis - dist:xenial and language:java

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-runtime-php.git

commit c05b85972fe2792b13e8d4705ffa5b56223a3947
Author: David Grove <gr...@us.ibm.com>
AuthorDate: Fri Nov 22 10:17:35 2019 -0500

    travis - dist:xenial and language:java
---
 .travis.yml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 0a4d4ba..acf58e9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,12 +16,12 @@
 #
 
 sudo: required
-group: deprecated-2017Q3
-language: scala
-scala:
-  - 2.12.7
+dist: xenial
+jdk: openjdk8
+language: java
 services:
   - docker
+
 notifications:
   email: false
   webhooks:


[openwhisk-runtime-php] 05/05: Update changelog for getenv() support

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-runtime-php.git

commit 71c5821a8f15a06d46adfab7b40252977458e092
Author: Rob Allen <ro...@akrabat.com>
AuthorDate: Sat Dec 14 21:34:31 2019 +0000

    Update changelog for getenv() support
---
 core/php7.1Action/CHANGELOG.md | 1 +
 core/php7.2Action/CHANGELOG.md | 3 ++-
 core/php7.3Action/CHANGELOG.md | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/core/php7.1Action/CHANGELOG.md b/core/php7.1Action/CHANGELOG.md
index b32fa53..b12368f 100644
--- a/core/php7.1Action/CHANGELOG.md
+++ b/core/php7.1Action/CHANGELOG.md
@@ -20,6 +20,7 @@
 ## Apache 1.14.0 (next release)
 Changes:
   - Update version of PHP to 7.1.30
+  - Support getenv()
 
 ## Apache 1.13.0-incubating
 Changes:
diff --git a/core/php7.2Action/CHANGELOG.md b/core/php7.2Action/CHANGELOG.md
index 5d361ae..879e17f 100644
--- a/core/php7.2Action/CHANGELOG.md
+++ b/core/php7.2Action/CHANGELOG.md
@@ -17,9 +17,10 @@
 #
 -->
 
-## Apache 1.14.0-incubating (next release)
+## Apache 1.14.0 (next release)
 Changes:
   - Update version of PHP to 7.2.19
+  - Support getenv()
 
 ## Apache 1.13.0-incubating
 Changes:
diff --git a/core/php7.3Action/CHANGELOG.md b/core/php7.3Action/CHANGELOG.md
index 2e5d708..4c44cf3 100644
--- a/core/php7.3Action/CHANGELOG.md
+++ b/core/php7.3Action/CHANGELOG.md
@@ -20,6 +20,7 @@
 Changes:
   - Update version of PHP to 7.3.6
   - Added PHP extension mongodb
+  - Support getenv()
 
 
 ## Apache 1.13.0-incubating


[openwhisk-runtime-php] 02/05: The parameters need to be set up as environment variables so that getenv() can retrieve them too

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-runtime-php.git

commit d91e35dd9f53b1491892b236863586d8c7dd036d
Author: Rob Allen <ro...@akrabat.com>
AuthorDate: Sat Dec 14 13:45:14 2019 -0500

    The parameters need to be set up as environment variables so that
    getenv() can retrieve them too
---
 core/php7.1Action/router.php | 1 -
 core/php7.2Action/router.php | 1 -
 core/php7.3Action/runner.php | 8 ++++----
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/core/php7.1Action/router.php b/core/php7.1Action/router.php
index 1ec8ecb..eadc153 100644
--- a/core/php7.1Action/router.php
+++ b/core/php7.1Action/router.php
@@ -208,7 +208,6 @@ function run() : array
     if (array_key_exists('value', $post) && is_array($post['value'])) {
         $args = json_encode($post['value']);
     }
-    $env['WHISK_INPUT'] = $args;
 
     // run the action
     list($returnCode, $stdout, $stderr) = runPHP(
diff --git a/core/php7.2Action/router.php b/core/php7.2Action/router.php
index c3ada90..3bf01a1 100644
--- a/core/php7.2Action/router.php
+++ b/core/php7.2Action/router.php
@@ -229,7 +229,6 @@ function run() : array
     if (array_key_exists('value', $post) && is_array($post['value'])) {
         $args = $post['value'];
     }
-    $_ENV['WHISK_INPUT'] = json_encode($args);
 
     // run the action
     require __DIR__ . '/src/vendor/autoload.php';
diff --git a/core/php7.3Action/runner.php b/core/php7.3Action/runner.php
index 6941986..5923818 100755
--- a/core/php7.3Action/runner.php
+++ b/core/php7.3Action/runner.php
@@ -49,10 +49,10 @@ while ($f = fgets(STDIN)) {
 
     // convert all parameters other than value to environment variables
     foreach ($data as $key => $value) {
-        if ($key == 'value') {
-            $_ENV['WHISK_INPUT'] = $data['value'] ?? [];
-        } else {
-            $_ENV['__OW_' . strtoupper($key)] = $value;
+        if ($key !== 'value') {
+            $envKeyName = '__OW_' . strtoupper($key);
+            $_ENV[$envKeyName] = $value;
+            putenv($envKeyName . '=' . $value);
         }
     }