Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit bd13e99

Browse files
bvennamcsantanapr
authored andcommitted
updating with explicit runtimes (#3)
1 parent bea90e0 commit bd13e99

File tree

16 files changed

+237
-27
lines changed

16 files changed

+237
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
### Overview
44
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`
55

6-
The only assets described by this hello world template are a single action, named helloworld, which takes as input a message parameter.
6+
The only assets described by this hello world template are a single action, named helloworld, which takes as input a name parameter.
77

88
You can use the wskdeploy tool to deploy this asset yourself using the manifest and available code.
99

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
*
3+
* main() will be invoked when you Run This Action.
4+
*
5+
* @param Cloud Functions actions accept a single parameter,
6+
* which must be a JSON object.
7+
*
8+
* In this case, the params variable will look like:
9+
* { "name": "xxxx" }
10+
*
11+
* @return which must be a JSON object.
12+
* It will be the output of this action.
13+
*
14+
*/
15+
function main(params) {
16+
if (params.name) {
17+
return { greeting: `Hello ${params.name}` };
18+
}
19+
return { greeting: 'Hello stranger!' };
20+
}
21+
22+
exports.main = main;

runtimes/nodejs-6/manifest.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Wskdeploy manifest for hello-world
2+
3+
# Deployment using this manifest file creates the following OpenWhisk components:
4+
# Package: openwhisk-helloworld
5+
# Action: openwhisk-helloworld/helloworld.js
6+
7+
packages:
8+
$PACKAGE_NAME:
9+
version: 1.0
10+
license: Apache-2.0
11+
namespace: _
12+
actions:
13+
helloworld:
14+
function: actions/helloworld.js
15+
runtime: nodejs:6
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
*
3+
* main() will be invoked when you Run This Action.
4+
*
5+
* @param Cloud Functions actions accept a single parameter,
6+
* which must be a JSON object.
7+
*
8+
* In this case, the params variable will look like:
9+
* { "name": "xxxx" }
10+
*
11+
* @return which must be a JSON object.
12+
* It will be the output of this action.
13+
*
14+
*/
15+
function main(params) {
16+
if (params.name) {
17+
return { greeting: `Hello ${params.name}` };
18+
}
19+
return { greeting: 'Hello stranger!' };
20+
}
21+
22+
exports.main = main;

runtimes/nodejs-8/manifest.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Wskdeploy manifest for hello-world
2+
3+
# Deployment using this manifest file creates the following OpenWhisk components:
4+
# Package: openwhisk-helloworld
5+
# Action: openwhisk-helloworld/helloworld.js
6+
7+
packages:
8+
$PACKAGE_NAME:
9+
version: 1.0
10+
license: Apache-2.0
11+
namespace: _
12+
actions:
13+
helloworld:
14+
function: actions/helloworld.js
15+
runtime: nodejs:8

runtimes/nodejs/actions/helloworld.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
* which must be a JSON object.
77
*
88
* In this case, the params variable will look like:
9-
* { "message": "xxxx" }
9+
* { "name": "xxxx" }
1010
*
1111
* @return which must be a JSON object.
1212
* It will be the output of this action.
1313
*
1414
*/
1515
function main(params) {
16-
if (params.message) {
17-
return { "greeting": "Hello " + params.message };
16+
if (params.name) {
17+
return { "greeting": "Hello " + params.name };
1818
} else {
1919
return {"greeting": "Hello stranger!"}
2020
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
*
4+
* main() will be invoked when you Run This Action.
5+
*
6+
* @param Cloud Functions actions accept a single parameter,
7+
* which must be a JSON object.
8+
*
9+
* In this case, the params variable will look like:
10+
* { "name": "xxxx" }
11+
*
12+
* @return which must be a JSON object.
13+
* It will be the output of this action.
14+
*
15+
*/
16+
function main(array $args) : array
17+
{
18+
$name = $args["name"] ?? "stranger";
19+
$greeting = "Hello $name!";
20+
echo $greeting;
21+
return ["greeting" => $greeting];
22+
}

runtimes/php-7.1/manifest.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Wskdeploy manifest for hello-world
2+
3+
# Deployment using this manifest file creates the following OpenWhisk components:
4+
# Package: openwhisk-helloworld
5+
# Action: openwhisk-helloworld/helloworld.js
6+
7+
packages:
8+
$PACKAGE_NAME:
9+
version: 1.0
10+
license: Apache-2.0
11+
namespace: _
12+
actions:
13+
helloworld:
14+
function: actions/helloworld.php
15+
runtime: php:7.1

runtimes/php/actions/helloworld.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
* which must be a JSON object.
88
*
99
* In this case, the params variable will look like:
10-
* { "message": "xxxx" }
10+
* { "name": "xxxx" }
1111
*
1212
* @return which must be a JSON object.
1313
* It will be the output of this action.
1414
*
1515
*/
1616
function main(array $args) : array
1717
{
18-
$name = $args["message"] ?? "stranger";
18+
$name = $args["name"] ?? "stranger";
1919
$greeting = "Hello $name!";
2020
echo $greeting;
2121
return ["greeting" => $greeting];
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
#
3+
# main() will be invoked when you Run This Action.
4+
#
5+
# @param Cloud Functions actions accept a single parameter,
6+
# which must be a JSON object.
7+
#
8+
# @return which must be a JSON object.
9+
# It will be the output of this action.
10+
#
11+
#
12+
import sys
13+
14+
def main(dict):
15+
if 'name' in dict:
16+
name = dict['name']
17+
else:
18+
name = 'stranger'
19+
greeting = 'Hello ' + name + '!'
20+
print(greeting)
21+
return {'greeting':greeting}

0 commit comments

Comments
 (0)