fix: 增加权限相关helper说明

pull/68/head
xiaojunnuo 2024-04-08 10:05:11 +08:00
parent 836d18f07e
commit 4304c9443a
3 changed files with 13 additions and 14 deletions

View File

@ -11,6 +11,7 @@ export class AliyunAccess {
component: {
placeholder: "accessKeyId",
},
helper:"注意证书申请需要dns解析权限其他阿里云插件也需要对应的权限比如证书上传需要证书管理权限",
required: true,
})
accessKeyId = "";

View File

@ -19,8 +19,8 @@ export class SshClient {
}
* @param options
*/
uploadFiles(options: { connectConf: any; transports: any; sudo: boolean }) {
const { connectConf, transports, sudo } = options;
uploadFiles(options: { connectConf: any; transports: any; }) {
const { connectConf, transports } = options;
const conn = new ssh2.Client();
return new Promise((resolve, reject) => {
@ -35,8 +35,7 @@ export class SshClient {
try {
for (const transport of transports) {
this.logger.info("上传文件:", JSON.stringify(transport));
const sudoCmd = sudo ? "sudo" : "";
await this.exec({ connectConf, script: `${sudoCmd} mkdir -p ${path.dirname(transport.remotePath)} ` });
await this.exec({ connectConf, script: `mkdir -p ${path.dirname(transport.remotePath)} ` });
await this.fastPut({ sftp, ...transport });
}
resolve({});

View File

@ -15,10 +15,18 @@ import * as fs from "fs";
export class UploadCertToHostPlugin extends AbstractTaskPlugin {
@TaskInput({
title: "证书保存路径",
helper: "需要有写入权限,路径要包含证书文件名",
component:{
placeholder:"/root/deploy/nginx/cert.crt",
}
})
crtPath!: string;
@TaskInput({
title: "私钥保存路径",
helper: "需要有写入权限,路径要包含证书文件名",
component:{
placeholder:"/root/deploy/nginx/cert.crt",
}
})
keyPath!: string;
@TaskInput({
@ -40,14 +48,6 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
rules: [{ required: true, message: "此项必填" }],
})
accessId!: string;
@TaskInput({
title: "是否sudo",
component: {
name: "a-checkbox",
vModel: "checked",
},
})
sudo!: boolean;
@TaskOutput({
title: "证书保存路径",
@ -67,7 +67,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
this.logger = this.ctx.logger;
}
async execute(): Promise<void> {
const { crtPath, keyPath, cert, accessId, sudo } = this;
const { crtPath, keyPath, cert, accessId } = this;
const certReader = new CertReader(cert);
const connectConf = await this.accessService.getById(accessId);
const sshClient = new SshClient(this.logger);
@ -87,7 +87,6 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
remotePath: keyPath,
},
],
sudo,
});
this.logger.info("证书上传成功crtPath=", crtPath, ",keyPath=", keyPath);