Skip to content

Commit 0bff41b

Browse files
authored
feat: yml支持job镜像配置&修复cfs找不到挂载点问题 (#296)
1 parent e91c2ec commit 0bff41b

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

src/modules/scf/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const WebServerImageDefaultPort = 9000;

src/modules/scf/interface.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export interface FunctionCode {
1212
RegistryId?: string;
1313
Command?: string;
1414
Args?: string;
15+
ContainerImageAccelerate?: boolean;
16+
ImagePort?: number;
1517
};
1618
}
1719

@@ -203,6 +205,7 @@ export interface ScfCreateFunctionInputs {
203205

204206
cfs?: {
205207
cfsId: string;
208+
mountInsId?: string;
206209
MountInsId?: string;
207210
localMountDir: string;
208211
remoteMountDir: string;
@@ -228,6 +231,10 @@ export interface ScfCreateFunctionInputs {
228231
command?: string;
229232
// 启动命令参数
230233
args?: string;
234+
// 是否开启镜像加速
235+
containerImageAccelerate?: boolean;
236+
// 监听端口: -1 表示job镜像,0~65535 表示Web Server镜像
237+
imagePort?: number;
231238
};
232239

233240
// 异步调用重试配置
@@ -391,25 +398,25 @@ export interface GetRequestStatusOptions {
391398
/**
392399
* 函数名称
393400
*/
394-
functionName: string
401+
functionName: string;
395402

396403
/**
397404
* 需要查询状态的请求id
398405
*/
399-
functionRequestId: string
406+
functionRequestId: string;
400407

401408
/**
402409
* 函数的所在的命名空间
403410
*/
404-
namespace?: string
411+
namespace?: string;
405412

406413
/**
407414
* 查询的开始时间,例如:2017-05-16 20:00:00,不填默认为当前时间 - 15min
408415
*/
409-
startTime?: string
416+
startTime?: string;
410417

411418
/**
412419
* 查询的结束时间,例如:2017-05-16 20:59:59,不填默认为当前时间。EndTime 需要晚于 StartTime。
413420
*/
414-
endTime?: string
421+
endTime?: string;
415422
}

src/modules/scf/utils.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { WebServerImageDefaultPort } from './constants';
12
import { ScfCreateFunctionInputs, BaseFunctionConfig, ProtocolParams } from './interface';
23
const CONFIGS = require('./config').default;
34

@@ -52,6 +53,20 @@ export const formatInputs = (inputs: ScfCreateFunctionInputs) => {
5253
if (imageConfig.args) {
5354
functionInputs.Code!.ImageConfig!.Args = imageConfig.args;
5455
}
56+
// 镜像加速
57+
if (imageConfig.containerImageAccelerate !== undefined) {
58+
functionInputs.Code!.ImageConfig!.ContainerImageAccelerate =
59+
imageConfig.containerImageAccelerate;
60+
}
61+
// 监听端口: -1 表示 job镜像,0 ~ 65526 表示webServer镜像
62+
if (imageConfig.imagePort) {
63+
functionInputs.Code!.ImageConfig!.ImagePort =
64+
Number.isInteger(imageConfig?.imagePort) &&
65+
imageConfig?.imagePort >= -1 &&
66+
imageConfig?.imagePort <= 65535
67+
? imageConfig.imagePort
68+
: WebServerImageDefaultPort;
69+
}
5570
} else {
5671
// 基于 COS 代码部署
5772
functionInputs.Code = {
@@ -149,7 +164,7 @@ export const formatInputs = (inputs: ScfCreateFunctionInputs) => {
149164
inputs.cfs.forEach((item) => {
150165
functionInputs.CfsConfig?.CfsInsList.push({
151166
CfsId: item.cfsId,
152-
MountInsId: item.MountInsId || item.cfsId,
167+
MountInsId: item.mountInsId || item.MountInsId || item.cfsId,
153168
LocalMountDir: item.localMountDir,
154169
RemoteMountDir: item.remoteMountDir,
155170
UserGroupId: String(item.userGroupId || 10000),

0 commit comments

Comments
 (0)