From e17ca0f878cc8c4af9f2fa08da1121b2d5be77b9 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Fri, 9 Feb 2018 15:24:35 -0600 Subject: [PATCH 01/19] new node js version folders --- runtimes/nodejs-6/actions/helloworld.js | 21 +++++++++++++++++++++ runtimes/nodejs-6/helloworld.js | 21 +++++++++++++++++++++ runtimes/nodejs-6/manifest.yaml | 14 ++++++++++++++ runtimes/nodejs-8/actions/helloworld.js | 21 +++++++++++++++++++++ runtimes/nodejs-8/helloworld.js | 21 +++++++++++++++++++++ runtimes/nodejs-8/manifest.yaml | 14 ++++++++++++++ 6 files changed, 112 insertions(+) create mode 100644 runtimes/nodejs-6/actions/helloworld.js create mode 100644 runtimes/nodejs-6/helloworld.js create mode 100644 runtimes/nodejs-6/manifest.yaml create mode 100644 runtimes/nodejs-8/actions/helloworld.js create mode 100644 runtimes/nodejs-8/helloworld.js create mode 100644 runtimes/nodejs-8/manifest.yaml diff --git a/runtimes/nodejs-6/actions/helloworld.js b/runtimes/nodejs-6/actions/helloworld.js new file mode 100644 index 0000000..21ec1ea --- /dev/null +++ b/runtimes/nodejs-6/actions/helloworld.js @@ -0,0 +1,21 @@ +/** + * + * main() will be invoked when you Run This Action. + * + * @param Cloud Functions actions accept a single parameter, + * which must be a JSON object. + * + * In this case, the params variable will look like: + * { "message": "xxxx" } + * + * @return which must be a JSON object. + * It will be the output of this action. + * + */ +function main(params) { + if (params.message) { + return { "greeting": "Hello " + params.message }; + } else { + return {"greeting": "Hello stranger!"} + } +} diff --git a/runtimes/nodejs-6/helloworld.js b/runtimes/nodejs-6/helloworld.js new file mode 100644 index 0000000..21ec1ea --- /dev/null +++ b/runtimes/nodejs-6/helloworld.js @@ -0,0 +1,21 @@ +/** + * + * main() will be invoked when you Run This Action. + * + * @param Cloud Functions actions accept a single parameter, + * which must be a JSON object. + * + * In this case, the params variable will look like: + * { "message": "xxxx" } + * + * @return which must be a JSON object. + * It will be the output of this action. + * + */ +function main(params) { + if (params.message) { + return { "greeting": "Hello " + params.message }; + } else { + return {"greeting": "Hello stranger!"} + } +} diff --git a/runtimes/nodejs-6/manifest.yaml b/runtimes/nodejs-6/manifest.yaml new file mode 100644 index 0000000..7844626 --- /dev/null +++ b/runtimes/nodejs-6/manifest.yaml @@ -0,0 +1,14 @@ +# Wskdeploy manifest for hello-world + +# Deployment using this manifest file creates the following OpenWhisk components: +# Package: openwhisk-helloworld +# Action: openwhisk-helloworld/helloworld.js + +packages: + $PACKAGE_NAME: + version: 1.0 + license: Apache-2.0 + namespace: _ + actions: + helloworld: + function: actions/helloworld.js diff --git a/runtimes/nodejs-8/actions/helloworld.js b/runtimes/nodejs-8/actions/helloworld.js new file mode 100644 index 0000000..21ec1ea --- /dev/null +++ b/runtimes/nodejs-8/actions/helloworld.js @@ -0,0 +1,21 @@ +/** + * + * main() will be invoked when you Run This Action. + * + * @param Cloud Functions actions accept a single parameter, + * which must be a JSON object. + * + * In this case, the params variable will look like: + * { "message": "xxxx" } + * + * @return which must be a JSON object. + * It will be the output of this action. + * + */ +function main(params) { + if (params.message) { + return { "greeting": "Hello " + params.message }; + } else { + return {"greeting": "Hello stranger!"} + } +} diff --git a/runtimes/nodejs-8/helloworld.js b/runtimes/nodejs-8/helloworld.js new file mode 100644 index 0000000..21ec1ea --- /dev/null +++ b/runtimes/nodejs-8/helloworld.js @@ -0,0 +1,21 @@ +/** + * + * main() will be invoked when you Run This Action. + * + * @param Cloud Functions actions accept a single parameter, + * which must be a JSON object. + * + * In this case, the params variable will look like: + * { "message": "xxxx" } + * + * @return which must be a JSON object. + * It will be the output of this action. + * + */ +function main(params) { + if (params.message) { + return { "greeting": "Hello " + params.message }; + } else { + return {"greeting": "Hello stranger!"} + } +} diff --git a/runtimes/nodejs-8/manifest.yaml b/runtimes/nodejs-8/manifest.yaml new file mode 100644 index 0000000..7844626 --- /dev/null +++ b/runtimes/nodejs-8/manifest.yaml @@ -0,0 +1,14 @@ +# Wskdeploy manifest for hello-world + +# Deployment using this manifest file creates the following OpenWhisk components: +# Package: openwhisk-helloworld +# Action: openwhisk-helloworld/helloworld.js + +packages: + $PACKAGE_NAME: + version: 1.0 + license: Apache-2.0 + namespace: _ + actions: + helloworld: + function: actions/helloworld.js From 155ac6a871d9aaf3bd11d204f744d17a5390ae12 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Mon, 12 Feb 2018 15:26:55 -0600 Subject: [PATCH 02/19] Update manifest.yaml --- runtimes/nodejs-8/manifest.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/runtimes/nodejs-8/manifest.yaml b/runtimes/nodejs-8/manifest.yaml index 7844626..bff2ae8 100644 --- a/runtimes/nodejs-8/manifest.yaml +++ b/runtimes/nodejs-8/manifest.yaml @@ -12,3 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.js + runtime: nodejs@8 From c44a5d490e38b08ebeb7a92cbcdc01160b83bd85 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Mon, 12 Feb 2018 15:54:54 -0600 Subject: [PATCH 03/19] Update manifest.yaml --- runtimes/nodejs-6/manifest.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/runtimes/nodejs-6/manifest.yaml b/runtimes/nodejs-6/manifest.yaml index 7844626..3bc64a8 100644 --- a/runtimes/nodejs-6/manifest.yaml +++ b/runtimes/nodejs-6/manifest.yaml @@ -12,3 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.js + runtime: nodejs@6 From 39179210dbaac41feb103eb3aef93653df255aad Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Mon, 12 Feb 2018 16:32:29 -0600 Subject: [PATCH 04/19] Update manifest.yaml --- runtimes/nodejs/manifest.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/runtimes/nodejs/manifest.yaml b/runtimes/nodejs/manifest.yaml index 7844626..07e498e 100644 --- a/runtimes/nodejs/manifest.yaml +++ b/runtimes/nodejs/manifest.yaml @@ -12,3 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.js + runtime: nodejs From 2fdcee2699e58195134554c8f5684f604cf48f7b Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Mon, 12 Feb 2018 21:19:36 -0600 Subject: [PATCH 05/19] Update manifest.yaml --- runtimes/nodejs-8/manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/nodejs-8/manifest.yaml b/runtimes/nodejs-8/manifest.yaml index bff2ae8..65bc18f 100644 --- a/runtimes/nodejs-8/manifest.yaml +++ b/runtimes/nodejs-8/manifest.yaml @@ -12,4 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.js - runtime: nodejs@8 + runtime: nodejs:8 From 7b01f3438603f41d3e6174853a740c301bef468b Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Mon, 12 Feb 2018 21:21:04 -0600 Subject: [PATCH 06/19] Update manifest.yaml --- runtimes/nodejs-6/manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/nodejs-6/manifest.yaml b/runtimes/nodejs-6/manifest.yaml index 3bc64a8..066685e 100644 --- a/runtimes/nodejs-6/manifest.yaml +++ b/runtimes/nodejs-6/manifest.yaml @@ -12,4 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.js - runtime: nodejs@6 + runtime: nodejs:6 From 12a10ace8781233c20a89d7798a5045984588cc6 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Tue, 13 Feb 2018 11:16:55 -0600 Subject: [PATCH 07/19] updating php & python manifest --- runtimes/php/manifest.yaml | 1 + runtimes/python/manifest.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/runtimes/php/manifest.yaml b/runtimes/php/manifest.yaml index 88ece2c..44ac35f 100644 --- a/runtimes/php/manifest.yaml +++ b/runtimes/php/manifest.yaml @@ -12,3 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.php + runtime: php:7.1 diff --git a/runtimes/python/manifest.yaml b/runtimes/python/manifest.yaml index 321410e..4352370 100644 --- a/runtimes/python/manifest.yaml +++ b/runtimes/python/manifest.yaml @@ -12,3 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.py + runtime: python:3 From 7c1aaab18206611fae4d30a37ac4bf61b7c15052 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Tue, 13 Feb 2018 15:02:43 -0600 Subject: [PATCH 08/19] updating with new runtimes --- runtimes/php-7.1/actions/helloworld.php | 22 +++++++++++++++++++ runtimes/php-7.1/manifest.yaml | 15 +++++++++++++ runtimes/php/manifest.yaml | 1 - runtimes/python-3/actions/helloworld.py | 21 ++++++++++++++++++ runtimes/python-3/manifest.yaml | 15 +++++++++++++ runtimes/python/manifest.yaml | 1 - runtimes/swift-3.1.1/actions/helloworld.swift | 21 ++++++++++++++++++ runtimes/swift-3.1.1/manifest.yaml | 15 +++++++++++++ runtimes/swift/manifest.yaml | 1 - 9 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 runtimes/php-7.1/actions/helloworld.php create mode 100644 runtimes/php-7.1/manifest.yaml create mode 100644 runtimes/python-3/actions/helloworld.py create mode 100644 runtimes/python-3/manifest.yaml create mode 100644 runtimes/swift-3.1.1/actions/helloworld.swift create mode 100644 runtimes/swift-3.1.1/manifest.yaml diff --git a/runtimes/php-7.1/actions/helloworld.php b/runtimes/php-7.1/actions/helloworld.php new file mode 100644 index 0000000..4004c09 --- /dev/null +++ b/runtimes/php-7.1/actions/helloworld.php @@ -0,0 +1,22 @@ + $greeting]; +} diff --git a/runtimes/php-7.1/manifest.yaml b/runtimes/php-7.1/manifest.yaml new file mode 100644 index 0000000..44ac35f --- /dev/null +++ b/runtimes/php-7.1/manifest.yaml @@ -0,0 +1,15 @@ +# Wskdeploy manifest for hello-world + +# Deployment using this manifest file creates the following OpenWhisk components: +# Package: openwhisk-helloworld +# Action: openwhisk-helloworld/helloworld.js + +packages: + $PACKAGE_NAME: + version: 1.0 + license: Apache-2.0 + namespace: _ + actions: + helloworld: + function: actions/helloworld.php + runtime: php:7.1 diff --git a/runtimes/php/manifest.yaml b/runtimes/php/manifest.yaml index 44ac35f..88ece2c 100644 --- a/runtimes/php/manifest.yaml +++ b/runtimes/php/manifest.yaml @@ -12,4 +12,3 @@ packages: actions: helloworld: function: actions/helloworld.php - runtime: php:7.1 diff --git a/runtimes/python-3/actions/helloworld.py b/runtimes/python-3/actions/helloworld.py new file mode 100644 index 0000000..9d0684c --- /dev/null +++ b/runtimes/python-3/actions/helloworld.py @@ -0,0 +1,21 @@ +# +# +# main() will be invoked when you Run This Action. +# +# @param Cloud Functions actions accept a single parameter, +# which must be a JSON object. +# +# @return which must be a JSON object. +# It will be the output of this action. +# +# +import sys + +def main(dict): + if 'message' in dict: + name = dict['message'] + else: + name = 'stranger' + greeting = 'Hello ' + name + '!' + print(greeting) + return {'greeting':greeting} diff --git a/runtimes/python-3/manifest.yaml b/runtimes/python-3/manifest.yaml new file mode 100644 index 0000000..4352370 --- /dev/null +++ b/runtimes/python-3/manifest.yaml @@ -0,0 +1,15 @@ +# Wskdeploy manifest for hello-world + +# Deployment using this manifest file creates the following OpenWhisk components: +# Package: openwhisk-helloworld +# Action: openwhisk-helloworld/helloworld.js + +packages: + $PACKAGE_NAME: + version: 1.0 + license: Apache-2.0 + namespace: _ + actions: + helloworld: + function: actions/helloworld.py + runtime: python:3 diff --git a/runtimes/python/manifest.yaml b/runtimes/python/manifest.yaml index 4352370..321410e 100644 --- a/runtimes/python/manifest.yaml +++ b/runtimes/python/manifest.yaml @@ -12,4 +12,3 @@ packages: actions: helloworld: function: actions/helloworld.py - runtime: python:3 diff --git a/runtimes/swift-3.1.1/actions/helloworld.swift b/runtimes/swift-3.1.1/actions/helloworld.swift new file mode 100644 index 0000000..a986798 --- /dev/null +++ b/runtimes/swift-3.1.1/actions/helloworld.swift @@ -0,0 +1,21 @@ +/** + * + * main() will be invoked when you Run This Action. + * + * @param Cloud Functions actions accept a single parameter, + * which must be a JSON object. + * + * In this case, the params variable will look like: + * { "message": "xxxx" } + * + * @return which must be a JSON object. + * It will be the output of this action. + * + */ +func main(args: [String:Any]) -> [String:Any] { + if let message = args["message"] as? String { + return [ "greeting" : "Hello \(message)!" ] + } else { + return [ "greeting" : "Hello stranger!" ] + } +} diff --git a/runtimes/swift-3.1.1/manifest.yaml b/runtimes/swift-3.1.1/manifest.yaml new file mode 100644 index 0000000..d099e2d --- /dev/null +++ b/runtimes/swift-3.1.1/manifest.yaml @@ -0,0 +1,15 @@ +# Wskdeploy manifest for hello-world + +# Deployment using this manifest file creates the following OpenWhisk components: +# Package: openwhisk-helloworld +# Action: openwhisk-helloworld/helloworld.js + +packages: + $PACKAGE_NAME: + version: 1.0 + license: Apache-2.0 + namespace: _ + actions: + helloworld: + function: actions/helloworld.swift + runtime: swift:3.1.1 diff --git a/runtimes/swift/manifest.yaml b/runtimes/swift/manifest.yaml index d099e2d..d56e338 100644 --- a/runtimes/swift/manifest.yaml +++ b/runtimes/swift/manifest.yaml @@ -12,4 +12,3 @@ packages: actions: helloworld: function: actions/helloworld.swift - runtime: swift:3.1.1 From 4de537d1bbfa330130060657b2ab29c3b7806447 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Tue, 13 Feb 2018 15:09:57 -0600 Subject: [PATCH 09/19] updating tests --- .../src/test/scala/templates/HelloTests.scala | 47 +++++++++++++++---- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/tests/src/test/scala/templates/HelloTests.scala b/tests/src/test/scala/templates/HelloTests.scala index 388920b..fe63de3 100644 --- a/tests/src/test/scala/templates/HelloTests.scala +++ b/tests/src/test/scala/templates/HelloTests.scala @@ -35,19 +35,20 @@ class HelloTests extends TestHelpers val wsk = new Wsk() //set parameters for deploy tests - val nodejsfolder = "../runtimes/nodejs/actions"; - val phpfolder = "../runtimes/php/actions"; - val pythonfolder = "../runtimes/python/actions"; - val swiftfolder = "../runtimes/swift/actions"; + val nodejs8folder = "../runtimes/nodejs-8/actions"; + val nodejs6folder = "../runtimes/nodejs-6/actions"; + val phpfolder = "../runtimes/php-7.1/actions"; + val pythonfolder = "../runtimes/python-3/actions"; + val swiftfolder = "../runtimes/swift-3.1.1/actions"; behavior of "Hello World Template" /** - * Test the nodejs "hello world" template + * Test the nodejs 8 "hello world" template */ it should "invoke helloworld.js and get the result" in withAssetCleaner(wskprops) { (wp, assetHelper) => val name = "helloNode" - val file = Some(new File(nodejsfolder, "helloworld.js").toString()); + val file = Some(new File(nodejs8folder, "helloworld.js").toString()); assetHelper.withCleaner(wsk.action, name) { (action, _) => action.create(name, file) } @@ -58,7 +59,7 @@ class HelloTests extends TestHelpers } it should "invoke helloworld.js without input and get stranger" in withAssetCleaner(wskprops) { (wp, assetHelper) => val name = "helloNode" - val file = Some(new File(nodejsfolder, "helloworld.js").toString()); + val file = Some(new File(nodejs8folder, "helloworld.js").toString()); assetHelper.withCleaner(wsk.action, name) { (action, _) => action.create(name, file) } @@ -67,8 +68,34 @@ class HelloTests extends TestHelpers _.response.result.get.toString should include("stranger") } } + + /** + * Test the nodejs 6 "hello world" template + */ + it should "invoke helloworld.js and get the result" in withAssetCleaner(wskprops) { (wp, assetHelper) => + val name = "helloNode" + val file = Some(new File(nodejs6folder, "helloworld.js").toString()); + assetHelper.withCleaner(wsk.action, name) { (action, _) => + action.create(name, file) + } + + withActivation(wsk.activation, wsk.action.invoke(name, Map("message" -> "Mindy".toJson))) { + _.response.result.get.toString should include("Mindy") + } + } + it should "invoke helloworld.js without input and get stranger" in withAssetCleaner(wskprops) { (wp, assetHelper) => + val name = "helloNode" + val file = Some(new File(nodejs6folder, "helloworld.js").toString()); + assetHelper.withCleaner(wsk.action, name) { (action, _) => + action.create(name, file) + } + + withActivation(wsk.activation, wsk.action.invoke(name)) { + _.response.result.get.toString should include("stranger") + } + } /** - * Test the php "hello world" template + * Test the php 7.1 "hello world" template */ it should "invoke helloworld.php and get the result" in withAssetCleaner(wskprops) { (wp, assetHelper) => val name = "helloPhp" @@ -93,7 +120,7 @@ class HelloTests extends TestHelpers } } /** - * Test the python "hello world" template + * Test the python 3 "hello world" template */ it should "invoke helloworld.py and get the result" in withAssetCleaner(wskprops) { (wp, assetHelper) => val name = "helloPython" @@ -118,7 +145,7 @@ class HelloTests extends TestHelpers } } /** - * Test the swift "hello world" template + * Test the swift 3.1.1 "hello world" template */ it should "invoke helloworld.swift and get the result" in withAssetCleaner(wskprops) { (wp, assetHelper) => val name = "helloSwift" From 2d7e944b1a075f1060f6911e4e00050fcdab7ea7 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Tue, 13 Feb 2018 15:12:30 -0600 Subject: [PATCH 10/19] removing explicit runtime from old file --- runtimes/nodejs/manifest.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/runtimes/nodejs/manifest.yaml b/runtimes/nodejs/manifest.yaml index 07e498e..7844626 100644 --- a/runtimes/nodejs/manifest.yaml +++ b/runtimes/nodejs/manifest.yaml @@ -12,4 +12,3 @@ packages: actions: helloworld: function: actions/helloworld.js - runtime: nodejs From 78a390ab2527a7311e0751b6b78820d0c0b17358 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Tue, 13 Feb 2018 15:14:19 -0600 Subject: [PATCH 11/19] replacing runtime for swift --- runtimes/swift/manifest.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/runtimes/swift/manifest.yaml b/runtimes/swift/manifest.yaml index d56e338..d099e2d 100644 --- a/runtimes/swift/manifest.yaml +++ b/runtimes/swift/manifest.yaml @@ -12,3 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.swift + runtime: swift:3.1.1 From cb2bb6ca3eb7f596fa74213a922f1a0e7bc75cda Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Tue, 13 Feb 2018 15:30:30 -0600 Subject: [PATCH 12/19] updating message to name --- README.md | 2 +- runtimes/nodejs-6/actions/helloworld.js | 6 +++--- runtimes/nodejs-6/helloworld.js | 6 +++--- runtimes/nodejs-8/actions/helloworld.js | 6 +++--- runtimes/nodejs-8/helloworld.js | 10 +++------- runtimes/nodejs/actions/helloworld.js | 6 +++--- runtimes/php-7.1/actions/helloworld.php | 4 ++-- runtimes/php/actions/helloworld.php | 4 ++-- runtimes/python-3/actions/helloworld.py | 4 ++-- runtimes/python/actions/helloworld.py | 4 ++-- runtimes/swift-3.1.1/actions/helloworld.swift | 6 +++--- runtimes/swift/actions/helloworld.swift | 6 +++--- 12 files changed, 30 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 366fc3a..85d2451 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ### Overview You can use this template to deploy some IBM Cloud Functions assets for you. The assets created by this template are described in the manifest.yaml file, which can be found at `template-hello-world/runtimes/your_language_choice/manifest.yaml` -The only assets described by this hello world template are a single action, named helloworld, which takes as input a message parameter. +The only assets described by this hello world template are a single action, named helloworld, which takes as input a name parameter. You can use the wskdeploy tool to deploy this asset yourself using the manifest and available code. diff --git a/runtimes/nodejs-6/actions/helloworld.js b/runtimes/nodejs-6/actions/helloworld.js index 21ec1ea..91a4aa8 100644 --- a/runtimes/nodejs-6/actions/helloworld.js +++ b/runtimes/nodejs-6/actions/helloworld.js @@ -6,15 +6,15 @@ * which must be a JSON object. * * In this case, the params variable will look like: - * { "message": "xxxx" } + * { "name": "xxxx" } * * @return which must be a JSON object. * It will be the output of this action. * */ function main(params) { - if (params.message) { - return { "greeting": "Hello " + params.message }; + if (params.name) { + return { "greeting": "Hello " + params.name }; } else { return {"greeting": "Hello stranger!"} } diff --git a/runtimes/nodejs-6/helloworld.js b/runtimes/nodejs-6/helloworld.js index 21ec1ea..91a4aa8 100644 --- a/runtimes/nodejs-6/helloworld.js +++ b/runtimes/nodejs-6/helloworld.js @@ -6,15 +6,15 @@ * which must be a JSON object. * * In this case, the params variable will look like: - * { "message": "xxxx" } + * { "name": "xxxx" } * * @return which must be a JSON object. * It will be the output of this action. * */ function main(params) { - if (params.message) { - return { "greeting": "Hello " + params.message }; + if (params.name) { + return { "greeting": "Hello " + params.name }; } else { return {"greeting": "Hello stranger!"} } diff --git a/runtimes/nodejs-8/actions/helloworld.js b/runtimes/nodejs-8/actions/helloworld.js index 21ec1ea..91a4aa8 100644 --- a/runtimes/nodejs-8/actions/helloworld.js +++ b/runtimes/nodejs-8/actions/helloworld.js @@ -6,15 +6,15 @@ * which must be a JSON object. * * In this case, the params variable will look like: - * { "message": "xxxx" } + * { "name": "xxxx" } * * @return which must be a JSON object. * It will be the output of this action. * */ function main(params) { - if (params.message) { - return { "greeting": "Hello " + params.message }; + if (params.name) { + return { "greeting": "Hello " + params.name }; } else { return {"greeting": "Hello stranger!"} } diff --git a/runtimes/nodejs-8/helloworld.js b/runtimes/nodejs-8/helloworld.js index 21ec1ea..bf0f1ac 100644 --- a/runtimes/nodejs-8/helloworld.js +++ b/runtimes/nodejs-8/helloworld.js @@ -6,16 +6,12 @@ * which must be a JSON object. * * In this case, the params variable will look like: - * { "message": "xxxx" } + * { "name": "xxxx" } * * @return which must be a JSON object. * It will be the output of this action. * */ -function main(params) { - if (params.message) { - return { "greeting": "Hello " + params.message }; - } else { - return {"greeting": "Hello stranger!"} - } +function main({name='Stranger'}) { + return { "greeting": "Hello " + name }; } diff --git a/runtimes/nodejs/actions/helloworld.js b/runtimes/nodejs/actions/helloworld.js index 21ec1ea..91a4aa8 100644 --- a/runtimes/nodejs/actions/helloworld.js +++ b/runtimes/nodejs/actions/helloworld.js @@ -6,15 +6,15 @@ * which must be a JSON object. * * In this case, the params variable will look like: - * { "message": "xxxx" } + * { "name": "xxxx" } * * @return which must be a JSON object. * It will be the output of this action. * */ function main(params) { - if (params.message) { - return { "greeting": "Hello " + params.message }; + if (params.name) { + return { "greeting": "Hello " + params.name }; } else { return {"greeting": "Hello stranger!"} } diff --git a/runtimes/php-7.1/actions/helloworld.php b/runtimes/php-7.1/actions/helloworld.php index 4004c09..4efae9a 100644 --- a/runtimes/php-7.1/actions/helloworld.php +++ b/runtimes/php-7.1/actions/helloworld.php @@ -7,7 +7,7 @@ * which must be a JSON object. * * In this case, the params variable will look like: - * { "message": "xxxx" } + * { "name": "xxxx" } * * @return which must be a JSON object. * It will be the output of this action. @@ -15,7 +15,7 @@ */ function main(array $args) : array { - $name = $args["message"] ?? "stranger"; + $name = $args["name"] ?? "stranger"; $greeting = "Hello $name!"; echo $greeting; return ["greeting" => $greeting]; diff --git a/runtimes/php/actions/helloworld.php b/runtimes/php/actions/helloworld.php index 4004c09..4efae9a 100644 --- a/runtimes/php/actions/helloworld.php +++ b/runtimes/php/actions/helloworld.php @@ -7,7 +7,7 @@ * which must be a JSON object. * * In this case, the params variable will look like: - * { "message": "xxxx" } + * { "name": "xxxx" } * * @return which must be a JSON object. * It will be the output of this action. @@ -15,7 +15,7 @@ */ function main(array $args) : array { - $name = $args["message"] ?? "stranger"; + $name = $args["name"] ?? "stranger"; $greeting = "Hello $name!"; echo $greeting; return ["greeting" => $greeting]; diff --git a/runtimes/python-3/actions/helloworld.py b/runtimes/python-3/actions/helloworld.py index 9d0684c..072729e 100644 --- a/runtimes/python-3/actions/helloworld.py +++ b/runtimes/python-3/actions/helloworld.py @@ -12,8 +12,8 @@ import sys def main(dict): - if 'message' in dict: - name = dict['message'] + if 'name' in dict: + name = dict['name'] else: name = 'stranger' greeting = 'Hello ' + name + '!' diff --git a/runtimes/python/actions/helloworld.py b/runtimes/python/actions/helloworld.py index 9d0684c..072729e 100644 --- a/runtimes/python/actions/helloworld.py +++ b/runtimes/python/actions/helloworld.py @@ -12,8 +12,8 @@ import sys def main(dict): - if 'message' in dict: - name = dict['message'] + if 'name' in dict: + name = dict['name'] else: name = 'stranger' greeting = 'Hello ' + name + '!' diff --git a/runtimes/swift-3.1.1/actions/helloworld.swift b/runtimes/swift-3.1.1/actions/helloworld.swift index a986798..96465c4 100644 --- a/runtimes/swift-3.1.1/actions/helloworld.swift +++ b/runtimes/swift-3.1.1/actions/helloworld.swift @@ -6,15 +6,15 @@ * which must be a JSON object. * * In this case, the params variable will look like: - * { "message": "xxxx" } + * { "name": "xxxx" } * * @return which must be a JSON object. * It will be the output of this action. * */ func main(args: [String:Any]) -> [String:Any] { - if let message = args["message"] as? String { - return [ "greeting" : "Hello \(message)!" ] + if let name = args["name"] as? String { + return [ "greeting" : "Hello \(name)!" ] } else { return [ "greeting" : "Hello stranger!" ] } diff --git a/runtimes/swift/actions/helloworld.swift b/runtimes/swift/actions/helloworld.swift index a986798..96465c4 100644 --- a/runtimes/swift/actions/helloworld.swift +++ b/runtimes/swift/actions/helloworld.swift @@ -6,15 +6,15 @@ * which must be a JSON object. * * In this case, the params variable will look like: - * { "message": "xxxx" } + * { "name": "xxxx" } * * @return which must be a JSON object. * It will be the output of this action. * */ func main(args: [String:Any]) -> [String:Any] { - if let message = args["message"] as? String { - return [ "greeting" : "Hello \(message)!" ] + if let name = args["name"] as? String { + return [ "greeting" : "Hello \(name)!" ] } else { return [ "greeting" : "Hello stranger!" ] } From b3c530d0c5f0fbcbaf00e169078c62f17e9bcf59 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Tue, 13 Feb 2018 15:59:45 -0600 Subject: [PATCH 13/19] updating tests and moving file --- runtimes/nodejs-6/actions/helloworld.js | 9 +++----- runtimes/nodejs-6/helloworld.js | 21 ------------------- runtimes/nodejs-8/actions/helloworld.js | 9 +++----- runtimes/nodejs-8/helloworld.js | 17 --------------- .../src/test/scala/templates/HelloTests.scala | 10 ++++----- 5 files changed, 11 insertions(+), 55 deletions(-) delete mode 100644 runtimes/nodejs-6/helloworld.js delete mode 100644 runtimes/nodejs-8/helloworld.js diff --git a/runtimes/nodejs-6/actions/helloworld.js b/runtimes/nodejs-6/actions/helloworld.js index 91a4aa8..9dfc4fb 100644 --- a/runtimes/nodejs-6/actions/helloworld.js +++ b/runtimes/nodejs-6/actions/helloworld.js @@ -12,10 +12,7 @@ * It will be the output of this action. * */ -function main(params) { - if (params.name) { - return { "greeting": "Hello " + params.name }; - } else { - return {"greeting": "Hello stranger!"} + function main(params) { + const name = params.name || "stranger" + return { "greeting": "Hello " + name + "!"}; } -} diff --git a/runtimes/nodejs-6/helloworld.js b/runtimes/nodejs-6/helloworld.js deleted file mode 100644 index 91a4aa8..0000000 --- a/runtimes/nodejs-6/helloworld.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * - * main() will be invoked when you Run This Action. - * - * @param Cloud Functions actions accept a single parameter, - * which must be a JSON object. - * - * In this case, the params variable will look like: - * { "name": "xxxx" } - * - * @return which must be a JSON object. - * It will be the output of this action. - * - */ -function main(params) { - if (params.name) { - return { "greeting": "Hello " + params.name }; - } else { - return {"greeting": "Hello stranger!"} - } -} diff --git a/runtimes/nodejs-8/actions/helloworld.js b/runtimes/nodejs-8/actions/helloworld.js index 91a4aa8..9dfc4fb 100644 --- a/runtimes/nodejs-8/actions/helloworld.js +++ b/runtimes/nodejs-8/actions/helloworld.js @@ -12,10 +12,7 @@ * It will be the output of this action. * */ -function main(params) { - if (params.name) { - return { "greeting": "Hello " + params.name }; - } else { - return {"greeting": "Hello stranger!"} + function main(params) { + const name = params.name || "stranger" + return { "greeting": "Hello " + name + "!"}; } -} diff --git a/runtimes/nodejs-8/helloworld.js b/runtimes/nodejs-8/helloworld.js deleted file mode 100644 index bf0f1ac..0000000 --- a/runtimes/nodejs-8/helloworld.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * - * main() will be invoked when you Run This Action. - * - * @param Cloud Functions actions accept a single parameter, - * which must be a JSON object. - * - * In this case, the params variable will look like: - * { "name": "xxxx" } - * - * @return which must be a JSON object. - * It will be the output of this action. - * - */ -function main({name='Stranger'}) { - return { "greeting": "Hello " + name }; -} diff --git a/tests/src/test/scala/templates/HelloTests.scala b/tests/src/test/scala/templates/HelloTests.scala index fe63de3..d1bf693 100644 --- a/tests/src/test/scala/templates/HelloTests.scala +++ b/tests/src/test/scala/templates/HelloTests.scala @@ -53,7 +53,7 @@ class HelloTests extends TestHelpers action.create(name, file) } - withActivation(wsk.activation, wsk.action.invoke(name, Map("message" -> "Mindy".toJson))) { + withActivation(wsk.activation, wsk.action.invoke(name, Map("name" -> "Mindy".toJson))) { _.response.result.get.toString should include("Mindy") } } @@ -79,7 +79,7 @@ class HelloTests extends TestHelpers action.create(name, file) } - withActivation(wsk.activation, wsk.action.invoke(name, Map("message" -> "Mindy".toJson))) { + withActivation(wsk.activation, wsk.action.invoke(name, Map("name" -> "Mindy".toJson))) { _.response.result.get.toString should include("Mindy") } } @@ -104,7 +104,7 @@ class HelloTests extends TestHelpers action.create(name, file) } - withActivation(wsk.activation, wsk.action.invoke(name, Map("message" -> "Mindy".toJson))) { + withActivation(wsk.activation, wsk.action.invoke(name, Map("name" -> "Mindy".toJson))) { _.response.result.get.toString should include("Mindy") } } @@ -129,7 +129,7 @@ class HelloTests extends TestHelpers action.create(name, file) } - withActivation(wsk.activation, wsk.action.invoke(name, Map("message" -> "Mindy".toJson))) { + withActivation(wsk.activation, wsk.action.invoke(name, Map("name" -> "Mindy".toJson))) { _.response.result.get.toString should include("Mindy") } } @@ -154,7 +154,7 @@ class HelloTests extends TestHelpers action.create(name, file) } - withActivation(wsk.activation, wsk.action.invoke(name, Map("message" -> "Mindy".toJson))) { + withActivation(wsk.activation, wsk.action.invoke(name, Map("name" -> "Mindy".toJson))) { _.response.result.get.toString should include("Mindy") } } From 7c80031a5aafda7f7cda8960ec62920d395fefeb Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Tue, 13 Feb 2018 22:09:28 -0600 Subject: [PATCH 14/19] rename test --- tests/src/test/scala/templates/HelloTests.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/src/test/scala/templates/HelloTests.scala b/tests/src/test/scala/templates/HelloTests.scala index d1bf693..2ad9db8 100644 --- a/tests/src/test/scala/templates/HelloTests.scala +++ b/tests/src/test/scala/templates/HelloTests.scala @@ -46,7 +46,7 @@ class HelloTests extends TestHelpers /** * Test the nodejs 8 "hello world" template */ - it should "invoke helloworld.js and get the result" in withAssetCleaner(wskprops) { (wp, assetHelper) => + it should "invoke nodejs 8 helloworld.js and get the result" in withAssetCleaner(wskprops) { (wp, assetHelper) => val name = "helloNode" val file = Some(new File(nodejs8folder, "helloworld.js").toString()); assetHelper.withCleaner(wsk.action, name) { (action, _) => @@ -57,7 +57,7 @@ class HelloTests extends TestHelpers _.response.result.get.toString should include("Mindy") } } - it should "invoke helloworld.js without input and get stranger" in withAssetCleaner(wskprops) { (wp, assetHelper) => + it should "invoke nodejs 8 helloworld.js without input and get stranger" in withAssetCleaner(wskprops) { (wp, assetHelper) => val name = "helloNode" val file = Some(new File(nodejs8folder, "helloworld.js").toString()); assetHelper.withCleaner(wsk.action, name) { (action, _) => @@ -72,7 +72,7 @@ class HelloTests extends TestHelpers /** * Test the nodejs 6 "hello world" template */ - it should "invoke helloworld.js and get the result" in withAssetCleaner(wskprops) { (wp, assetHelper) => + it should "invoke nodejs 6 helloworld.js and get the result" in withAssetCleaner(wskprops) { (wp, assetHelper) => val name = "helloNode" val file = Some(new File(nodejs6folder, "helloworld.js").toString()); assetHelper.withCleaner(wsk.action, name) { (action, _) => @@ -83,7 +83,7 @@ class HelloTests extends TestHelpers _.response.result.get.toString should include("Mindy") } } - it should "invoke helloworld.js without input and get stranger" in withAssetCleaner(wskprops) { (wp, assetHelper) => + it should "invoke nodejs 6 helloworld.js without input and get stranger" in withAssetCleaner(wskprops) { (wp, assetHelper) => val name = "helloNode" val file = Some(new File(nodejs6folder, "helloworld.js").toString()); assetHelper.withCleaner(wsk.action, name) { (action, _) => From efbe8533986825fb49f5c8135aa3e0be06bccda8 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Wed, 14 Feb 2018 14:34:06 -0600 Subject: [PATCH 15/19] linter updates --- runtimes/nodejs-6/actions/helloworld.js | 10 +++++++--- runtimes/nodejs-8/actions/helloworld.js | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/runtimes/nodejs-6/actions/helloworld.js b/runtimes/nodejs-6/actions/helloworld.js index 9dfc4fb..8e30651 100644 --- a/runtimes/nodejs-6/actions/helloworld.js +++ b/runtimes/nodejs-6/actions/helloworld.js @@ -12,7 +12,11 @@ * It will be the output of this action. * */ - function main(params) { - const name = params.name || "stranger" - return { "greeting": "Hello " + name + "!"}; +function main(params) { + if (params.name) { + return { greeting: `Hello ${params.name}` }; } + return { greeting: 'Hello stranger!' }; +} + +exports.main = main; diff --git a/runtimes/nodejs-8/actions/helloworld.js b/runtimes/nodejs-8/actions/helloworld.js index 9dfc4fb..8e30651 100644 --- a/runtimes/nodejs-8/actions/helloworld.js +++ b/runtimes/nodejs-8/actions/helloworld.js @@ -12,7 +12,11 @@ * It will be the output of this action. * */ - function main(params) { - const name = params.name || "stranger" - return { "greeting": "Hello " + name + "!"}; +function main(params) { + if (params.name) { + return { greeting: `Hello ${params.name}` }; } + return { greeting: 'Hello stranger!' }; +} + +exports.main = main; From f2e25e8e4cf399cc0996913f76b4c54ff6718732 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Mon, 19 Feb 2018 09:31:09 -0800 Subject: [PATCH 16/19] update python version --- runtimes/{python-3 => python-3.6.4}/actions/helloworld.py | 0 runtimes/{python-3 => python-3.6.4}/manifest.yaml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename runtimes/{python-3 => python-3.6.4}/actions/helloworld.py (100%) rename runtimes/{python-3 => python-3.6.4}/manifest.yaml (92%) diff --git a/runtimes/python-3/actions/helloworld.py b/runtimes/python-3.6.4/actions/helloworld.py similarity index 100% rename from runtimes/python-3/actions/helloworld.py rename to runtimes/python-3.6.4/actions/helloworld.py diff --git a/runtimes/python-3/manifest.yaml b/runtimes/python-3.6.4/manifest.yaml similarity index 92% rename from runtimes/python-3/manifest.yaml rename to runtimes/python-3.6.4/manifest.yaml index 4352370..b0b563c 100644 --- a/runtimes/python-3/manifest.yaml +++ b/runtimes/python-3.6.4/manifest.yaml @@ -12,4 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.py - runtime: python:3 + runtime: python:3.6.4 From a09b9e581fb6d47c0b9521979a9fcbbf3a407411 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Mon, 19 Feb 2018 09:56:24 -0800 Subject: [PATCH 17/19] Update manifest.yaml --- runtimes/python-3.6.4/manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/python-3.6.4/manifest.yaml b/runtimes/python-3.6.4/manifest.yaml index b0b563c..4352370 100644 --- a/runtimes/python-3.6.4/manifest.yaml +++ b/runtimes/python-3.6.4/manifest.yaml @@ -12,4 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.py - runtime: python:3.6.4 + runtime: python:3 From 687170c38d0948eef9eda5485ac858bc051cd9fd Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Mon, 19 Feb 2018 10:09:56 -0800 Subject: [PATCH 18/19] Update manifest.yaml --- runtimes/python-3.6.4/manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/python-3.6.4/manifest.yaml b/runtimes/python-3.6.4/manifest.yaml index 4352370..11bca29 100644 --- a/runtimes/python-3.6.4/manifest.yaml +++ b/runtimes/python-3.6.4/manifest.yaml @@ -12,4 +12,4 @@ packages: actions: helloworld: function: actions/helloworld.py - runtime: python:3 + runtime: python-jessie:3 From 764bd55eb8ad5536c09c631616491f1a5426fac4 Mon Sep 17 00:00:00 2001 From: Belinda Vennam Date: Mon, 19 Feb 2018 12:11:30 -0800 Subject: [PATCH 19/19] update py folder --- tests/src/test/scala/templates/HelloTests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/test/scala/templates/HelloTests.scala b/tests/src/test/scala/templates/HelloTests.scala index 2ad9db8..35c8c1b 100644 --- a/tests/src/test/scala/templates/HelloTests.scala +++ b/tests/src/test/scala/templates/HelloTests.scala @@ -38,7 +38,7 @@ class HelloTests extends TestHelpers val nodejs8folder = "../runtimes/nodejs-8/actions"; val nodejs6folder = "../runtimes/nodejs-6/actions"; val phpfolder = "../runtimes/php-7.1/actions"; - val pythonfolder = "../runtimes/python-3/actions"; + val pythonfolder = "../runtimes/python-3.6.4/actions"; val swiftfolder = "../runtimes/swift-3.1.1/actions"; behavior of "Hello World Template"