Skip to content

feat: yml支持job镜像配置&修复cfs找不到挂载点问题 #296

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

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
1 change: 1 addition & 0 deletions src/modules/scf/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const WebServerImageDefaultPort = 9000;
17 changes: 12 additions & 5 deletions src/modules/scf/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface FunctionCode {
RegistryId?: string;
Command?: string;
Args?: string;
ContainerImageAccelerate?: boolean;
ImagePort?: number;
};
}

Expand Down Expand Up @@ -203,6 +205,7 @@ export interface ScfCreateFunctionInputs {

cfs?: {
cfsId: string;
mountInsId?: string;
MountInsId?: string;
localMountDir: string;
remoteMountDir: string;
Expand All @@ -228,6 +231,10 @@ export interface ScfCreateFunctionInputs {
command?: string;
// 启动命令参数
args?: string;
// 是否开启镜像加速
containerImageAccelerate?: boolean;
// 监听端口: -1 表示job镜像,0~65535 表示Web Server镜像
imagePort?: number;
};

// 异步调用重试配置
Expand Down Expand Up @@ -391,25 +398,25 @@ export interface GetRequestStatusOptions {
/**
* 函数名称
*/
functionName: string
functionName: string;

/**
* 需要查询状态的请求id
*/
functionRequestId: string
functionRequestId: string;

/**
* 函数的所在的命名空间
*/
namespace?: string
namespace?: string;

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

/**
* 查询的结束时间,例如:2017-05-16 20:59:59,不填默认为当前时间。EndTime 需要晚于 StartTime。
*/
endTime?: string
endTime?: string;
}
17 changes: 16 additions & 1 deletion src/modules/scf/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WebServerImageDefaultPort } from './constants';
import { ScfCreateFunctionInputs, BaseFunctionConfig, ProtocolParams } from './interface';
const CONFIGS = require('./config').default;

Expand Down Expand Up @@ -52,6 +53,20 @@ export const formatInputs = (inputs: ScfCreateFunctionInputs) => {
if (imageConfig.args) {
functionInputs.Code!.ImageConfig!.Args = imageConfig.args;
}
// 镜像加速
if (imageConfig.containerImageAccelerate !== undefined) {
functionInputs.Code!.ImageConfig!.ContainerImageAccelerate =
imageConfig.containerImageAccelerate;
}
// 监听端口: -1 表示 job镜像,0 ~ 65526 表示webServer镜像
if (imageConfig.imagePort) {
functionInputs.Code!.ImageConfig!.ImagePort =
Number.isInteger(imageConfig?.imagePort) &&
imageConfig?.imagePort >= -1 &&
imageConfig?.imagePort <= 65535
? imageConfig.imagePort
: WebServerImageDefaultPort;
}
} else {
// 基于 COS 代码部署
functionInputs.Code = {
Expand Down Expand Up @@ -149,7 +164,7 @@ export const formatInputs = (inputs: ScfCreateFunctionInputs) => {
inputs.cfs.forEach((item) => {
functionInputs.CfsConfig?.CfsInsList.push({
CfsId: item.cfsId,
MountInsId: item.MountInsId || item.cfsId,
MountInsId: item.mountInsId || item.MountInsId || item.cfsId,
LocalMountDir: item.localMountDir,
RemoteMountDir: item.remoteMountDir,
UserGroupId: String(item.userGroupId || 10000),
Expand Down