Skip to content

Commit d971be9

Browse files
committed
feat: add layers config support
1 parent ee0a2af commit d971be9

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

docs/configure.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
```yml
66
# serverless.yml
77

8-
component: express-tencent@dev # (required) name of the component. In that case, it's express.
9-
name: express-api # (required) name of your express component instance.
10-
org: test # (optional) serverless dashboard org. default is the first org you created during signup.
11-
app: expressApp # (optional) serverless dashboard app. default is the same as the name property.
8+
component: express # (required) name of the component. In that case, it's express.
9+
name: expressDemo # (required) name of your express component instance.
10+
org: orgDemo # (optional) serverless dashboard org. default is the first org you created during signup.
11+
app: appDemo # (optional) serverless dashboard app. default is the same as the name property.
1212
stage: dev # (optional) serverless dashboard stage. default is dev.
1313

1414
inputs:
1515
region: ap-guangzhou
16-
functionName: express-api
16+
functionName: expressDemo
1717
serviceName: mytest
18-
runtime: Nodejs8.9
18+
runtime: Nodejs10.15
1919
serviceId: service-np1uloxw
2020
src: ./src
21+
layers:
22+
- name: expressLayer
23+
version: 1
2124
functionConf:
2225
timeout: 10
2326
memorySize: 128
@@ -60,26 +63,35 @@ Main param description
6063
6164
| Param | Required | Default | Description |
6265
| ---------------------------------------- | :------: | :-------------: | :------------------------------------------------------------------------------------------ |
63-
| runtime | N | Nodejs8.9 | Function Runtime, support: Nodejs6.10, Nodejs8.9, Nodejs10.15 |
66+
| runtime | N | Nodejs10.15 | Function Runtime, support: Nodejs6.10, Nodejs8.9, Nodejs10.15 |
6467
| region | N | ap-guangzhou | Deploy region |
6568
| functionName | N | | Serverless Cloud Function Name |
6669
| serviceName | N | | API-Gateway service name, default to create a new serivce |
6770
| serviceId | N | | API-Gateway service id, if it has will use this APII-Gateway service |
6871
| src | N | `process.cwd()` | Default is current working directory, if it is object, refer to [code object](#code-object) |
72+
| layers | N | | Bind layers for scf, array of [Layer](#layer) |
6973
| exclude | N | | exclude file |
7074
| include | N | | include file, if relative path, should relative to `serverless.yml` |
7175
| [functionConf](#funtionConf) | N | | Function configure |
7276
| [apigatewayConf](#apigatewayConf) | N | | API-Gateway configure |
7377
| [cloudDNSConf](#cloudDNSConf) | N | | Special config for region |
7478
| [Region special config](#apigatewayConf) | N | | Special config for region. Use region name for key |
7579

76-
## code object
80+
## src object
7781

7882
| Param | Required | Type | Default | Description |
7983
| ------ | :------: | :----: | :-----: | :----------------- |
84+
| src | N | String | | code path |
8085
| bucket | N | String | | bucket name |
8186
| object | N | String | | bucket object name |
8287

88+
## layer
89+
90+
| Param | Required | Type | Default | Description |
91+
| ------- | :------: | :----: | :-----: | :------------ |
92+
| name | N | String | | layer name |
93+
| version | N | String | | layer version |
94+
8395
### cloudDNSConf
8496

8597
Refer to: https://cloud.tencent.com/document/product/302/8516

example/serverless.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
component: express # (required) name of the component. In that case, it's express.
2-
name: expressDemo # (required) name of your express component instance.
31
org: orgDemo # (optional) serverless dashboard org. default is the first org you created during signup.
42
app: appDemo # (optional) serverless dashboard app. default is the same as the name property.
53
stage: dev # (optional) serverless dashboard stage. default is dev.
4+
component: express # (required) name of the component. In that case, it's express.
5+
name: expressDemo # (required) name of your express component instance.
66

77
inputs:
8-
src: ./src
8+
src:
9+
src: ./src # (optional) path to the source folder. default is a hello world app.
10+
exclude:
11+
- .env
912
region: ap-guangzhou
13+
layers:
14+
- name: nodeLayer
15+
version: 1
1016
runtime: Nodejs10.15
11-
exclude:
12-
- .env
1317
apigatewayConf:
1418
protocols:
1519
- http

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"download": "^8.0.0",
1616
"fs-extra": "^8.1.0",
17-
"tencent-component-toolkit": "^1.1.1",
17+
"tencent-component-toolkit": "^1.2.4",
1818
"type": "^2.0.0"
1919
}
2020
}

src/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
176176
default: CONFIGS.description
177177
}
178178
),
179-
fromClientRemark
179+
fromClientRemark,
180+
layers: ensureIterable(tempFunctionConf.layers ? tempFunctionConf.layers : inputs.layers, {
181+
default: []
182+
})
180183
}
181184
functionConf.tags = ensureObject(tempFunctionConf.tags ? tempFunctionConf.tags : inputs.tag, {
182185
default: null

0 commit comments

Comments
 (0)