You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by mr...@apache.org on 2020/03/06 19:39:36 UTC
[openwhisk-test] branch master updated: Initial commit for input
and output for single entrypoint examples (#10)
This is an automated email from the ASF dual-hosted git repository.
mrutkowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-test.git
The following commit(s) were added to refs/heads/master by this push:
new ee58ea9 Initial commit for input and output for single entrypoint examples (#10)
ee58ea9 is described below
commit ee58ea91c4653c70a1bb8aae81f5cb33e8a0494c
Author: Will Plusnick <pw...@users.noreply.github.com>
AuthorDate: Fri Mar 6 13:39:28 2020 -0600
Initial commit for input and output for single entrypoint examples (#10)
* Initial commit for input and output for single entrypoint examples
* Add init, run, and init-run as separate input files
* Update single entrypoint example readme
* Add license headers
* Fix json typo
---
runtimes/proxy/single_entrypoint/README.md | 23 +++++++++++++++++++++
runtimes/proxy/single_entrypoint/hello_world.js | 20 ++++++++++++++++++
.../single_entrypoint/hello_world_with_params.js | 20 ++++++++++++++++++
.../input/hello_world-init-run.json | 20 ++++++++++++++++++
.../single_entrypoint/input/hello_world-init.json | 8 ++++++++
.../single_entrypoint/input/hello_world-run.json | 15 ++++++++++++++
.../input/hello_world_with_params-init-run.json | 20 ++++++++++++++++++
.../input/hello_world_with_params-init.json | 8 ++++++++
.../input/hello_world_with_params-run.json | 14 +++++++++++++
.../input/web_action_hello_world-init-run.json | 19 +++++++++++++++++
.../input/web_action_hello_world-init.json | 8 ++++++++
.../input/web_action_hello_world-run.json | 13 ++++++++++++
.../web_action_hello_world_no_input-init-run.json | 16 +++++++++++++++
.../web_action_hello_world_no_input-init.json | 8 ++++++++
.../input/web_action_hello_world_no_input-run.json | 10 +++++++++
.../input/web_action_raw-init-run.json | 19 +++++++++++++++++
.../input/web_action_raw-init.json | 8 ++++++++
.../input/web_action_raw-run.json | 13 ++++++++++++
.../single_entrypoint/output/hello_world.json | 3 +++
.../output/hello_world_with_params.json | 3 +++
.../output/web_action_hello_world.json | 1 +
.../output/web_action_hello_world_no_input.json | 1 +
.../single_entrypoint/output/web_action_raw.json | 16 +++++++++++++++
.../single_entrypoint/web_action_hello_world.js | 24 ++++++++++++++++++++++
.../web_action_hello_world_no_input.js | 24 ++++++++++++++++++++++
runtimes/proxy/single_entrypoint/web_action_raw.js | 20 ++++++++++++++++++
26 files changed, 354 insertions(+)
diff --git a/runtimes/proxy/single_entrypoint/README.md b/runtimes/proxy/single_entrypoint/README.md
new file mode 100644
index 0000000..bc620d6
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/README.md
@@ -0,0 +1,23 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+# Single Entrypoint Proxy
+
+This is a repo to store single entrypoint proxy example test cases, such as Knative Serving. All single entrypoint execution environments should follow the contract this defined in the single entrypoint documentation.
+
+The action code for each example is defined in the is directory, and the input directory has JSON files where the filename corresponds to the input for a the action code of the same file name, but with an -init, -run, or -init-run postfix. The output directory similarly has the expected output for that file.
diff --git a/runtimes/proxy/single_entrypoint/hello_world.js b/runtimes/proxy/single_entrypoint/hello_world.js
new file mode 100644
index 0000000..56a4ee7
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/hello_world.js
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the \"License\"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an \"AS IS\" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function main() {
+ return {payload: 'Hello World!'};
+}
diff --git a/runtimes/proxy/single_entrypoint/hello_world_with_params.js b/runtimes/proxy/single_entrypoint/hello_world_with_params.js
new file mode 100644
index 0000000..ae45363
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/hello_world_with_params.js
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the \"License\"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an \"AS IS\" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function main(params) {
+ return { payload: 'Hello ' + params.name + ' from ' + params.place + '!' };
+}
diff --git a/runtimes/proxy/single_entrypoint/input/hello_world-init-run.json b/runtimes/proxy/single_entrypoint/input/hello_world-init-run.json
new file mode 100644
index 0000000..89f2b29
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/hello_world-init-run.json
@@ -0,0 +1,20 @@
+{
+ "init": {
+ "name": "",
+ "main": "main",
+ "binary": false,
+ "code": "function main() { return {payload: 'Hello World!'};}"
+ },
+ "activation": {
+ "namespace": "default",
+ "action_name": "",
+ "api_host": "",
+ "api_key": "",
+ "activation_id": "",
+ "deadline": "4102498800000"
+ },
+ "value": {
+ "name": "Joe",
+ "place": "TX"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/hello_world-init.json b/runtimes/proxy/single_entrypoint/input/hello_world-init.json
new file mode 100644
index 0000000..9abb525
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/hello_world-init.json
@@ -0,0 +1,8 @@
+{
+ "init": {
+ "name": "",
+ "main": "main",
+ "binary": false,
+ "code": "function main() { return {payload: 'Hello World!'};}"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/hello_world-run.json b/runtimes/proxy/single_entrypoint/input/hello_world-run.json
new file mode 100644
index 0000000..a016aff
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/hello_world-run.json
@@ -0,0 +1,15 @@
+{
+ "activation": {
+ "namespace": "default",
+ "action_name": "",
+ "api_host": "",
+ "api_key": "",
+ "activation_id": "",
+ "deadline": "4102498800000"
+ },
+
+ "value": {
+ "name": "Joe",
+ "place": "TX"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/hello_world_with_params-init-run.json b/runtimes/proxy/single_entrypoint/input/hello_world_with_params-init-run.json
new file mode 100644
index 0000000..9bcd455
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/hello_world_with_params-init-run.json
@@ -0,0 +1,20 @@
+{
+ "init": {
+ "name": "",
+ "main": "main",
+ "binary": false,
+ "code": "function main(params) { return { payload: 'Hello ' + params.name + ' from ' + params.place + '!' };}"
+ },
+ "activation": {
+ "namespace": "default",
+ "action_name": "",
+ "api_host": "",
+ "api_key": "",
+ "activation_id": "",
+ "deadline": "4102498800000"
+ },
+ "value": {
+ "name": "Joe",
+ "place": "TX"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/hello_world_with_params-init.json b/runtimes/proxy/single_entrypoint/input/hello_world_with_params-init.json
new file mode 100644
index 0000000..a25ebf9
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/hello_world_with_params-init.json
@@ -0,0 +1,8 @@
+{
+ "init": {
+ "name": "",
+ "main": "main",
+ "binary": false,
+ "code": "function main(params) { return { payload: 'Hello ' + params.name + ' from ' + params.place + '!' };}"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/hello_world_with_params-run.json b/runtimes/proxy/single_entrypoint/input/hello_world_with_params-run.json
new file mode 100644
index 0000000..22d2f26
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/hello_world_with_params-run.json
@@ -0,0 +1,14 @@
+{
+ "activation": {
+ "namespace": "default",
+ "action_name": "",
+ "api_host": "",
+ "api_key": "",
+ "activation_id": "",
+ "deadline": "4102498800000"
+ },
+ "value": {
+ "name": "Joe",
+ "place": "TX"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/web_action_hello_world-init-run.json b/runtimes/proxy/single_entrypoint/input/web_action_hello_world-init-run.json
new file mode 100644
index 0000000..d65f090
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/web_action_hello_world-init-run.json
@@ -0,0 +1,19 @@
+{
+ "init": {
+ "name": "",
+ "main": "main",
+ "binary": false,
+ "code": "function main({name}) { var msg = 'you did not tell me who you are.'; if (name) { msg = `hello ${name}` } return {body: `<html><body><h3>{msg}</h3></body></html>`}}"
+ },
+ "activation": {
+ "namespace": "default",
+ "action_name": "",
+ "api_host": "",
+ "api_key": "",
+ "activation_id": "",
+ "deadline": "4102498800000"
+ },
+ "value": {
+ "name": "Joe"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/web_action_hello_world-init.json b/runtimes/proxy/single_entrypoint/input/web_action_hello_world-init.json
new file mode 100644
index 0000000..709dff7
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/web_action_hello_world-init.json
@@ -0,0 +1,8 @@
+{
+ "init": {
+ "name": "",
+ "main": "main",
+ "binary": false,
+ "code": "function main({name}) { var msg = 'you did not tell me who you are.'; if (name) { msg = `hello ${name}` } return {body: `<html><body><h3>{msg}</h3></body></html>`}}"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/web_action_hello_world-run.json b/runtimes/proxy/single_entrypoint/input/web_action_hello_world-run.json
new file mode 100644
index 0000000..8f409bf
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/web_action_hello_world-run.json
@@ -0,0 +1,13 @@
+{
+ "activation": {
+ "namespace": "default",
+ "action_name": "",
+ "api_host": "",
+ "api_key": "",
+ "activation_id": "",
+ "deadline": "4102498800000"
+ },
+ "value": {
+ "name": "Joe"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/web_action_hello_world_no_input-init-run.json b/runtimes/proxy/single_entrypoint/input/web_action_hello_world_no_input-init-run.json
new file mode 100644
index 0000000..dca5d6b
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/web_action_hello_world_no_input-init-run.json
@@ -0,0 +1,16 @@
+{
+ "init": {
+ "name": "",
+ "main": "main",
+ "binary": false,
+ "code": "function main({name}) { var msg = 'you did not tell me who you are.'; if (name) { msg = `hello ${name}` } return {body: `<html><body><h3>{msg}</h3></body></html>`}}"
+ },
+ "activation": {
+ "namespace": "default",
+ "action_name": "",
+ "api_host": "",
+ "api_key": "",
+ "activation_id": "",
+ "deadline": "4102498800000"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/web_action_hello_world_no_input-init.json b/runtimes/proxy/single_entrypoint/input/web_action_hello_world_no_input-init.json
new file mode 100644
index 0000000..709dff7
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/web_action_hello_world_no_input-init.json
@@ -0,0 +1,8 @@
+{
+ "init": {
+ "name": "",
+ "main": "main",
+ "binary": false,
+ "code": "function main({name}) { var msg = 'you did not tell me who you are.'; if (name) { msg = `hello ${name}` } return {body: `<html><body><h3>{msg}</h3></body></html>`}}"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/web_action_hello_world_no_input-run.json b/runtimes/proxy/single_entrypoint/input/web_action_hello_world_no_input-run.json
new file mode 100644
index 0000000..3e5a626
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/web_action_hello_world_no_input-run.json
@@ -0,0 +1,10 @@
+{
+ "activation": {
+ "namespace": "default",
+ "action_name": "",
+ "api_host": "",
+ "api_key": "",
+ "activation_id": "",
+ "deadline": "4102498800000"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/web_action_raw-init-run.json b/runtimes/proxy/single_entrypoint/input/web_action_raw-init-run.json
new file mode 100644
index 0000000..03da7e5
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/web_action_raw-init-run.json
@@ -0,0 +1,19 @@
+{
+ "init": {
+ "name": "",
+ "main": "main",
+ "binary": false,
+ "code": "function main(params) { return { response: params };}"
+ },
+ "activation": {
+ "namespace": "default",
+ "action_name": "",
+ "api_host": "",
+ "api_key": "",
+ "activation_id": "",
+ "deadline": "4102498800000"
+ },
+ "value": {
+ "name": "Joe"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/web_action_raw-init.json b/runtimes/proxy/single_entrypoint/input/web_action_raw-init.json
new file mode 100644
index 0000000..d5687ed
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/web_action_raw-init.json
@@ -0,0 +1,8 @@
+{
+ "init": {
+ "name": "",
+ "main": "main",
+ "binary": false,
+ "code": "function main(params) { return { response: params };}"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/input/web_action_raw-run.json b/runtimes/proxy/single_entrypoint/input/web_action_raw-run.json
new file mode 100644
index 0000000..c11eea3
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/input/web_action_raw-run.json
@@ -0,0 +1,13 @@
+{
+ "activation": {
+ "namespace": "default",
+ "action_name": "",
+ "api_host": "",
+ "api_key": "",
+ "activation_id": "",
+ "deadline": "4102498800000"
+ },
+ "value": {
+ "name": "Joe"
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/output/hello_world.json b/runtimes/proxy/single_entrypoint/output/hello_world.json
new file mode 100644
index 0000000..19ddd69
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/output/hello_world.json
@@ -0,0 +1,3 @@
+{
+ "payload": "Hello World!"
+}
diff --git a/runtimes/proxy/single_entrypoint/output/hello_world_with_params.json b/runtimes/proxy/single_entrypoint/output/hello_world_with_params.json
new file mode 100644
index 0000000..974352e
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/output/hello_world_with_params.json
@@ -0,0 +1,3 @@
+{
+ "payload": "Hello Joe from TX!"
+}
diff --git a/runtimes/proxy/single_entrypoint/output/web_action_hello_world.json b/runtimes/proxy/single_entrypoint/output/web_action_hello_world.json
new file mode 100644
index 0000000..fc6691f
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/output/web_action_hello_world.json
@@ -0,0 +1 @@
+<html><body><h3>hello Joe</h3></body></html>
diff --git a/runtimes/proxy/single_entrypoint/output/web_action_hello_world_no_input.json b/runtimes/proxy/single_entrypoint/output/web_action_hello_world_no_input.json
new file mode 100644
index 0000000..d173bbe
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/output/web_action_hello_world_no_input.json
@@ -0,0 +1 @@
+<html><body><h3>you did not tell me who you are.</h3></body></html>
diff --git a/runtimes/proxy/single_entrypoint/output/web_action_raw.json b/runtimes/proxy/single_entrypoint/output/web_action_raw.json
new file mode 100644
index 0000000..25f1989
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/output/web_action_raw.json
@@ -0,0 +1,16 @@
+{
+ "response": {
+ "__ow_body": "eyJuYW1lIjoiSm9lIn0=",
+ "__ow_query": {},
+ "__ow_user": "",
+ "__ow_method": "POST",
+ "__ow_headers": {
+ "host": "localhost",
+ "user-agent": "curl/7.54.0",
+ "accept": "*/*",
+ "content-type": "application/json",
+ "content-length": "394"
+ },
+ "__ow_path": ""
+ }
+}
diff --git a/runtimes/proxy/single_entrypoint/web_action_hello_world.js b/runtimes/proxy/single_entrypoint/web_action_hello_world.js
new file mode 100644
index 0000000..ab5390e
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/web_action_hello_world.js
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the \"License\"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an \"AS IS\" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function main({name}) {
+ var msg = 'you did not tell me who you are.';
+ if (name) {
+ msg = `hello ${name}`
+ }
+ return {body: `<html><body><h3>{msg}</h3></body></html>`}
+}
diff --git a/runtimes/proxy/single_entrypoint/web_action_hello_world_no_input.js b/runtimes/proxy/single_entrypoint/web_action_hello_world_no_input.js
new file mode 100644
index 0000000..ab5390e
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/web_action_hello_world_no_input.js
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the \"License\"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an \"AS IS\" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function main({name}) {
+ var msg = 'you did not tell me who you are.';
+ if (name) {
+ msg = `hello ${name}`
+ }
+ return {body: `<html><body><h3>{msg}</h3></body></html>`}
+}
diff --git a/runtimes/proxy/single_entrypoint/web_action_raw.js b/runtimes/proxy/single_entrypoint/web_action_raw.js
new file mode 100644
index 0000000..5971754
--- /dev/null
+++ b/runtimes/proxy/single_entrypoint/web_action_raw.js
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the \"License\"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an \"AS IS\" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function main(params) {
+ return { response: params };
+}