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/05/24 18:44:02 UTC

[GitHub] houshengbo closed pull request #933: replacing cat with a simple helloworld example

houshengbo closed pull request #933: replacing cat with a simple helloworld example
URL: https://github.com/apache/incubator-openwhisk-wskdeploy/pull/933
 
 
   

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/tests/src/integration/zipaction/actions/cat/index.js b/tests/src/integration/zipaction/actions/cat/index.js
deleted file mode 100644
index 89d0f487..00000000
--- a/tests/src/integration/zipaction/actions/cat/index.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one or more contributor
-// license agreements; and to You under the Apache License, Version 2.0.
-
-function myAction(args) {
-    var cat = require('cat');
-    cat('https://baidu.com', console.log);
-}
-exports.main = myAction;
diff --git a/tests/src/integration/zipaction/actions/cat/node_modules/.bin/cat b/tests/src/integration/zipaction/actions/cat/node_modules/.bin/cat
deleted file mode 120000
index a618fc35..00000000
--- a/tests/src/integration/zipaction/actions/cat/node_modules/.bin/cat
+++ /dev/null
@@ -1 +0,0 @@
-../cat/bin.js
\ No newline at end of file
diff --git a/tests/src/integration/zipaction/actions/cat/node_modules/cat/README.md b/tests/src/integration/zipaction/actions/cat/node_modules/cat/README.md
deleted file mode 100644
index 71e3a96a..00000000
--- a/tests/src/integration/zipaction/actions/cat/node_modules/cat/README.md
+++ /dev/null
@@ -1,43 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# cat
-
-cat will read the contents of an url. it's available through npm
-
-    npm install cat
-
-it will read your files
-
-```js
-var cat = require('cat');
-
-cat('myfile.txt', console.log);             // reads the file as utf-8 and returns it output
-cat('file://myfile.txt', console.log);      // same as above
-```
-
-and your `http` / `https` urls
-
-```js
-cat('http://google.com', console.log);      // cat also follows any redirects
-cat('https://github.com', console.log);     // and cat read https
-cat('http://fail.google.com', console.log); // if a status code != 2xx is received it will
-                                            // call the callback with an error.
-
-```
diff --git a/tests/src/integration/zipaction/actions/cat/node_modules/cat/bin.js b/tests/src/integration/zipaction/actions/cat/node_modules/cat/bin.js
deleted file mode 100755
index 697d1f68..00000000
--- a/tests/src/integration/zipaction/actions/cat/node_modules/cat/bin.js
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env node
-// Licensed to the Apache Software Foundation (ASF) under one or more contributor
-// license agreements; and to You under the Apache License, Version 2.0.
-
-var fs = require('fs')
-
-var input = process.argv.slice(2)
-
-var loop = function() {
-  if (!input.length) return
-  var next = input.shift()
-  var s = next === '-' ? process.stdin : fs.createReadStream(next)
-  s.on('end', loop).pipe(process.stdout)
-}
-
-loop()
diff --git a/tests/src/integration/zipaction/actions/cat/node_modules/cat/example.js b/tests/src/integration/zipaction/actions/cat/node_modules/cat/example.js
deleted file mode 100644
index 4a6e857c..00000000
--- a/tests/src/integration/zipaction/actions/cat/node_modules/cat/example.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one or more contributor
-// license agreements; and to You under the Apache License, Version 2.0.
-
-var cat = require('./index');
-
-cat(__filename, console.log);
-
-cat('https://raw.github.com/mafintosh/cat/master/example.js', console.log);
diff --git a/tests/src/integration/zipaction/actions/cat/node_modules/cat/index.js b/tests/src/integration/zipaction/actions/cat/node_modules/cat/index.js
deleted file mode 100644
index 49f2e48a..00000000
--- a/tests/src/integration/zipaction/actions/cat/node_modules/cat/index.js
+++ /dev/null
@@ -1,57 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one or more contributor
-// license agreements; and to You under the Apache License, Version 2.0.
-
-var fs = require('fs');
-var parse = require('url').parse;
-
-var catter = function(lib) {
-    var cat = function(url, callback) {
-        if (typeof url === 'string') {
-            url = parse(url);
-        }
-        lib.get({host:url.hostname, port:url.port, path:url.pathname}, function(response) {
-            if (/3\d\d/.test(response.statusCode) && response.headers.location) {
-                cat(parse(response.headers.location), callback);
-                return;
-            }
-            if (!(/2\d\d/).test(response.statusCode)) {
-                callback(new Error('non 2xx status code: ' + response.statusCode));
-                return;
-            }
-            var buffer = '';
-
-            response.setEncoding('utf-8');
-            response.on('data', function(data) {
-                buffer += data;
-            });
-            response.on('close', function() {
-                callback(new Error('unexpected close of response'));
-            });
-            response.on('end', function() {
-                callback(null, buffer);
-            });
-        }).on('error', callback);
-    };
-    return cat;
-};
-
-var http = catter(require('http'));
-var https = catter(require('https'));
-
-module.exports = function(location, callback) {
-    var protocol = (location.match(/^(\w+):\/\//) || [])[1] || 'file';
-
-    if (protocol === 'file') {
-        fs.readFile(location.replace(/^(file:\/\/localhost|file:\/\/)/, ''), 'utf-8', callback);
-        return;
-    }
-    if (protocol === 'http') {
-        http(location, callback);
-        return;
-    }
-    if (protocol === 'https') {
-        https(location, callback);
-        return;
-    }
-    throw new Error('protocol '+protocol+' currently not supported :(');
-};
diff --git a/tests/src/integration/zipaction/actions/cat/node_modules/cat/package.json b/tests/src/integration/zipaction/actions/cat/node_modules/cat/package.json
deleted file mode 100644
index 355bc25d..00000000
--- a/tests/src/integration/zipaction/actions/cat/node_modules/cat/package.json
+++ /dev/null
@@ -1,74 +0,0 @@
-{
-  "_args": [
-    [
-      {
-        "raw": "cat@0.2.0",
-        "scope": null,
-        "escapedName": "cat",
-        "name": "cat",
-        "rawSpec": "0.2.0",
-        "spec": "0.2.0",
-        "type": "version"
-      },
-      "/Users/dliu/go_work/src/github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/zipaction/actions/cat"
-    ]
-  ],
-  "_from": "cat@0.2.0",
-  "_id": "cat@0.2.0",
-  "_inCache": true,
-  "_location": "/cat",
-  "_npmUser": {
-    "name": "mafintosh",
-    "email": "mathiasbuus@gmail.com"
-  },
-  "_npmVersion": "1.4.9",
-  "_phantomChildren": {},
-  "_requested": {
-    "raw": "cat@0.2.0",
-    "scope": null,
-    "escapedName": "cat",
-    "name": "cat",
-    "rawSpec": "0.2.0",
-    "spec": "0.2.0",
-    "type": "version"
-  },
-  "_requiredBy": [
-    "/"
-  ],
-  "_resolved": "https://registry.npmjs.org/cat/-/cat-0.2.0.tgz",
-  "_shasum": "fd850cda7d4162e6904f33b7fcf743b1243fd434",
-  "_shrinkwrap": null,
-  "_spec": "cat@0.2.0",
-  "_where": "/Users/dliu/go_work/src/github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/zipaction/actions/cat",
-  "author": {
-    "name": "Mathias Buus Madsen",
-    "email": "mathiasbuus@gmail.com"
-  },
-  "bin": {
-    "cat": "bin.js"
-  },
-  "dependencies": {},
-  "description": "cat will read the contents of an url",
-  "devDependencies": {},
-  "directories": {},
-  "dist": {
-    "shasum": "fd850cda7d4162e6904f33b7fcf743b1243fd434",
-    "tarball": "https://registry.npmjs.org/cat/-/cat-0.2.0.tgz"
-  },
-  "homepage": "https://github.com/mafintosh/cat",
-  "keywords": [
-    "cat",
-    "util",
-    "request"
-  ],
-  "maintainers": [
-    {
-      "name": "mafintosh",
-      "email": "m@ge.tt"
-    }
-  ],
-  "name": "cat",
-  "optionalDependencies": {},
-  "readme": "ERROR: No README data found!",
-  "version": "0.2.0"
-}
diff --git a/tests/src/integration/zipaction/actions/cat/package.json b/tests/src/integration/zipaction/actions/cat/package.json
deleted file mode 100644
index 63282146..00000000
--- a/tests/src/integration/zipaction/actions/cat/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-  "name": "my-action",
-  "main": "index.js",
-  "dependencies" : {
-    "cat" : "0.2.0"
-  }
-}
diff --git a/tests/src/integration/zipaction/actions/greeting/index.js b/tests/src/integration/zipaction/actions/greeting/index.js
new file mode 100644
index 00000000..38c3ad8f
--- /dev/null
+++ b/tests/src/integration/zipaction/actions/greeting/index.js
@@ -0,0 +1,16 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+function main(params) {
+    var name = params.name || params.payload || 'stranger';
+    var place = params.place || 'somewhere';
+    return {payload:  'Hello, ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git a/tests/src/integration/zipaction/actions/greeting/package.json b/tests/src/integration/zipaction/actions/greeting/package.json
new file mode 100644
index 00000000..80cb6cd9
--- /dev/null
+++ b/tests/src/integration/zipaction/actions/greeting/package.json
@@ -0,0 +1,6 @@
+{
+   "name": "my-action",
+   "main": "index.js",
+   "dependencies" : {
+   }
+}
diff --git a/tests/src/integration/zipaction/deployment.yml b/tests/src/integration/zipaction/deployment.yml
index 99a65bc9..55a48a6c 100644
--- a/tests/src/integration/zipaction/deployment.yml
+++ b/tests/src/integration/zipaction/deployment.yml
@@ -2,11 +2,11 @@
 # license agreements; and to You under the Apache License, Version 2.0.
 
 project:
-  name: wskdeploy-samples
-  packages:
-    zipaction:
-      actions:
-        cat:
-          inputs:
-            name: Bernie
-            place: Vermont
+    name: wskdeploy-samples
+    packages:
+        zipaction:
+            actions:
+                greeting:
+                    inputs:
+                        name: Bernie
+                        place: Vermont
diff --git a/tests/src/integration/zipaction/manifest.yml b/tests/src/integration/zipaction/manifest.yml
index 59104f8e..de0bf942 100644
--- a/tests/src/integration/zipaction/manifest.yml
+++ b/tests/src/integration/zipaction/manifest.yml
@@ -2,16 +2,16 @@
 # license agreements; and to You under the Apache License, Version 2.0.
 
 packages:
-  zipaction:
-      version: 1.0
-      license: Apache-2.0
-      actions:
-        cat:
-          version: 1.0
-          function: actions/cat
-          runtime: nodejs:6
-          inputs:
-            name: string
-            place: string
-          outputs:
-            payload: string
+    zipaction:
+        version: 1.0
+        license: Apache-2.0
+        actions:
+            greeting:
+                version: 1.0
+                function: actions/greeting
+                runtime: nodejs:6
+                inputs:
+                    name: string
+                    place: string
+                outputs:
+                    payload: string


 

----------------------------------------------------------------
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