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

feat: support layerArnV2 #846

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"typescript": "^4.4.3"
},
"scripts": {
"preln": "rm -rf ~/.s/components/devsapp.cn/devsapp/fc/dist",
"ln": "ln -s $(pwd)/dist ~/.s/components/devsapp.cn/devsapp/fc/dist",
"start": "npm run dev",
"dev": "npm run prebuild && npx tsc -w -p tsconfig.json",
"prebuild": "rm -rf node_modules && rm -rf package-lock.json && npm i && rimraf dist",
Expand Down
6 changes: 6 additions & 0 deletions src/entry-public-method/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import InfraAsTemplate from '../lib/infra-as-template';
import { IInputs, IProperties } from '../lib/interface/interface';
import { getCredentials } from '../lib/utils';
import { setDefaultValue } from './set-default-value';
import { tipLayerArn } from './tip-layer-arn';

const { lodash: _ } = core;

Expand Down Expand Up @@ -39,6 +40,11 @@ export default class EntryPublicMethod {

setDefaultValue(inputs);

// 提示使用 layerArnV2 版本
if (!_.isEmpty(inputs.props?.function?.layers)) {
tipLayerArn(inputs.props?.region, inputs.props?.function?.layers, inputs.project?.access);
}

await InfraAsTemplate.modifyInputs(inputs); // 多环境处理

return inputs;
Expand Down
15 changes: 15 additions & 0 deletions src/entry-public-method/tip-layer-arn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { lodash as _ } from '@serverless-devs/core';
import logger from '../common/logger';

export function tipLayerArn(region: string, layers: string[], access) {
const accessStr = access ? `-a ${access}` : '';

_.forEach(layers, function (layer) {
if (_.includes(layer, '#')) {
try {
const [, layerName, version] = layer.split('#');
logger.warn(`The arnV2 layer is recommended. This can be done using the 's cli fc layer detail --region ${region} --layer-name ${layerName} --version-id ${version} ${accessStr}' query`);
} catch (e) { /* 不影响主流程运行 */ }
}
});
}
1 change: 1 addition & 0 deletions src/lib/interface/fc/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface FunctionConfig {
initializer?: string;
instanceConcurrency?: number;
instanceType?: string;
layers?: string[];
}

export interface CustomContainerConfig {
Expand Down