You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/08/08 20:00:53 UTC

[GitHub] pritidesai closed pull request #285: adding scripts/manifest

pritidesai closed pull request #285: adding scripts/manifest
URL: https://github.com/apache/incubator-openwhisk-website/pull/285
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services