chore: format

This commit is contained in:
xiaojunnuo
2026-05-31 01:41:33 +08:00
parent acd440106b
commit 4b57a0d729
557 changed files with 12530 additions and 14039 deletions
@@ -1,35 +1,35 @@
import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
import { IsAccess, AccessInput, BaseAccess } from "@certd/pipeline";
/**
* 这个注解将注册一个授权配置
* 在certd的后台管理系统中,用户可以选择添加此类型的授权
*/
@IsAccess({
name: 'proxmox',
title: 'proxmox',
desc: '',
icon: 'svg:icon-proxmox',
name: "proxmox",
title: "proxmox",
desc: "",
icon: "svg:icon-proxmox",
})
export class ProxmoxAccess extends BaseAccess {
/**
* 授权属性配置
*/
@AccessInput({
title: 'host',
title: "host",
component: {
placeholder: 'IP或域名',
placeholder: "IP或域名",
},
required: true,
encrypt: false,
})
host = '';
host = "";
@AccessInput({
title: '端口',
title: "端口",
component: {
placeholder: '端口',
placeholder: "端口",
component: {
name: 'a-input-number',
name: "a-input-number",
},
},
required: true,
@@ -40,39 +40,37 @@ export class ProxmoxAccess extends BaseAccess {
* 授权属性配置
*/
@AccessInput({
title: '用户名',
title: "用户名",
component: {
placeholder: 'username',
placeholder: "username",
},
required: true,
encrypt: false,
})
username = '';
username = "";
@AccessInput({
title: '密码',
title: "密码",
component: {
placeholder: 'password',
placeholder: "password",
},
required: true,
encrypt: true,
})
password = '';
password = "";
@AccessInput({
title: '领域',
title: "领域",
value: "pam",
component: {
placeholder: 'pam、pve。默认值 pam',
placeholder: "pam、pve。默认值 pam",
},
helper:"pam 或 pve。默认值 pam",
helper: "pam 或 pve。默认值 pam",
required: false,
encrypt: false,
})
realm = '';
realm = "";
@AccessInput({
title: "测试",
component: {
@@ -88,27 +86,25 @@ export class ProxmoxAccess extends BaseAccess {
return "ok";
}
async getNodeList() {
const client = await this.getClient();
const nodesRes = await client.nodes.index();
// this.logger.info('nodes:', nodesRes.response);
if (!nodesRes.response?.data) {
return []
return [];
}
return nodesRes.response.data
return nodesRes.response.data;
}
async getClient() {
const pve = await import('@certd/cv4pve-api-javascript');
const pve = await import("@certd/cv4pve-api-javascript");
const client = new pve.PveClient(this.host, this.port);
const login = await client.login(this.username, this.password, this.realm || 'pam');
const login = await client.login(this.username, this.password, this.realm || "pam");
if (!login) {
throw new Error(`Login failed:${JSON.stringify(login)}`);
}
const versionRes = await client.version.version();
this.ctx.logger.info('Proxmox version:', versionRes.response);
this.ctx.logger.info("Proxmox version:", versionRes.response);
return client;
}
}
@@ -1,2 +1,2 @@
export * from './plugins/index.js';
export * from './access.js';
export * from "./plugins/index.js";
export * from "./access.js";
@@ -1 +1 @@
export * from './plugin-upload.js';
export * from "./plugin-upload.js";
@@ -1,14 +1,14 @@
import { IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
import { CertInfo } from '@certd/plugin-cert';
import { IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
import { CertInfo } from "@certd/plugin-cert";
import { AbstractPlusTaskPlugin } from "@certd/plugin-plus";
import { ProxmoxAccess } from '../access.js';
import { createRemoteSelectInputDefine } from '@certd/plugin-lib';
import { CertApplyPluginNames} from '@certd/plugin-cert';
import { ProxmoxAccess } from "../access.js";
import { createRemoteSelectInputDefine } from "@certd/plugin-lib";
import { CertApplyPluginNames } from "@certd/plugin-cert";
@IsTaskPlugin({
//命名规范,插件名称+功能(就是目录plugin-demo中的demo),大写字母开头,驼峰命名
name: 'ProxmoxUploadCert',
title: 'Proxmox-上传证书到Proxmox',
icon: 'svg:icon-proxmox',
name: "ProxmoxUploadCert",
title: "Proxmox-上传证书到Proxmox",
icon: "svg:icon-proxmox",
//插件分组
group: pluginGroups.panel.key,
needPlus: true,
@@ -23,10 +23,10 @@ import { CertApplyPluginNames} from '@certd/plugin-cert';
export class ProxmoxUploadCert extends AbstractPlusTaskPlugin {
//证书选择,此项必须要有
@TaskInput({
title: '域名证书',
helper: '请选择前置任务输出的域名证书',
title: "域名证书",
helper: "请选择前置任务输出的域名证书",
component: {
name: 'output-selector',
name: "output-selector",
from: [...CertApplyPluginNames],
},
// required: true, // 必填
@@ -39,10 +39,10 @@ export class ProxmoxUploadCert extends AbstractPlusTaskPlugin {
//授权选择框
@TaskInput({
title: 'Proxmox授权',
title: "Proxmox授权",
component: {
name: 'access-selector',
type: 'proxmox', //固定授权类型
name: "access-selector",
type: "proxmox", //固定授权类型
},
required: true, //必填
})
@@ -51,11 +51,11 @@ export class ProxmoxUploadCert extends AbstractPlusTaskPlugin {
@TaskInput(
createRemoteSelectInputDefine({
title: '节点',
helper: '要部署证书的节点',
typeName: 'ProxmoxUploadCert',
title: "节点",
helper: "要部署证书的节点",
typeName: "ProxmoxUploadCert",
action: ProxmoxUploadCert.prototype.onGetNodeList.name,
watches: ['accessId'],
watches: ["accessId"],
})
)
nodes!: string[];
@@ -71,21 +71,19 @@ export class ProxmoxUploadCert extends AbstractPlusTaskPlugin {
for (const node of this.nodes) {
this.logger.info(`开始上传证书到节点:${node}`);
try{
try {
const res = await client.nodes.get(node).certificates.custom.uploadCustomCert(cert.crt, true, cert.key, true);
this.logger.info(`上传结果:${JSON.stringify(res.response)}`);
}catch (e) {
} catch (e) {
this.logger.error(`执行失败:${e.message},请检查节点名称是否正确`);
throw e
throw e;
}
}
this.logger.info('部署成功');
this.logger.info("部署成功");
}
async onGetNodeList() {
async onGetNodeList() {
const access = await this.getAccess<ProxmoxAccess>(this.accessId);
const nodesRes = await access.getNodeList();
return nodesRes.map((node: any) => {