pull/229/head
xiaojunnuo 2024-10-26 18:10:19 +08:00
parent be2f0aa435
commit fdda8985de
6 changed files with 99 additions and 5 deletions

View File

@ -0,0 +1,89 @@
import { IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
import { AbstractPlusTaskPlugin } from '@certd/plugin-plus';
@IsTaskPlugin({
name: 'DeployCertToTencentAll',
title: '部署证书到腾讯云任意云资源',
needPlus: true,
icon: 'svg:icon-tencentcloud',
group: pluginGroups.tencent.key,
desc: '需要【上传到腾讯云】作为前置任务',
default: {
strategy: {
runStrategy: RunStrategy.SkipWhenSucceed,
},
},
})
export class DeployCertToTencentAll extends AbstractPlusTaskPlugin {
/**
* AccessProviderkey,access
*/
@TaskInput({
title: 'Access授权',
helper: 'access授权',
component: {
name: 'access-selector',
type: 'tencent',
},
required: true,
})
accessId!: string;
@TaskInput({
title: '腾讯云证书id',
helper: '请选择“上传证书到腾讯云”前置任务的输出',
component: {
name: 'output-selector',
from: 'UploadCertToTencent',
},
required: true,
})
tencentCertId!: string;
@TaskInput({
title: '云资源实例Id列表',
component: {
name: 'a-select',
vModel: 'value',
open: false,
mode: 'tags',
},
helper: '',
})
instanceIdList!: string[];
async onInstance() {}
async execute(): Promise<void> {
const accessProvider = await this.accessService.getById(this.accessId);
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/ssl/v20191205/index.js');
const Client = sdk.v20191205.Client;
const client = new Client({
credential: {
secretId: accessProvider.secretId,
secretKey: accessProvider.secretKey,
},
region: '',
profile: {
httpProfile: {
endpoint: 'ssl.tencentcloudapi.com',
},
},
});
const params = {
CertificateId: this.tencentCertId,
InstanceIdList: this.instanceIdList,
};
const res = await client.DeployCertificateInstance(params);
this.checkRet(res);
this.logger.info('部署成功');
}
checkRet(ret: any) {
if (!ret || ret.Error) {
throw new Error('执行失败:' + ret.Error.Code + ',' + ret.Error.Message);
}
}
}

View File

@ -14,7 +14,7 @@ import dayjs from 'dayjs';
},
},
})
export class DeployToClbPlugin extends AbstractTaskPlugin {
export class DeployCertToTencentCLB extends AbstractTaskPlugin {
@TaskInput({
title: '大区',
component: {

View File

@ -162,4 +162,4 @@ export class DeployCertToTencentCosPlugin extends AbstractPlusTaskPlugin {
}
}
// new DeployCertToTencentCosPlugin()
new DeployCertToTencentCosPlugin();

View File

@ -13,7 +13,7 @@ import { TencentAccess } from '@certd/plugin-plus';
},
},
})
export class DeployToEOPlugin extends AbstractTaskPlugin {
export class DeployCertToTencentEO extends AbstractTaskPlugin {
@TaskInput({
title: '已上传证书ID',
helper: '请选择前置任务上传到腾讯云的证书',
@ -131,3 +131,5 @@ export class DeployToEOPlugin extends AbstractTaskPlugin {
}
}
}
new DeployCertToTencentEO();

View File

@ -1,4 +1,7 @@
export * from './deploy-to-all/index.js';
export * from './deploy-to-clb/index.js';
export * from './deploy-to-cdn/index.js';
export * from './upload-to-tencent/index.js';
export * from './deploy-to-cdn-v2/index.js';
export * from './upload-to-tencent/index.js';
export * from './deploy-to-cos/index.js';
export * from './deploy-to-eo/index.js';

View File

@ -13,7 +13,7 @@ import dayjs from 'dayjs';
},
},
})
export class UploadToTencentPlugin extends AbstractTaskPlugin {
export class UploadCertToTencent extends AbstractTaskPlugin {
@TaskInput({ title: '证书名称' })
name!: string;