Skip to content

Commit

Permalink
fix put aritfact in linux
Browse files Browse the repository at this point in the history
  • Loading branch information
rsonghuster committed Aug 9, 2024
1 parent 62707e7 commit 3551e9e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions __tests__/e2e/artifact/s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition: 3.0.0
name: hello-world-app
access: "quanxi"

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

resources:
Expand All @@ -19,7 +19,7 @@ resources:
description: 'hello world by serverless devs'
runtime: "python3.10"
code: ./code
artifact: test-devs-artifact_cn-hangzhou
artifact: test-devs-artifact-1001
handler: index.handler
memorySize: 128
timeout: 40
9 changes: 8 additions & 1 deletion src/subCommands/deploy/impl/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export default class Service extends Base {
if (process.env.ARTIFACT_ENDPOINT) {
config.endpoint = process.env.ARTIFACT_ENDPOINT;
}
if (process.env.artifact_endpoint) {
config.endpoint = process.env.artifact_endpoint;
}
this.devsClient = new Devs20230714(config);
}
// 准备动作
Expand Down Expand Up @@ -504,10 +507,14 @@ nasConfig:
// const artifactName = truncateString(`${functionName}_${region}`);

const downloadDir: string = path.join(tmpDir, 'artifacts');
if (!fs.existsSync(downloadDir)) {
fs.mkdirSync(downloadDir);
}
const zipFile = path.join(downloadDir, `${artifactName}_${uuidV4()}.zip`);

logger.info(`download ${url} to ${zipFile}`);
await downloadFile(url, zipFile);

logger.debug(zipFile);
const resp = await this.devsClient.fetchArtifactTempBucketToken();
logger.debug(JSON.stringify(resp.body));
const { credentials, ossRegion, ossBucketName, ossObjectName } = resp.body;
Expand Down
2 changes: 1 addition & 1 deletion src/subCommands/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export default class Deploy {
const run3 = await this.asyncInvokeConfig?.run();
const run4 = await this.vpcBinding?.run();
const run5 = await this.customDomain?.run();

// 获取输出
if (run1 && run2 && run3 && run4 && run5) {
const info = new Info(this.inputs);
Expand All @@ -88,6 +87,7 @@ export default class Deploy {
return result;
}
const mergedObj = Object.assign({}, result, artifact);
logger.debug(`mergedObj = ${JSON.stringify(mergedObj, null, 2)}`);
return mergedObj;
}
}
Expand Down

0 comments on commit 3551e9e

Please sign in to comment.