Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 34e926a

Browse files
authored
Merge pull request #112 from andresmgot/k0.6.0
Upgrade Kubeless version to 0.6.0. Add golang example
2 parents f5b21c5 + d21a56b commit 34e926a

File tree

7 files changed

+88
-2
lines changed

7 files changed

+88
-2
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- docker
1111
env:
1212
global:
13-
- KUBELESS_VERSION: v0.5.0
13+
- KUBELESS_VERSION: v0.6.0
1414
- MINIKUBE_VERSION: v0.25.2
1515
- REPO_DOMAIN: serverless
1616
- REPO_NAME: serverless-kubeless

examples/post-go/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Simple Hello World function
2+
3+
This function returns the given data capitalizing the first word.
4+
5+
```console
6+
$ npm install
7+
$ serverless deploy
8+
$ serverless invoke -f go-echo -l --data 'hello!'
9+
Serverless: Calling function: go-echo...
10+
--------------------------------------------------------------------
11+
hello!
12+
$ serverless remove
13+
```

examples/post-go/handler.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package kubeless
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/kubeless/kubeless/pkg/functions"
7+
)
8+
9+
// Handler sample function with data
10+
func Handler(event functions.Event, context functions.Context) (string, error) {
11+
fmt.Println(event)
12+
return event.Data, nil
13+
}

examples/post-go/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "go-echo",
3+
"version": "1.0.0",
4+
"description": "Example function for serverless kubeless",
5+
"dependencies": {
6+
"serverless-kubeless": "^0.4.0"
7+
},
8+
"devDependencies": {},
9+
"scripts": {
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"author": "",
13+
"license": "Apache-2.0"
14+
}

examples/post-go/serverless.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
service: go-echo
2+
3+
provider:
4+
name: kubeless
5+
runtime: go1.10
6+
7+
plugins:
8+
- serverless-kubeless
9+
10+
functions:
11+
go-echo:
12+
handler: handler.Handler

scripts/integration-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ install_kubecfg() {
2424

2525
install_kubeless() {
2626
kubectl create ns kubeless
27-
kubectl create -f https://github.com/kubeless/kubeless/releases/download/$KUBELESS_VERSION/kubeless-rbac-$KUBELESS_VERSION.yaml
27+
kubectl create -f https://github.com/kubeless/kubeless/releases/download/$KUBELESS_VERSION/kubeless-$KUBELESS_VERSION.yaml
2828
kubectl create -f https://github.com/kubeless/kubeless/releases/download/$KUBELESS_VERSION/kafka-zookeeper-$KUBELESS_VERSION.yaml
2929
curl -LO https://github.com/kubeless/kubeless/releases/download/$KUBELESS_VERSION/kubeless_linux-amd64.zip
3030
unzip kubeless_linux-amd64.zip

test/examples-test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ describe('Examples', () => {
104104
'post-nodejs': { cwd: null, path: 'post-nodejs' },
105105
'post-python': { cwd: null, path: 'post-python' },
106106
'post-php': { cwd: null, path: 'post-php' },
107+
'post-go': { cwd: null, path: 'post-go' },
107108
'post-ruby': { cwd: null, path: 'post-ruby' },
108109
'scheduled-node': { cwd: null, path: 'scheduled-node' },
109110
'todo-app': { cwd: null, path: 'todo-app/backend' },
@@ -386,6 +387,39 @@ describe('Examples', () => {
386387
});
387388
});
388389
});
390+
describe('post-go', function () {
391+
const exampleName = 'post-go';
392+
before(function (done) {
393+
examples[exampleName].cwd = path.join(cwd, examples[exampleName].path);
394+
this.timeout(300000);
395+
prepareExample(cwd, exampleName, (e) => {
396+
if (e) {
397+
throw e;
398+
}
399+
deployExample(examples[exampleName].cwd, (ee) => {
400+
if (ee) {
401+
throw ee;
402+
}
403+
done();
404+
});
405+
});
406+
});
407+
after(function (done) {
408+
this.timeout(100000);
409+
removeExample(examples[exampleName].cwd, () => {
410+
done();
411+
});
412+
});
413+
this.timeout(10000);
414+
it('should return a "hello"', (done) => {
415+
exec('serverless invoke -f go-echo -l --data \'hello!\'',
416+
{ cwd: examples['post-go'].cwd }, (err, stdout) => {
417+
if (err) throw err;
418+
expect(stdout).to.contain('hello!');
419+
done();
420+
});
421+
});
422+
});
389423
describe('scheduled-node', function () {
390424
const exampleName = 'scheduled-node';
391425
before(function (done) {

0 commit comments

Comments
 (0)