Skip to content

Commit d4b1660

Browse files
Rong5180rongxwang
andauthored
fix: 修改更新逻辑,完成旧版本兼容 (#270)
* fix: 修改更新逻辑,完成旧版本兼容 * fix: 完善更新逻辑,兼容老项目 * fix: 修改output输出服务名 Co-authored-by: rongxwang <rongxwang@tencent.com>
1 parent 27c0367 commit d4b1660

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/modules/apigw/index.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ export default class Apigw {
240240
oldState = {},
241241
serviceId,
242242
isAutoRelease = true,
243+
serviceName,
244+
serviceDesc,
243245
} = inputs;
244246
inputs.protocols = getProtocolString(inputs.protocols as ('http' | 'https')[]);
245247

@@ -248,6 +250,27 @@ export default class Apigw {
248250

249251
const detail = await this.service.getById(serviceId);
250252
if (detail) {
253+
// 如果 serviceName,serviceDesc,protocols任意字段更新了,则更新服务
254+
if (
255+
!(serviceName === detail.ServiceName && serviceDesc === detail.ServiceDesc) &&
256+
!(serviceName === undefined && serviceDesc === undefined)
257+
) {
258+
const apiInputs = {
259+
Action: 'ModifyService' as const,
260+
serviceId,
261+
serviceDesc: serviceDesc || detail.ServiceDesc || undefined,
262+
serviceName: serviceName || detail.ServiceName || undefined,
263+
};
264+
if (!serviceName) {
265+
delete apiInputs.serviceName;
266+
}
267+
if (!serviceDesc) {
268+
delete apiInputs.serviceDesc;
269+
}
270+
271+
await this.request(apiInputs);
272+
}
273+
251274
const apiList: ApiEndpoint[] = await this.api.bulkDeploy({
252275
apiList: endpoints,
253276
stateList: stateApiList,
@@ -269,7 +292,7 @@ export default class Apigw {
269292
const outputs: ApigwDeployOutputs = {
270293
created: false,
271294
serviceId,
272-
serviceName: detail.ServiceName,
295+
serviceName: serviceName || detail.ServiceName,
273296
subDomain: subDomain,
274297
protocols: inputs.protocols,
275298
environment: environment,
@@ -291,7 +314,8 @@ export default class Apigw {
291314
}));
292315
}
293316

294-
return this.formatApigwOutputs(outputs);
317+
// return this.formatApigwOutputs(outputs);
318+
return outputs;
295319
}
296320
throw new ApiError({
297321
type: 'API_APIGW_DescribeService',

0 commit comments

Comments
 (0)