Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tencent provider create-template #6898

Merged
merged 7 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/plugins/create/templates/tencent-go1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: all deps clean build
all: deps clean build
deps:
go get github.com/tencentyun/scf-go-lib/cloudfunction

clean:
rm -rf ./index

build:
GOOS=linux GOARCH=amd64 go build -o ./index .
18 changes: 18 additions & 0 deletions lib/plugins/create/templates/tencent-go1/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Serverless directories
.serverless

# golang output binary directory
bin

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
22 changes: 22 additions & 0 deletions lib/plugins/create/templates/tencent-go1/index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"context"
"fmt"
"github.com/tencentyun/scf-go-lib/cloudfunction"
)

type DefineEvent struct {
Key1 string `json:"key1"`
Key2 string `json:"key2"`
}

func hello(ctx context.Context, event DefineEvent) (string, error) {
fmt.Println("key1:", event.Key1)
fmt.Println("key2:", event.Key2)
return fmt.Sprintf("Hello World"), nil
}

func main() {
cloudfunction.Start(hello)
}
14 changes: 14 additions & 0 deletions lib/plugins/create/templates/tencent-go1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "tencent-golang",
"version": "1.0.0",
"description": "Tencent Serverless Cloud Function example using Golang",
"main": "index.go",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "cloud.tencent.com",
"license": "MIT",
"devDependencies": {
"serverless-tencent-scf": "*"
}
}
88 changes: 88 additions & 0 deletions lib/plugins/create/templates/tencent-go1/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
#
# Happy Coding!

service: my-service # service name

provider: # provider information
name: tencent
runtime: Go1
credentials: ~/credentials

# you can overwrite defaults here
# stage: dev
# cosBucket: DEFAULT
# role: QCS_SCFExcuteRole
# memorySize: 256
# timeout: 10
# region: ap-shanghai
# environment:
# variables:
# ENV_FIRST: env1
# ENV_SECOND: env2

plugins:
- serverless-tencent-scf

# you can add packaging information here
#package:
# exclude:
# - ./**
# include:
# - ./bin/**


functions:
function_one:
handler: main
# description: Tencent Serverless Cloud Function
# runtime: Go1
# memorySize: 256
# timeout: 10
# environment:
# variables:
# ENV_FIRST: env1
# ENV_Third: env2
# events:
# - timer:
# name: timer
# parameters:
# cronExpression: '*/5 * * * *'
# enable: true
# - cos:
# name: cli-appid.cos.ap-beijing.myqcloud.com
# parameters:
# bucket: cli-appid.cos.ap-beijing.myqcloud.com
# filter:
# prefix: filterdir/
# suffix: .jpg
# events: cos:ObjectCreated:*
# enable: true
# - apigw:
# name: hello_world_apigw
# parameters:
# stageName: release
# serviceId:
# httpMethod: ANY
# - cmq:
# name: cmq_trigger
# parameters:
# name: test-topic-queue
# enable: true
# - ckafka:
# name: ckafka_trigger
# parameters:
# name: ckafka-2o10hua5
# topic: test
# maxMsgNum: 999
# offset: latest
# enable: true
6 changes: 6 additions & 0 deletions lib/plugins/create/templates/tencent-nodejs6/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# package directories
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node.js v6 is already at EOL. Do you feel there's a value in providing template for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I have updated the template.

node_modules
jspm_packages

# Serverless directories
.serverless
6 changes: 6 additions & 0 deletions lib/plugins/create/templates/tencent-nodejs6/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

exports.main_handler = (event, context, callback) => {
console.log("%j", event);
callback(null, "Hello World");
};
14 changes: 14 additions & 0 deletions lib/plugins/create/templates/tencent-nodejs6/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "tencent-nodejs",
"version": "1.0.0",
"description": "Tencent Serverless Cloud Function example using Nodejs",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "cloud.tencent.com",
"license": "MIT",
"devDependencies": {
"serverless-tencent-scf": "*"
}
}
90 changes: 90 additions & 0 deletions lib/plugins/create/templates/tencent-nodejs6/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
#
# Happy Coding!

service: my-service # service name

provider: # provider information
name: tencent
runtime: Nodejs6.10
credentials: ~/credentials

# you can overwrite defaults here
# stage: dev
# cosBucket: DEFAULT
# role: QCS_SCFExcuteRole
# memorySize: 256
# timeout: 10
# region: ap-shanghai
# environment:
# variables:
# ENV_FIRST: env1
# ENV_SECOND: env2

plugins:
- serverless-tencent-scf

# you can add packaging information here
#package:
# include:
# - include-me.js
# - include-me-dir/**
# exclude:
# - exclude-me.js
# - exclude-me-dir/**


functions:
function_one:
handler: index.main_handler
# description: Tencent Serverless Cloud Function
# runtime: Nodejs6.10
# memorySize: 256
# timeout: 10
# environment:
# variables:
# ENV_FIRST: env1
# ENV_Third: env2
# events:
# - timer:
# name: timer
# parameters:
# cronExpression: '*/5 * * * *'
# enable: true
# - cos:
# name: cli-appid.cos.ap-beijing.myqcloud.com
# parameters:
# bucket: cli-appid.cos.ap-beijing.myqcloud.com
# filter:
# prefix: filterdir/
# suffix: .jpg
# events: cos:ObjectCreated:*
# enable: true
# - apigw:
# name: hello_world_apigw
# parameters:
# stageName: release
# serviceId:
# httpMethod: ANY
# - cmq:
# name: cmq_trigger
# parameters:
# name: test-topic-queue
# enable: true
# - ckafka:
# name: ckafka_trigger
# parameters:
# name: ckafka-2o10hua5
# topic: test
# maxMsgNum: 999
# offset: latest
# enable: true
6 changes: 6 additions & 0 deletions lib/plugins/create/templates/tencent-nodejs8/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# package directories
node_modules
jspm_packages

# Serverless directories
.serverless
5 changes: 5 additions & 0 deletions lib/plugins/create/templates/tencent-nodejs8/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';
exports.main_handler = async (event, context, callback) => {
console.log("%j", event);
return "hello world"
};
14 changes: 14 additions & 0 deletions lib/plugins/create/templates/tencent-nodejs8/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "tencent-nodejs",
"version": "1.0.0",
"description": "Tencent Serverless Cloud Function example using Nodejs",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "cloud.tencent.com",
"license": "MIT",
"devDependencies": {
"serverless-tencent-scf": "*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be good to pin it to current version so ^0.1.7. That will prevent any eventual breaking changes to a plugin to affect the template

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.
I have added the plugin version in package.json just now.

}
}
90 changes: 90 additions & 0 deletions lib/plugins/create/templates/tencent-nodejs8/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
#
# Happy Coding!

service: my-service # service name

provider: # provider information
name: tencent
runtime: Nodejs8.9
credentials: ~/credentials

# you can overwrite defaults here
# stage: dev
# cosBucket: DEFAULT
# role: QCS_SCFExcuteRole
# memorySize: 256
# timeout: 10
# region: ap-shanghai
# environment:
# variables:
# ENV_FIRST: env1
# ENV_SECOND: env2

plugins:
- serverless-tencent-scf

# you can add packaging information here
#package:
# include:
# - include-me.js
# - include-me-dir/**
# exclude:
# - exclude-me.js
# - exclude-me-dir/**


functions:
function_one:
handler: index.main_handler
# description: Tencent Serverless Cloud Function
# runtime: Nodejs8.9
# memorySize: 256
# timeout: 10
# environment:
# variables:
# ENV_FIRST: env1
# ENV_Third: env2
# events:
# - timer:
# name: timer
# parameters:
# cronExpression: '*/5 * * * *'
# enable: true
# - cos:
# name: cli-appid.cos.ap-beijing.myqcloud.com
# parameters:
# bucket: cli-appid.cos.ap-beijing.myqcloud.com
# filter:
# prefix: filterdir/
# suffix: .jpg
# events: cos:ObjectCreated:*
# enable: true
# - apigw:
# name: hello_world_apigw
# parameters:
# stageName: release
# serviceId:
# httpMethod: ANY
# - cmq:
# name: cmq_trigger
# parameters:
# name: test-topic-queue
# enable: true
# - ckafka:
# name: ckafka_trigger
# parameters:
# name: ckafka-2o10hua5
# topic: test
# maxMsgNum: 999
# offset: latest
# enable: true