Skip to content

Commit

Permalink
fix: support all configs for scf
Browse files Browse the repository at this point in the history
  • Loading branch information
yugasun committed Oct 10, 2020
1 parent 8173d8d commit 52b8f51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion serverless.component.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: nextjs
version: 0.1.5
version: 0.1.6
author: 'Tencent Cloud, Inc.'
org: 'Tencent Cloud, Inc.'
description: Deploy a serverless Next.js application onto Tencent SCF and API Gateway.
Expand Down
14 changes: 6 additions & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
// chenck state function name
const stateFunctionName =
instance.state[regionList[0]] && instance.state[regionList[0]].functionName
const functionConf = {
const functionConf = Object.assign(tempFunctionConf, {
code: {
src: inputs.src,
bucket: inputs.srcOriginal && inputs.srcOriginal.bucket,
Expand Down Expand Up @@ -339,14 +339,12 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
publish: inputs.publish,
traffic: inputs.traffic,
lastVersion: instance.state.lastVersion,
eip: tempFunctionConf.eip === true,
l5Enable: tempFunctionConf.l5Enable === true,
timeout: tempFunctionConf.timeout ? tempFunctionConf.timeout : CONFIGS.timeout,
memorySize: tempFunctionConf.memorySize ? tempFunctionConf.memorySize : CONFIGS.memorySize,
tags: ensureObject(tempFunctionConf.tags ? tempFunctionConf.tags : inputs.tag, {
tags: ensureObject(tempFunctionConf.tags ? tempFunctionConf.tags : inputs.tags, {
default: null
})
}
})

// validate traffic
if (inputs.traffic !== undefined) {
Expand All @@ -355,7 +353,7 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
functionConf.needSetTraffic = inputs.traffic !== undefined && functionConf.lastVersion

if (tempFunctionConf.environment) {
functionConf.environment = inputs.functionConf.environment
functionConf.environment = tempFunctionConf.environment
functionConf.environment.variables = functionConf.environment.variables || {}
functionConf.environment.variables.SERVERLESS = '1'
functionConf.environment.variables.SLS_ENTRY_FILE = inputs.entryFile || CONFIGS.defaultEntryFile
Expand All @@ -373,7 +371,7 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {

// 对apigw inputs进行标准化
const tempApigwConf = inputs.apigatewayConf ? inputs.apigatewayConf : {}
const apigatewayConf = {
const apigatewayConf = Object.assign(tempApigwConf, {
serviceId: inputs.serviceId,
region: regionList,
isDisabled: tempApigwConf.isDisabled === true,
Expand All @@ -396,7 +394,7 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
}
],
customDomains: tempApigwConf.customDomains || []
}
})
if (tempApigwConf.usagePlan) {
apigatewayConf.endpoints[0].usagePlan = {
usagePlanId: tempApigwConf.usagePlan.usagePlanId,
Expand Down

0 comments on commit 52b8f51

Please sign in to comment.