Skip to content

Commit

Permalink
Adapt templates and docs to Kubeless 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres committed Mar 28, 2018
1 parent 63f15f6 commit 93d48f3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
8 changes: 4 additions & 4 deletions docs/providers/kubeless/guide/debugging.md
Expand Up @@ -20,8 +20,8 @@ Let's imagine that we have deployed the following Python code as a Kubeless func
import urllib2
import json

def find(request):
term = request.json["term"]
def find(event, context):
term = event['data']['term']
url = "https://feeds.capitalbikeshare.com/stations/stations.json"
response = urllib2.urlopen(url)
stations = json.loads(response.read())
Expand Down Expand Up @@ -126,7 +126,7 @@ Traceback (most recent call last):
File "/kubeless.py", line 35, in handler
return func(bottle.request)
File "/kubeless/handler.py", line 5, in find
term = request.json["term"]
term = event['data']['term']
KeyError: 'term'
172.17.0.1 - - [25/Aug/2017:08:46:16 +0000] "POST / HTTP/1.1" 500 746 "" "" 0/6703
172.17.0.1 - - [25/Aug/2017:08:46:34 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/122
Expand All @@ -145,7 +145,7 @@ Traceback (most recent call last):
File "/kubeless.py", line 35, in handler
return func(bottle.request)
File "/kubeless/handler.py", line 5, in find
term = request.json["term"]
term = event['data']['term']
KeyError: 'term'
```

Expand Down
12 changes: 2 additions & 10 deletions lib/plugins/create/templates/kubeless-nodejs/handler.js
Expand Up @@ -3,15 +3,7 @@
const _ = require('lodash');

module.exports = {
capitalize(req, res) {
let body = [];
req.on('error', (err) => {
console.error(err);
}).on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
res.end(_.capitalize(body));
});
capitalize(event, context) {
return _.capitalize(event.data);
},
};
2 changes: 1 addition & 1 deletion lib/plugins/create/templates/kubeless-nodejs/package.json
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "Example function for serverless kubeless",
"dependencies": {
"serverless-kubeless": "^0.2.4",
"serverless-kubeless": "^0.4.0",
"lodash": "^4.1.0"
},
"devDependencies": {},
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/create/templates/kubeless-python/handler.py
@@ -1,10 +1,10 @@
import json


def hello(request):
def hello(event, context):
body = {
"message": "Go Serverless v1.0! Your function executed successfully!",
"input": request.json
"input": event['data']
}

response = {
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/create/templates/kubeless-python/package.json
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "Sample Kubeless Python serverless framework service.",
"dependencies": {
"serverless-kubeless": "^0.2.4"
"serverless-kubeless": "^0.4.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down

0 comments on commit 93d48f3

Please sign in to comment.