Skip to content
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
7 changes: 7 additions & 0 deletions __tests__/e2e/ci-mac-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ s invoke -e '{"hello":"fc nodejs with auto"}' -t s_auto.yaml
s info -y -t s_auto.yaml
s remove -y -t s_auto.yaml

echo "test nodejs runtime with oss config auto ..."
export fc_component_function_name=nodejs18-$(uname)-$(uname -m)-$RANDSTR
s deploy -y -t ./s_oss_config_auto.yaml
s invoke -e '{"hello":"fc nodejs with oss config auto"}' -t ./s_oss_config_auto.yaml
s info -y -t ./s_oss_config_auto.yaml
s remove -y -t ./s_oss_config_auto.yaml

echo "test nodejs runtime with more vpc and nas auto ..."
export fc_component_function_name=nodejs16-$(uname)-$(uname -m)-$RANDSTR
s deploy -y -t ./s_lock_auto.yaml
Expand Down
33 changes: 33 additions & 0 deletions __tests__/e2e/nodejs/s_oss_config_auto.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
edition: 3.0.0
name: test-node-app
access: quanxi

vars:
region: ${env('REGION', 'cn-hongkong')}

resources:
fcDemo:
component: ${env('fc_component_version', path('../../../'))}
props:
region: ${vars.region}
functionName: fc3-event-${env('fc_component_function_name', 'nodejs18')}-ossConfig
role: acs:ram::${config('AccountID')}:role/aliyunaliyunfcdefaultrole
runtime: ${env('fc_component_runtime', 'nodejs18')}
code: './test-auto-code'
handler: index.handler
memorySize: 128
timeout: 60
ossMountConfig: auto

fcDemo2: # 业务名称/模块名称
component: ${env('fc_component_version', path('../../../'))}
props: # 组件的属性值
region: ${vars.region}
functionName: fc3-event-${env('fc_component_function_name', 'nodejs18')}-ossConfigF2
role: acs:ram::${config('AccountID')}:role/aliyunaliyunfcdefaultrole
runtime: ${env('fc_component_runtime', 'nodejs18')}
code: ./test-auto-code
handler: index.handler
memorySize: 128
timeout: 60
ossMountConfig: auto|rules=[{"allowedOrigin":"*","allowedMethod":"GET","allowedHeader":"*","exposeHeader":"Content-Length","maxAgeSeconds":30}]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@serverless-cd/srm-aliyun-pop-core": "^0.0.8-beta.1",
"@serverless-cd/srm-aliyun-ram20150501": "^0.0.2-beta.9",
"@serverless-cd/srm-aliyun-sls20201230": "0.0.5-beta.3",
"@serverless-cd/srm-aliyun-oss": "^0.0.1-beta.4",
"@serverless-cd/srm-aliyun-oss": "^0.0.1-beta.6",
"@serverless-devs/diff": "^0.0.3-beta.6",
"@serverless-devs/downloads": "^0.0.7",
"@serverless-devs/load-component": "^0.0.9",
Expand Down
2 changes: 1 addition & 1 deletion src/interface/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export interface IFunction {

logConfig?: 'auto' | ILogConfig;
nasConfig?: 'auto' | INasConfig;
ossMountConfig?: IOssMountConfig;
ossMountConfig?: 'auto' | IOssMountConfig;
role?: 'auto' | string;
vpcConfig?: 'auto' | IVpcConfig;
vpcBinding?: {
Expand Down
4 changes: 2 additions & 2 deletions src/resources/oss/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default class OSS {
this.client = new Oss();
}

async deploy(): Promise<{ ossBucket: string }> {
async deploy(ossMountConfig = 'auto'): Promise<{ ossBucket: string }> {
logger.debug(`init oss: ${JSON.stringify(this.config)}`);
const result = await this.client.initOss(this.config);
const result = await this.client.initOss(this.config, ossMountConfig);
const ossBucket = result?.ossBucket || '';
if (isAppCenter()) {
logger.info(`created oss region: ${this.region};`);
Expand Down
3 changes: 2 additions & 1 deletion src/subCommands/deploy/impl/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ logConfig:
}
logger.info(`ossAuto code to ${ossEndpoint}`);
const oss = new OSS(region, credential as ICredentials, ossEndpoint);
const { ossBucket } = await oss.deploy();
const { ossBucket } = await oss.deploy(this.inputs.props.ossMountConfig as string);

logger.write(
yellow(`Created oss resource succeeded, please replace ossMountConfig: auto in yaml with:
ossMountConfig:
Expand Down
6 changes: 5 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ export const isAuto = (config: unknown): boolean => {
return false;
}

return _.toUpper(config) === 'AUTO';
if (_.toUpper(config) === 'AUTO') {
return true;
}
const autoConfig = config.split('|')[0];
return _.toUpper(autoConfig) === 'AUTO';
};

export const isAutoVpcConfig = (config: unknown): boolean => {
Expand Down