Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log(`Packaging ${CONFIGS.compFullname} application...`)
// unzip source zip file
let zipPath
if (!inputs.code.src) {
// add default template
const downloadPath = `/tmp/${generateId()}`
const filename = 'template'
console.log(`Installing Default ${CONFIGS.compFullname} App...`)
try {
await download(CONFIGS.templateUrl, downloadPath, {
filename: `${filename}.zip`
})
} catch (e) {
throw new TypeError(`DOWNLOAD_TEMPLATE`, 'Download default template failed.')
}
zipPath = `${downloadPath}/${filename}.zip`
} else {
zipPath = inputs.code.src
}
return zipPath
}
getCredentials() {
const { tmpSecrets } = this.credentials.tencent
if (!tmpSecrets || !tmpSecrets.TmpSecretId) {
throw new TypeError(
'CREDENTIAL',
'Cannot get secretId/Key, your account could be sub-account and does not have the access to use SLS_QcsRole, please make sure the role exists first, then visit https://cloud.tencent.com/document/product/1154/43006, follow the instructions to bind the role to your account.'
)
}
return {
SecretId: tmpSecrets.TmpSecretId,
SecretKey: tmpSecrets.TmpSecretKey,
Token: tmpSecrets.Token
}
}
const validateTraffic = (num) => {
if (getType(num) !== 'Number') {
throw new TypeError(
`PARAMETER_${CONFIGS.compName.toUpperCase()}_TRAFFIC`,
'traffic must be a number'
)
}
if (num < 0 || num > 1) {
throw new TypeError(
`PARAMETER_${CONFIGS.compName.toUpperCase()}_TRAFFIC`,
'traffic must be a number between 0 and 1'
)
}
return true
}
const validateTraffic = (num) => {
if (getType(num) !== 'Number') {
throw new TypeError(
`PARAMETER_${CONFIGS.compName.toUpperCase()}_TRAFFIC`,
'traffic must be a number'
)
}
if (num < 0 || num > 1) {
throw new TypeError(
`PARAMETER_${CONFIGS.compName.toUpperCase()}_TRAFFIC`,
'traffic must be a number between 0 and 1'
)
}
return true
}