From 8caab1fd9264df548f467b94202d567107b7a30b Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Fri, 26 Dec 2025 23:20:14 +0800 Subject: [PATCH] perf: aws route53 --- packages/core/acme-client/src/util.js | 2 +- .../pipeline/components/change-trigger.vue | 3 ++ .../src/plugins/plugin-aws/access.ts | 9 ++--- .../plugin-aws/aws-route53-provider.ts | 2 +- .../src/plugins/plugin-aws/libs/aws-client.ts | 35 ++++++++++--------- pnpm-lock.yaml | 30 ++++++++-------- 6 files changed, 43 insertions(+), 38 deletions(-) diff --git a/packages/core/acme-client/src/util.js b/packages/core/acme-client/src/util.js index cdfde034d..ab2a5b74e 100644 --- a/packages/core/acme-client/src/util.js +++ b/packages/core/acme-client/src/util.js @@ -247,7 +247,7 @@ async function getAuthoritativeDnsResolver(recordName, logger = log) { try { /* Resolve root domain by SOA */ - const domain = await resolveDomainBySoaRecord(recordNam,logger); + const domain = await resolveDomainBySoaRecord(recordName,logger); /* Resolve authoritative NS addresses */ logger(`获取到权威NS服务器name: ${domain}`); diff --git a/packages/ui/certd-client/src/views/certd/pipeline/components/change-trigger.vue b/packages/ui/certd-client/src/views/certd/pipeline/components/change-trigger.vue index 95a9de7a9..edb377ad3 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/components/change-trigger.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/components/change-trigger.vue @@ -63,6 +63,9 @@ async function openFormDialog() { form: { value: true, helper: "是否给流水线随机设置一个时间", + show: compute(({ form }) => { + return form.clear !== true; + }), component: { name: "fs-dict-switch", vModel: "checked", diff --git a/packages/ui/certd-server/src/plugins/plugin-aws/access.ts b/packages/ui/certd-server/src/plugins/plugin-aws/access.ts index 6f2824842..b52c6e363 100644 --- a/packages/ui/certd-server/src/plugins/plugin-aws/access.ts +++ b/packages/ui/certd-server/src/plugins/plugin-aws/access.ts @@ -1,9 +1,10 @@ import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline'; export const AwsRegions = [ - { label: 'cn-north-1', value: 'cn-north-1' }, - { label: 'cn-northwest-1', value: 'cn-northwest-1' }, - { label: '---------------', value: '--',disabled: true }, + { label: '------中国区------', value: 'cn',disabled: true }, + { label: '北京', value: 'cn-north-1' }, + { label: '宁夏', value: 'cn-northwest-1' }, + { label: '------海外-----', value: 'out',disabled: true }, { label: 'us-east-1', value: 'us-east-1' }, { label: 'us-east-2', value: 'us-east-2' }, { label: 'us-west-1', value: 'us-west-1' }, @@ -72,7 +73,7 @@ export class AwsAccess extends BaseAccess { options: AwsRegions, }, required: true, - helper: '请选择您的默认AWS区域,默认us-east-1', + helper: '请选择您的默认AWS区域,主要区分中国区还是海外区即可', options: AwsRegions, }) region = ''; diff --git a/packages/ui/certd-server/src/plugins/plugin-aws/aws-route53-provider.ts b/packages/ui/certd-server/src/plugins/plugin-aws/aws-route53-provider.ts index e36d49f13..0d0f7d27f 100644 --- a/packages/ui/certd-server/src/plugins/plugin-aws/aws-route53-provider.ts +++ b/packages/ui/certd-server/src/plugins/plugin-aws/aws-route53-provider.ts @@ -32,7 +32,7 @@ export class AwsRoute53Provider extends AbstractDnsProvider { fullRecord: fullRecord, type: type, value: value, - action: 'CREATE', + action: 'UPSERT', }); return { hostedZoneId: ZoneId, diff --git a/packages/ui/certd-server/src/plugins/plugin-aws/libs/aws-client.ts b/packages/ui/certd-server/src/plugins/plugin-aws/libs/aws-client.ts index 78640173d..f5db11aee 100644 --- a/packages/ui/certd-server/src/plugins/plugin-aws/libs/aws-client.ts +++ b/packages/ui/certd-server/src/plugins/plugin-aws/libs/aws-client.ts @@ -1,8 +1,8 @@ // 导入所需的 SDK 模块 import { AwsAccess } from '../access.js'; import { CertInfo } from '@certd/plugin-cert'; -import {ILogger, utils} from '@certd/basic'; -type AwsClientOptions = { access: AwsAccess; region: string, logger:ILogger }; +import { ILogger, utils } from '@certd/basic'; +type AwsClientOptions = { access: AwsAccess; region: string, logger: ILogger }; export class AwsClient { options: AwsClientOptions; @@ -52,24 +52,24 @@ export class AwsClient { }); } - async route53GetHostedZoneId(name:string) :Promise<{ZoneId:string,ZoneName:string}> { + async route53GetHostedZoneId(name: string): Promise<{ ZoneId: string, ZoneName: string }> { const hostedZones = await this.route53ListHostedZones(name); - const zoneId = hostedZones[0].Id.replace('/hostedzone/',''); + const zoneId = hostedZones[0].Id.replace('/hostedzone/', ''); this.logger.info(`获取到hostedZoneId:${zoneId},name:${hostedZones[0].Name}`); return { ZoneId: zoneId, ZoneName: hostedZones[0].Name, }; } - async route53ListHostedZones(name:string) :Promise<{Id:string,Name:string}[]> { - const { ListHostedZonesByNameCommand } =await import("@aws-sdk/client-route-53"); // ES Modules import + async route53ListHostedZones(name: string): Promise<{ Id: string, Name: string }[]> { + const { ListHostedZonesByNameCommand } = await import("@aws-sdk/client-route-53"); // ES Modules import const client = await this.route53ClientGet(); const input = { // ListHostedZonesByNameRequest DNSName: name, }; const command = new ListHostedZonesByNameCommand(input); - const response = await this.doRequest(()=>client.send(command)); + const response = await this.doRequest(() => client.send(command)); if (response.HostedZones.length === 0) { throw new Error(`找不到 HostedZone ${name}`); } @@ -77,9 +77,10 @@ export class AwsClient { return response.HostedZones; } - async route53ChangeRecord(req:{ - hostedZoneId:string,fullRecord:string,type:string, value:string, action:"CREATE"|"DELETE"}){ - const { ChangeResourceRecordSetsCommand} =await import("@aws-sdk/client-route-53"); // ES Modules import + async route53ChangeRecord(req: { + hostedZoneId: string, fullRecord: string, type: string, value: string, action: "UPSERT" | "DELETE" + }) { + const { ChangeResourceRecordSetsCommand } = await import("@aws-sdk/client-route-53"); // ES Modules import // const { Route53Client, ChangeResourceRecordSetsCommand } = require("@aws-sdk/client-route-53"); // CommonJS import // import type { Route53ClientConfig } from "@aws-sdk/client-route-53"; const client = await this.route53ClientGet(); @@ -88,9 +89,9 @@ export class AwsClient { ChangeBatch: { // ChangeBatch Changes: [ // Changes // required { // Change - Action: req.action as any , // required + Action: req.action as any, // required ResourceRecordSet: { // ResourceRecordSet - Name: req.fullRecord+".", // required + Name: req.fullRecord, // required Type: req.type.toUpperCase() as any, ResourceRecords: [ // ResourceRecords { // ResourceRecord @@ -103,9 +104,9 @@ export class AwsClient { ], }, }; - this.logger.info(`添加域名解析参数:${JSON.stringify(input)}`); + this.logger.info(`设置域名解析参数:${JSON.stringify(input)}`); const command = new ChangeResourceRecordSetsCommand(input); - const response = await this.doRequest(()=>client.send(command)); + const response = await this.doRequest(() => client.send(command)); console.log('Add record successful:', JSON.stringify(response)); await utils.sleep(3000); return response; @@ -120,10 +121,10 @@ export class AwsClient { // };*/ } - async doRequest(call:()=>Promise):Promise{ - try{ + async doRequest(call: () => Promise): Promise { + try { return await call(); - }catch(err){ + } catch (err) { this.logger.error(`调用接口失败:${err.Error?.Message || err.message},requestId:${err.requestId}`); throw err; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a0011a03..ff5810213 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -783,19 +783,19 @@ importers: packages/pro/commercial-core: dependencies: '@certd/basic': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../../core/basic '@certd/lib-server': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../../libs/lib-server '@certd/pipeline': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../../core/pipeline '@certd/plugin-plus': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../plugin-plus '@certd/plus-core': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../plus-core '@midwayjs/core': specifier: 3.20.11 @@ -880,22 +880,22 @@ importers: specifier: ^1.0.2 version: 1.0.3 '@certd/basic': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../../core/basic '@certd/lib-k8s': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../../libs/lib-k8s '@certd/pipeline': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../../core/pipeline '@certd/plugin-cert': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../../plugins/plugin-cert '@certd/plugin-lib': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../../plugins/plugin-lib '@certd/plus-core': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../plus-core ali-oss: specifier: ^6.21.0 @@ -998,7 +998,7 @@ importers: packages/pro/plus-core: dependencies: '@certd/basic': - specifier: ^1.37.15 + specifier: ^1.37.16 version: link:../../core/basic dayjs: specifier: ^1.11.7 @@ -21364,13 +21364,13 @@ snapshots: resolve: 1.22.10 semver: 6.3.1 - eslint-plugin-prettier@3.4.1(eslint-config-prettier@8.10.0(eslint@7.32.0))(eslint@7.32.0)(prettier@2.8.8): + eslint-plugin-prettier@3.4.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@7.32.0)(prettier@2.8.8): dependencies: eslint: 7.32.0 prettier: 2.8.8 prettier-linter-helpers: 1.0.0 optionalDependencies: - eslint-config-prettier: 8.10.0(eslint@7.32.0) + eslint-config-prettier: 8.10.0(eslint@8.57.0) eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@8.57.0)(prettier@2.8.8): dependencies: @@ -23784,7 +23784,7 @@ snapshots: eslint: 7.32.0 eslint-config-prettier: 8.10.0(eslint@7.32.0) eslint-plugin-node: 11.1.0(eslint@7.32.0) - eslint-plugin-prettier: 3.4.1(eslint-config-prettier@8.10.0(eslint@7.32.0))(eslint@7.32.0)(prettier@2.8.8) + eslint-plugin-prettier: 3.4.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@7.32.0)(prettier@2.8.8) execa: 5.1.1 inquirer: 7.3.3 json5: 2.2.3