mirror of
https://github.com/certd/certd.git
synced 2026-05-15 20:47:31 +08:00
perf: 1panel支持先上传证书再选择证书
This commit is contained in:
+33
-1
@@ -2,7 +2,7 @@ import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput
|
||||
|
||||
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { OnePanelAccess } from "../access.js";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine, ICertInfoGetter } from "@certd/plugin-lib";
|
||||
import { OnePanelClient } from "../client.js";
|
||||
|
||||
@IsTaskPlugin({
|
||||
@@ -66,6 +66,7 @@ export class OnePanelDeployToWebsitePlugin extends AbstractTaskPlugin {
|
||||
watches: ["accessId"],
|
||||
helper: "要更新的1Panel证书id,选择授权之后,从下拉框中选择\nIP需要加白名单,如果是同一台机器部署的,可以试试172.16.0.0/12",
|
||||
required: true,
|
||||
uploadCert: {}
|
||||
})
|
||||
)
|
||||
sslIds!: string[];
|
||||
@@ -213,5 +214,36 @@ export class OnePanelDeployToWebsitePlugin extends AbstractTaskPlugin {
|
||||
});
|
||||
return this.ctx.utils.options.buildGroupOptions(list, this.certDomains);
|
||||
}
|
||||
|
||||
async onUploadCert(data: { pipelineId: string, certName: string }) {
|
||||
if (!this.access) {
|
||||
throw new Error("请先选择1panel授权");
|
||||
}
|
||||
const certInfoGetter = await this.ctx.serviceGetter.get<ICertInfoGetter>("certInfoGetter")
|
||||
const cert = await certInfoGetter.getByPipelineId(Number(data.pipelineId));
|
||||
|
||||
const client = new OnePanelClient({
|
||||
access: this.access,
|
||||
http: this.http,
|
||||
logger: this.logger,
|
||||
utils: this.ctx.utils,
|
||||
});
|
||||
|
||||
await client.doRequest({
|
||||
url: `/api/${this.access.apiVersion}/websites/ssl/upload`,
|
||||
method: "post",
|
||||
data: {
|
||||
sslId: 0,
|
||||
certificate: cert.crt,
|
||||
certificatePath: "",
|
||||
description: data.certName,
|
||||
privateKey: cert.key,
|
||||
privateKeyPath: "",
|
||||
type: "paste",
|
||||
},
|
||||
currentNode: this.currentNode,
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
new OnePanelDeployToWebsitePlugin();
|
||||
|
||||
Reference in New Issue
Block a user