mirror of
https://github.com/serverless/serverless.git
synced 2026-02-01 16:07:28 +00:00
Merge pull request #6898 from serverless-tencent/add-tencent
Add tencent provider create-template
This commit is contained in:
commit
593ef909b8
@ -61,6 +61,10 @@ const validTemplates = [
|
||||
'spotinst-java8',
|
||||
'twilio-nodejs',
|
||||
'aliyun-nodejs',
|
||||
'tencent-go',
|
||||
'tencent-nodejs',
|
||||
'tencent-python',
|
||||
'tencent-php',
|
||||
'plugin',
|
||||
|
||||
// this template is used to streamline the onboarding process
|
||||
|
||||
@ -800,6 +800,55 @@ describe('Create', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should generate scaffolding for "tencent-go" template', () => {
|
||||
process.chdir(tmpDir);
|
||||
create.options.template = 'tencent-go';
|
||||
|
||||
return create.create().then(() => {
|
||||
const dirContent = fs.readdirSync(tmpDir);
|
||||
expect(dirContent).to.include('serverless.yml');
|
||||
expect(dirContent).to.include('index.go');
|
||||
expect(dirContent).to.include('Makefile');
|
||||
expect(dirContent).to.include('.gitignore');
|
||||
});
|
||||
});
|
||||
|
||||
it('should generate scaffolding for "tencent-php" template', () => {
|
||||
process.chdir(tmpDir);
|
||||
create.options.template = 'tencent-php';
|
||||
|
||||
return create.create().then(() => {
|
||||
const dirContent = fs.readdirSync(tmpDir);
|
||||
expect(dirContent).to.include('serverless.yml');
|
||||
expect(dirContent).to.include('index.php');
|
||||
expect(dirContent).to.include('.gitignore');
|
||||
});
|
||||
});
|
||||
|
||||
it('should generate scaffolding for "tencent-python" template', () => {
|
||||
process.chdir(tmpDir);
|
||||
create.options.template = 'tencent-python';
|
||||
|
||||
return create.create().then(() => {
|
||||
const dirContent = fs.readdirSync(tmpDir);
|
||||
expect(dirContent).to.include('serverless.yml');
|
||||
expect(dirContent).to.include('index.py');
|
||||
expect(dirContent).to.include('.gitignore');
|
||||
});
|
||||
});
|
||||
|
||||
it('should generate scaffolding for "tencent-nodejs" template', () => {
|
||||
process.chdir(tmpDir);
|
||||
create.options.template = 'tencent-nodejs';
|
||||
|
||||
return create.create().then(() => {
|
||||
const dirContent = fs.readdirSync(tmpDir);
|
||||
expect(dirContent).to.include('serverless.yml');
|
||||
expect(dirContent).to.include('index.js');
|
||||
expect(dirContent).to.include('.gitignore');
|
||||
});
|
||||
});
|
||||
|
||||
it('should generate scaffolding for "plugin" template', () => {
|
||||
process.chdir(tmpDir);
|
||||
create.options.template = 'plugin';
|
||||
|
||||
10
lib/plugins/create/templates/tencent-go/Makefile
Normal file
10
lib/plugins/create/templates/tencent-go/Makefile
Normal file
@ -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
lib/plugins/create/templates/tencent-go/gitignore
Executable file
18
lib/plugins/create/templates/tencent-go/gitignore
Executable file
@ -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
lib/plugins/create/templates/tencent-go/index.go
Normal file
22
lib/plugins/create/templates/tencent-go/index.go
Normal file
@ -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
lib/plugins/create/templates/tencent-go/package.json
Executable file
14
lib/plugins/create/templates/tencent-go/package.json
Executable file
@ -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": "^0.1.7"
|
||||
}
|
||||
}
|
||||
87
lib/plugins/create/templates/tencent-go/serverless.yml
Executable file
87
lib/plugins/create/templates/tencent-go/serverless.yml
Executable file
@ -0,0 +1,87 @@
|
||||
# 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
lib/plugins/create/templates/tencent-nodejs/gitignore
Executable file
6
lib/plugins/create/templates/tencent-nodejs/gitignore
Executable file
@ -0,0 +1,6 @@
|
||||
# package directories
|
||||
node_modules
|
||||
jspm_packages
|
||||
|
||||
# Serverless directories
|
||||
.serverless
|
||||
6
lib/plugins/create/templates/tencent-nodejs/index.js
Normal file
6
lib/plugins/create/templates/tencent-nodejs/index.js
Normal file
@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
exports.main_handler = (event, context, callback) => {
|
||||
console.log('%j', event);
|
||||
callback(null, 'Hello World');
|
||||
};
|
||||
14
lib/plugins/create/templates/tencent-nodejs/package.json
Executable file
14
lib/plugins/create/templates/tencent-nodejs/package.json
Executable file
@ -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": "^0.1.7"
|
||||
}
|
||||
}
|
||||
89
lib/plugins/create/templates/tencent-nodejs/serverless.yml
Executable file
89
lib/plugins/create/templates/tencent-nodejs/serverless.yml
Executable file
@ -0,0 +1,89 @@
|
||||
# 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 # Nodejs8.9 or 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: Nodejs8.9 # Nodejs8.9 or 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
lib/plugins/create/templates/tencent-php/gitignore
Executable file
6
lib/plugins/create/templates/tencent-php/gitignore
Executable file
@ -0,0 +1,6 @@
|
||||
# package directories
|
||||
node_modules
|
||||
jspm_packages
|
||||
|
||||
# Serverless directories
|
||||
.serverless
|
||||
9
lib/plugins/create/templates/tencent-php/index.php
Normal file
9
lib/plugins/create/templates/tencent-php/index.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
function main_handler($event, $context) {
|
||||
var_dump($event);
|
||||
return "hello world";
|
||||
}
|
||||
|
||||
?>
|
||||
14
lib/plugins/create/templates/tencent-php/package.json
Executable file
14
lib/plugins/create/templates/tencent-php/package.json
Executable file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "tencent-php",
|
||||
"version": "1.0.0",
|
||||
"description": "Tencent Serverless Cloud Function example using Php",
|
||||
"main": "index.php",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "cloud.tencent.com",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"serverless-tencent-scf": "^0.1.7"
|
||||
}
|
||||
}
|
||||
80
lib/plugins/create/templates/tencent-php/serverless.yml
Executable file
80
lib/plugins/create/templates/tencent-php/serverless.yml
Executable file
@ -0,0 +1,80 @@
|
||||
# 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: Php7 # Php7 or Php5
|
||||
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
|
||||
|
||||
functions:
|
||||
function_one_one_one:
|
||||
handler: index.main_handler
|
||||
# description: Tencent Serverless Cloud Function
|
||||
# runtime: Php7 # Php7 or Php5
|
||||
# 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
|
||||
20
lib/plugins/create/templates/tencent-python/gitignore
Executable file
20
lib/plugins/create/templates/tencent-python/gitignore
Executable file
@ -0,0 +1,20 @@
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# Serverless directories
|
||||
.serverless
|
||||
7
lib/plugins/create/templates/tencent-python/index.py
Normal file
7
lib/plugins/create/templates/tencent-python/index.py
Normal file
@ -0,0 +1,7 @@
|
||||
# -*- coding: utf8 -*-
|
||||
|
||||
|
||||
def main_handler(event, context):
|
||||
print(str(event))
|
||||
return "hello world"
|
||||
|
||||
14
lib/plugins/create/templates/tencent-python/package.json
Executable file
14
lib/plugins/create/templates/tencent-python/package.json
Executable file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "tencent-python",
|
||||
"version": "1.0.0",
|
||||
"description": "Tencent Serverless Cloud Function example using Python",
|
||||
"main": "index.py",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "cloud.tencent.com",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"serverless-tencent-scf": "^0.1.7"
|
||||
}
|
||||
}
|
||||
89
lib/plugins/create/templates/tencent-python/serverless.yml
Executable file
89
lib/plugins/create/templates/tencent-python/serverless.yml
Executable file
@ -0,0 +1,89 @@
|
||||
# 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: Python3.6 # Python3.6 or Python2.7
|
||||
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.py
|
||||
# - include-me-dir/**
|
||||
# exclude:
|
||||
# - exclude-me.py
|
||||
# - exclude-me-dir/**
|
||||
|
||||
functions:
|
||||
function_one:
|
||||
handler: index.main_handler
|
||||
# description: Tencent Serverless Cloud Function
|
||||
# runtime: Python3.6 # Python3.6 or Python2.7
|
||||
# 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
|
||||
Loading…
x
Reference in New Issue
Block a user