fix: 修复上传证书到腾讯云失败的bug

This commit is contained in:
xiaojunnuo
2023-07-10 11:52:38 +08:00
parent 14de21ee64
commit e950322232
9 changed files with 68 additions and 13 deletions
@@ -7,13 +7,20 @@ import { IsAccess, AccessInput } from "@certd/pipeline";
})
export class DnspodAccess {
@AccessInput({
title: "token",
title: "端点",
component: {
placeholder: "开放接口token",
placeholder: "endpoint",
name: "a-select",
vModel: "value",
options: [
{ value: "https://dnsapi.cn", label: "中国站" },
{ value: "https://api.dnspod.com", label: "国际站" },
],
},
rules: [{ required: true, message: "该项必填" }],
})
token = "";
endpoint = "";
@AccessInput({
title: "账户id",
component: {
@@ -22,6 +29,15 @@ export class DnspodAccess {
rules: [{ required: true, message: "该项必填" }],
})
id = "";
@AccessInput({
title: "token",
component: {
placeholder: "开放接口token",
},
rules: [{ required: true, message: "该项必填" }],
})
token = "";
}
new DnspodAccess();
@@ -20,9 +20,11 @@ export class DnspodDnsProvider implements IDnsProvider {
loginToken: any;
endpoint = "";
async onInstance() {
const access: DnspodAccess = this.access as DnspodAccess;
this.loginToken = access.id + "," + access.token;
this.endpoint = access.endpoint || "https://dnsapi.cn";
}
async doRequest(options: any, successCodes: string[] = []) {
@@ -51,7 +53,7 @@ export class DnspodDnsProvider implements IDnsProvider {
async getDomainList() {
const ret = await this.doRequest({
url: "https://dnsapi.cn/Domain.List",
url: this.access.endpoint + "/Domain.List",
});
this.logger.debug("dnspod 域名列表:", ret.domains);
return ret.domains;
@@ -66,7 +68,7 @@ export class DnspodDnsProvider implements IDnsProvider {
const ret = await this.doRequest(
{
url: "https://dnsapi.cn/Record.Create",
url: this.access.endpoint + "/Record.Create",
formData: {
domain,
sub_domain: rr,
@@ -87,7 +89,7 @@ export class DnspodDnsProvider implements IDnsProvider {
const domain = await this.matchDomain(fullRecord);
const ret = await this.doRequest({
url: "https://dnsapi.cn/Record.Remove",
url: this.access.endpoint + "/Record.Remove",
formData: {
domain,
record_id: record.id,
@@ -47,6 +47,17 @@ export class DeployToCdnPlugin extends AbstractTaskPlugin {
})
domainName!: string;
@TaskInput({
title: "CDN接口",
helper: "CDN接口端点",
component: {
name: "a-select",
type: "tencent",
},
required: true,
})
endpoint!: string;
accessService!: IAccessService;
logger!: ILogger;
@@ -87,7 +87,7 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
this.logger = this.ctx.logger;
}
async execute(): Promise<void> {
const accessProvider = this.accessService.getById(this.accessId);
const accessProvider = await this.accessService.getById(this.accessId);
const tkeClient = this.getTkeClient(accessProvider, this.region);
const kubeConfigStr = await this.getTkeKubeConfig(tkeClient, this.clusterId);
@@ -52,7 +52,7 @@ export class UploadToTencentPlugin extends AbstractTaskPlugin {
async execute(): Promise<void> {
const { accessId, name, cert } = this;
const accessProvider = this.accessService.getById(accessId);
const accessProvider = await this.accessService.getById(accessId);
const certName = this.appendTimeSuffix(name || cert.domain);
const client = this.getClient(accessProvider);
@@ -96,7 +96,7 @@ export class UploadToTencentPlugin extends AbstractTaskPlugin {
// async rollback({ input }) {
// const { accessId } = input;
// const accessProvider = this.accessService.getById(accessId);
// const accessProvider = await this.accessService.getById(accessId);
// const client = this.getClient(accessProvider);
//
// const { tencentCertId } = context;