You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by pd...@apache.org on 2018/08/08 20:00:53 UTC
[incubator-openwhisk-website] branch master updated: adding
scripts/manifest (#285)
This is an automated email from the ASF dual-hosted git repository.
pdesai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-website.git
The following commit(s) were added to refs/heads/master by this push:
new 9068545 adding scripts/manifest (#285)
9068545 is described below
commit 9068545263f68b82cb365b34f7aee2d6aec5f1c2
Author: Priti Desai <pd...@us.ibm.com>
AuthorDate: Wed Aug 8 13:00:51 2018 -0700
adding scripts/manifest (#285)
---
code/Hello.java | 19 +++++++++++++++++++
code/hello-with-params.js | 3 +++
code/hello.go | 25 +++++++++++++++++++++++++
code/hello.js | 3 +++
code/hello.php | 8 ++++++++
code/hello.py | 8 ++++++++
code/manifest-for-helloJS-1.yaml | 5 +++++
code/manifest-for-helloJS-2.yaml | 10 ++++++++++
code/manifest-for-helloPhp-1.yaml | 5 +++++
code/manifest-for-helloPhp-2.yaml | 14 ++++++++++++++
code/manifest-for-helloPy-1.yaml | 5 +++++
code/manifest-for-helloPy-2.yaml | 15 +++++++++++++++
12 files changed, 120 insertions(+)
diff --git a/code/Hello.java b/code/Hello.java
new file mode 100644
index 0000000..516c1d0
--- /dev/null
+++ b/code/Hello.java
@@ -0,0 +1,19 @@
+package hello;
+
+import com.google.gson.JsonObject;
+
+public class Hello {
+ public static JsonObject main(JsonObject args)
+ String name;
+
+ try {
+ name = args.getAsJsonPrimitive("name").getAsString();
+ } catch(Exception e) {
+ name = "stranger";
+ }
+
+ JsonObject response = new JsonObject();
+ response.addProperty("greeting", "Hello " + name + "!");
+ return response;
+ }
+}
diff --git a/code/hello-with-params.js b/code/hello-with-params.js
new file mode 100644
index 0000000..6fb00e3
--- /dev/null
+++ b/code/hello-with-params.js
@@ -0,0 +1,3 @@
+function main(params) {
+ return {payload: 'Hello, ' + params.name + ' from ' + params.place};
+}
diff --git a/code/hello.go b/code/hello.go
new file mode 100644
index 0000000..149c22b
--- /dev/null
+++ b/code/hello.go
@@ -0,0 +1,25 @@
+package main
+
+import "encoding/json"
+import "fmt"
+import "os"
+
+func main() {
+ //program receives one argument: the JSON object as a string
+ arg := os.Args[1]
+
+ // unmarshal the string to a JSON object
+ var obj map[string]interface{}
+ json.Unmarshal([]byte(arg), &obj)
+
+ // can optionally log to stdout (or stderr)
+ fmt.Println("hello Go action")
+
+ name, ok := obj["name"].(string)
+ if !ok { name = "Stranger" }
+
+ // last line of stdout is the result JSON object as a string
+ msg := map[string]string{"msg": ("Hello, " + name + "!")}
+ res, _ := json.Marshal(msg)
+ fmt.Println(string(res))
+}
diff --git a/code/hello.js b/code/hello.js
new file mode 100644
index 0000000..685fd4e
--- /dev/null
+++ b/code/hello.js
@@ -0,0 +1,3 @@
+function main() {
+ return {payload: 'Hello world'};
+}
diff --git a/code/hello.php b/code/hello.php
new file mode 100644
index 0000000..ce75126
--- /dev/null
+++ b/code/hello.php
@@ -0,0 +1,8 @@
+<?php
+function main(array $args) : array
+{
+ $name = $args["name"] ?? "stranger";
+ $greeting = "Hello $name!";
+ echo $greeting;
+ return ["greeting" => $greeting];
+}
diff --git a/code/hello.py b/code/hello.py
new file mode 100644
index 0000000..eb436b7
--- /dev/null
+++ b/code/hello.py
@@ -0,0 +1,8 @@
+def main(dict):
+ if 'name' in dict:
+ name = dict['name']
+ else:
+ name = "stranger"
+ greeting = "Hello " + name + "!"
+ print(greeting)
+ return {"greeting": greeting}
diff --git a/code/manifest-for-helloJS-1.yaml b/code/manifest-for-helloJS-1.yaml
new file mode 100644
index 0000000..c5a2d5a
--- /dev/null
+++ b/code/manifest-for-helloJS-1.yaml
@@ -0,0 +1,5 @@
+packages:
+ default:
+ actions:
+ helloJS:
+ function: hello.js
diff --git a/code/manifest-for-helloJS-2.yaml b/code/manifest-for-helloJS-2.yaml
new file mode 100644
index 0000000..e01efb1
--- /dev/null
+++ b/code/manifest-for-helloJS-2.yaml
@@ -0,0 +1,10 @@
+packages:
+ default:
+ actions:
+ helloJS:
+ code: |
+ function main() {
+ return {payload: 'Hello world'};
+ }
+ runtime: nodejs:6
+
diff --git a/code/manifest-for-helloPhp-1.yaml b/code/manifest-for-helloPhp-1.yaml
new file mode 100644
index 0000000..aa84921
--- /dev/null
+++ b/code/manifest-for-helloPhp-1.yaml
@@ -0,0 +1,5 @@
+packages:
+ default:
+ actions:
+ helloPHP:
+ function: hello.php
diff --git a/code/manifest-for-helloPhp-2.yaml b/code/manifest-for-helloPhp-2.yaml
new file mode 100644
index 0000000..55d2e2e
--- /dev/null
+++ b/code/manifest-for-helloPhp-2.yaml
@@ -0,0 +1,14 @@
+packages:
+ default:
+ actions:
+ helloPHP:
+ code: |
+ <?php
+ function main(array $args) : array
+ {
+ $name = $args["name"] ?? "stranger";
+ $greeting = "Hello $name!";
+ echo $greeting;
+ return ["greeting" => $greeting];
+ }
+ runtime: php:7.1
diff --git a/code/manifest-for-helloPy-1.yaml b/code/manifest-for-helloPy-1.yaml
new file mode 100644
index 0000000..baf767b
--- /dev/null
+++ b/code/manifest-for-helloPy-1.yaml
@@ -0,0 +1,5 @@
+packages:
+ default:
+ actions:
+ helloPy:
+ function: hello.py
diff --git a/code/manifest-for-helloPy-2.yaml b/code/manifest-for-helloPy-2.yaml
new file mode 100644
index 0000000..ed10e9f
--- /dev/null
+++ b/code/manifest-for-helloPy-2.yaml
@@ -0,0 +1,15 @@
+packages:
+ default:
+ actions:
+ helloPy:
+ code: |
+ import sys
+ def main(dict):
+ if 'name' in dict:
+ name = dict['name']
+ else:
+ name = "stranger"
+ greeting = "Hello " + name + "!"
+ print(greeting)
+ return {"greeting": greeting}
+ runtime: python:2