mirror of https://github.com/certd/certd
fix: 修复上传证书到腾讯云失败的bug
parent
14de21ee64
commit
e950322232
|
@ -88,7 +88,7 @@ export type Pipeline = Runnable & {
|
|||
userId: any;
|
||||
stages: Stage[];
|
||||
triggers: Trigger[];
|
||||
notifications: Notification[];
|
||||
notifications?: Notification[];
|
||||
};
|
||||
|
||||
export type Context = {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { IAccessService } from "@certd/pipeline";
|
||||
import { EmailSend, IAccessService, IEmailService } from "@certd/pipeline";
|
||||
import { AliyunAccess } from "@certd/plugin-aliyun";
|
||||
import { aliyunSecret } from "../user.secret";
|
||||
|
||||
export class AccessServiceTest implements IAccessService {
|
||||
async getById(id: any): Promise<any> {
|
||||
return {
|
||||
|
@ -8,3 +9,10 @@ export class AccessServiceTest implements IAccessService {
|
|||
} as AliyunAccess;
|
||||
}
|
||||
}
|
||||
|
||||
export class EmailServiceTest implements IEmailService {
|
||||
send(email: EmailSend): Promise<void> {
|
||||
console.log("send email", email);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,17 @@ export const pipeline: Pipeline = {
|
|||
runStrategy: RunStrategy.SkipWhenSucceed,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: generateId(),
|
||||
title: "上传证书到腾讯云",
|
||||
type: "EchoPlugin",
|
||||
input: {
|
||||
cert: "cert",
|
||||
},
|
||||
strategy: {
|
||||
runStrategy: RunStrategy.SkipWhenSucceed,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import "mocha";
|
||||
import { Executor, FileStorage, RunHistory } from "@certd/pipeline";
|
||||
import { pipeline } from "./pipeline.define";
|
||||
import { AccessServiceTest } from "./access-service-test";
|
||||
import { AccessServiceTest, EmailServiceTest } from "./access-service-test";
|
||||
import "../../src";
|
||||
import "../plugin/echo-plugin";
|
||||
|
||||
|
@ -13,7 +13,14 @@ describe("pipeline", function () {
|
|||
console.log("changed:");
|
||||
}
|
||||
|
||||
const executor = new Executor({ userId: "test", pipeline, onChanged, accessService: new AccessServiceTest(), storage: new FileStorage() });
|
||||
const executor = new Executor({
|
||||
userId: "test",
|
||||
pipeline,
|
||||
onChanged,
|
||||
accessService: new AccessServiceTest(),
|
||||
emailService: new EmailServiceTest(),
|
||||
storage: new FileStorage(),
|
||||
});
|
||||
await executor.run(1, "user");
|
||||
// expect(define.name).eq("EchoPlugin");
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue