Skip to content

Commit 5be8a71

Browse files
committed
feat: yml支持job镜像配置&修复cfs找不到挂载点
1 parent 83943c1 commit 5be8a71

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

src/modules/apigw/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,23 @@ export default class Apigw {
151151
outputs.usagePlan = usagePlan;
152152
}
153153

154+
try {
155+
const { tags } = inputs;
156+
if (tags) {
157+
await this.tagClient.deployResourceTags({
158+
tags: tags.map(({ key, value }) => ({ TagKey: key, TagValue: value })),
159+
resourceId: serviceId,
160+
serviceType: ApiServiceType.apigw,
161+
resourcePrefix: 'service',
162+
});
163+
if (tags.length > 0) {
164+
outputs.tags = tags;
165+
}
166+
}
167+
} catch (e) {
168+
console.log(`[TAG] ${e.message}`);
169+
}
170+
154171
// return this.formatApigwOutputs(outputs);
155172
return outputs;
156173
}

src/modules/scf/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export const WebServerImageDefaultPort = 9000;
2-
32
export const YunTiTagDocHref = 'https://doc.weixin.qq.com/doc/w3_AQ8AWgYkAOEEeD1cr34R7S66r8ONY?scode=AJEAIQdfAAoiSWrYcZAOMAswb5AFM';

src/modules/scf/interface.ts

Lines changed: 7 additions & 0 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
// 异步调用重试配置

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)