mirror of https://github.com/certd/certd
perf: 优化成功后跳过的提示
parent
ffc4e71783
commit
7b451bbf6e
|
@ -6,7 +6,7 @@ import { IAccessService } from "../access/index.js";
|
||||||
import { IEmailService } from "../service/index.js";
|
import { IEmailService } from "../service/index.js";
|
||||||
import { IContext } from "../core/index.js";
|
import { IContext } from "../core/index.js";
|
||||||
import { AxiosInstance } from "axios";
|
import { AxiosInstance } from "axios";
|
||||||
import { logger } from "../utils/index.js";
|
import { ILogger, logger } from "../utils/index.js";
|
||||||
|
|
||||||
export enum ContextScope {
|
export enum ContextScope {
|
||||||
global,
|
global,
|
||||||
|
@ -69,6 +69,9 @@ export type TaskInstanceContext = {
|
||||||
export abstract class AbstractTaskPlugin implements ITaskPlugin {
|
export abstract class AbstractTaskPlugin implements ITaskPlugin {
|
||||||
_result: TaskResult = { clearLastStatus: false, files: [], pipelineVars: {} };
|
_result: TaskResult = { clearLastStatus: false, files: [], pipelineVars: {} };
|
||||||
ctx!: TaskInstanceContext;
|
ctx!: TaskInstanceContext;
|
||||||
|
logger!: ILogger;
|
||||||
|
accessService!: IAccessService;
|
||||||
|
|
||||||
clearLastStatus() {
|
clearLastStatus() {
|
||||||
this._result.clearLastStatus = true;
|
this._result.clearLastStatus = true;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +82,8 @@ export abstract class AbstractTaskPlugin implements ITaskPlugin {
|
||||||
|
|
||||||
setCtx(ctx: TaskInstanceContext) {
|
setCtx(ctx: TaskInstanceContext) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
this.logger = ctx.logger;
|
||||||
|
this.accessService = ctx.accessService;
|
||||||
}
|
}
|
||||||
|
|
||||||
randomFileId() {
|
randomFileId() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { AbstractTaskPlugin, HttpClient, IAccessService, IContext, Step, TaskInput, TaskOutput } from "@certd/pipeline";
|
import { AbstractTaskPlugin, HttpClient, IContext, Step, TaskInput, TaskOutput } from "@certd/pipeline";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import type { CertInfo } from "./acme.js";
|
import type { CertInfo } from "./acme.js";
|
||||||
import { Logger } from "log4js";
|
|
||||||
import { CertReader } from "./cert-reader.js";
|
import { CertReader } from "./cert-reader.js";
|
||||||
import JSZip from "jszip";
|
import JSZip from "jszip";
|
||||||
|
|
||||||
|
@ -91,9 +90,7 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
|
||||||
// })
|
// })
|
||||||
csrInfo!: string;
|
csrInfo!: string;
|
||||||
|
|
||||||
logger!: Logger;
|
|
||||||
userContext!: IContext;
|
userContext!: IContext;
|
||||||
accessService!: IAccessService;
|
|
||||||
http!: HttpClient;
|
http!: HttpClient;
|
||||||
lastStatus!: Step;
|
lastStatus!: Step;
|
||||||
|
|
||||||
|
@ -103,8 +100,6 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
|
||||||
cert?: CertInfo;
|
cert?: CertInfo;
|
||||||
|
|
||||||
async onInstance() {
|
async onInstance() {
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
this.userContext = this.ctx.userContext;
|
this.userContext = this.ctx.userContext;
|
||||||
this.http = this.ctx.http;
|
this.http = this.ctx.http;
|
||||||
this.lastStatus = this.ctx.lastStatus as Step;
|
this.lastStatus = this.ctx.lastStatus as Step;
|
||||||
|
|
|
@ -23,7 +23,7 @@ export default {
|
||||||
const currentStepIndex = inject("currentStepIndex") as Ref<number>;
|
const currentStepIndex = inject("currentStepIndex") as Ref<number>;
|
||||||
const currentTask = inject("currentTask") as Ref<any>;
|
const currentTask = inject("currentTask") as Ref<any>;
|
||||||
|
|
||||||
const getPluginGroups = inject("getPluginGroups") as Ref<any>;
|
const getPluginGroups = inject("getPluginGroups") as any;
|
||||||
const pluginGroups = getPluginGroups();
|
const pluginGroups = getPluginGroups();
|
||||||
function onCreate() {
|
function onCreate() {
|
||||||
options.value = pluginGroups.getPreStepOutputOptions({
|
options.value = pluginGroups.getPreStepOutputOptions({
|
||||||
|
@ -42,7 +42,7 @@ export default {
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => {
|
() => {
|
||||||
return pluginGroups.value.map;
|
return pluginGroups.value?.map;
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
onCreate();
|
onCreate();
|
||||||
|
|
|
@ -61,24 +61,7 @@
|
||||||
<fs-form-item v-model="currentStep.input[key]" :item="item" :get-context-fn="blankFn" />
|
<fs-form-item v-model="currentStep.input[key]" :item="item" :get-context-fn="blankFn" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<fs-form-item
|
<fs-form-item v-model="currentStep.strategy.runStrategy" :item="runStrategyProps" :get-context-fn="blankFn" />
|
||||||
v-model="currentStep.strategy.runStrategy"
|
|
||||||
:item="{
|
|
||||||
title: '运行策略',
|
|
||||||
key: 'strategy.runStrategy',
|
|
||||||
component: {
|
|
||||||
name: 'a-select',
|
|
||||||
vModel: 'value',
|
|
||||||
options: [
|
|
||||||
{ value: 0, label: '正常运行(证书申请任务请选择它)' },
|
|
||||||
{ value: 1, label: '成功后跳过(非证书任务请选择它)' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
helper: '该任务运行成功一次之后下次运行是否跳过,保持默认即可',
|
|
||||||
rules: [{ required: true, message: '此项必填' }]
|
|
||||||
}"
|
|
||||||
:get-context-fn="blankFn"
|
|
||||||
/>
|
|
||||||
</a-form>
|
</a-form>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
@ -289,10 +272,36 @@ export default {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const runStrategyProps = ref({
|
||||||
|
title: "运行策略",
|
||||||
|
key: "strategy.runStrategy",
|
||||||
|
component: {
|
||||||
|
name: "a-select",
|
||||||
|
vModel: "value",
|
||||||
|
options: [
|
||||||
|
{ value: 0, label: "正常运行(证书申请任务请选择它)" },
|
||||||
|
{ value: 1, label: "成功后跳过(非证书任务请选择它)" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
helper: {
|
||||||
|
render: () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div>正常运行:每次都运行,证书任务需要每次都运行</div>
|
||||||
|
<div>成功后跳过:在证书没变化时,该任务成功一次之后跳过,不重复部署</div>
|
||||||
|
<div>保持默认即可,如果你想要再次测试部署,可以临时设置为正常运行</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: [{ required: true, message: "此项必填" }]
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...useStepForm(),
|
...useStepForm(),
|
||||||
labelCol: { span: 6 },
|
labelCol: { span: 6 },
|
||||||
wrapperCol: { span: 16 }
|
wrapperCol: { span: 16 },
|
||||||
|
runStrategyProps
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
koa:
|
|
||||||
port: 7001
|
|
||||||
|
|
||||||
flyway:
|
flyway:
|
||||||
scriptDir: './db/migration-pg'
|
scriptDir: './db/migration-pg'
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
koa:
|
preview:
|
||||||
port: 7001
|
enabled: true
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
koa:
|
preview:
|
||||||
port: 7001
|
enabled: false
|
||||||
|
|
||||||
|
typeorm:
|
||||||
|
dataSource:
|
||||||
|
default:
|
||||||
|
logging: false
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,10 @@ const development = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cron: {
|
cron: {
|
||||||
|
//启动时立即触发一次
|
||||||
immediateTriggerOnce: false,
|
immediateTriggerOnce: false,
|
||||||
|
//启动时仅注册admin(id=1)用户的
|
||||||
|
onlyAdminUser: false,
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 演示环境
|
* 演示环境
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { MidwayConfig } from '@midwayjs/core';
|
|
||||||
import { mergeConfig } from './loader.js';
|
|
||||||
|
|
||||||
const preview = {
|
|
||||||
/**
|
|
||||||
* 演示环境
|
|
||||||
*/
|
|
||||||
preview: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
typeorm: {
|
|
||||||
dataSource: {
|
|
||||||
default: {
|
|
||||||
logging: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as MidwayConfig;
|
|
||||||
|
|
||||||
mergeConfig(preview, 'preview');
|
|
||||||
export default preview;
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { MidwayConfig } from '@midwayjs/core';
|
|
||||||
import { mergeConfig } from './loader.js';
|
|
||||||
|
|
||||||
const production = {
|
|
||||||
/**
|
|
||||||
* 演示环境
|
|
||||||
*/
|
|
||||||
preview: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
typeorm: {
|
|
||||||
dataSource: {
|
|
||||||
default: {
|
|
||||||
logging: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as MidwayConfig;
|
|
||||||
|
|
||||||
mergeConfig(production, 'production');
|
|
||||||
export default production;
|
|
|
@ -1,11 +0,0 @@
|
||||||
import { MidwayConfig } from '@midwayjs/core';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
typeorm: {
|
|
||||||
dataSource: {
|
|
||||||
default: {
|
|
||||||
synchronize: true, // 如果第一次使用,不存在表,有同步的需求可以写 true
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as MidwayConfig;
|
|
|
@ -1,7 +0,0 @@
|
||||||
import { MidwayConfig } from '@midwayjs/core';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
koa: {
|
|
||||||
port: null,
|
|
||||||
},
|
|
||||||
} as MidwayConfig;
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Configuration, App } from '@midwayjs/core';
|
import { App, Configuration } from '@midwayjs/core';
|
||||||
import * as koa from '@midwayjs/koa';
|
import * as koa from '@midwayjs/koa';
|
||||||
import * as orm from '@midwayjs/typeorm';
|
import * as orm from '@midwayjs/typeorm';
|
||||||
import * as cache from '@midwayjs/cache';
|
import * as cache from '@midwayjs/cache';
|
||||||
|
@ -14,12 +14,7 @@ import { PreviewMiddleware } from './middleware/preview.js';
|
||||||
import { AuthorityMiddleware } from './middleware/authority.js';
|
import { AuthorityMiddleware } from './middleware/authority.js';
|
||||||
import { logger } from './utils/logger.js';
|
import { logger } from './utils/logger.js';
|
||||||
import { ResetPasswdMiddleware } from './middleware/reset-passwd/middleware.js';
|
import { ResetPasswdMiddleware } from './middleware/reset-passwd/middleware.js';
|
||||||
// import { DefaultErrorFilter } from './filter/default.filter.js';
|
|
||||||
// import { NotFoundFilter } from './filter/notfound.filter.js';
|
|
||||||
import DefaultConfig from './config/config.default.js';
|
import DefaultConfig from './config/config.default.js';
|
||||||
import ProductionConfig from './config/config.production.js';
|
|
||||||
import PreviewConfig from './config/config.preview.js';
|
|
||||||
import UnittestConfig from './config/config.unittest.js';
|
|
||||||
|
|
||||||
process.on('uncaughtException', error => {
|
process.on('uncaughtException', error => {
|
||||||
console.error('未捕获的异常:', error);
|
console.error('未捕获的异常:', error);
|
||||||
|
@ -43,9 +38,6 @@ process.on('uncaughtException', error => {
|
||||||
importConfigs: [
|
importConfigs: [
|
||||||
{
|
{
|
||||||
default: DefaultConfig,
|
default: DefaultConfig,
|
||||||
preview: PreviewConfig,
|
|
||||||
production: ProductionConfig,
|
|
||||||
unittest: UnittestConfig,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,12 +1,4 @@
|
||||||
import {
|
import { Provide, Controller, Post, Inject, Body, Query, ALL } from '@midwayjs/core';
|
||||||
Provide,
|
|
||||||
Controller,
|
|
||||||
Post,
|
|
||||||
Inject,
|
|
||||||
Body,
|
|
||||||
Query,
|
|
||||||
ALL,
|
|
||||||
} from '@midwayjs/core';
|
|
||||||
import { UserService } from '../service/user-service.js';
|
import { UserService } from '../service/user-service.js';
|
||||||
import { CrudController } from '../../../basic/crud-controller.js';
|
import { CrudController } from '../../../basic/crud-controller.js';
|
||||||
import { RoleService } from '../service/role-service.js';
|
import { RoleService } from '../service/role-service.js';
|
||||||
|
|
|
@ -191,4 +191,17 @@ export class UserService extends BaseService<UserEntity> {
|
||||||
};
|
};
|
||||||
await this.update(param);
|
await this.update(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async delete(ids: any) {
|
||||||
|
if (typeof ids === 'string') {
|
||||||
|
ids = ids.split(',');
|
||||||
|
ids = ids.map(id => parseInt(id));
|
||||||
|
}
|
||||||
|
if (ids instanceof Array) {
|
||||||
|
if (ids.includes(1)) {
|
||||||
|
throw new CommonException('不能删除管理员');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await super.delete(ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ export class AutoRegisterCron {
|
||||||
@Inject()
|
@Inject()
|
||||||
pipelineService: PipelineService;
|
pipelineService: PipelineService;
|
||||||
|
|
||||||
@Config('preview.enabled')
|
@Config('cron.onlyAdminUser')
|
||||||
private preview: boolean;
|
private onlyAdminUser: boolean;
|
||||||
|
|
||||||
// @Inject()
|
// @Inject()
|
||||||
// echoPlugin: EchoPlugin;
|
// echoPlugin: EchoPlugin;
|
||||||
|
@ -19,7 +19,7 @@ export class AutoRegisterCron {
|
||||||
@Init()
|
@Init()
|
||||||
async init() {
|
async init() {
|
||||||
logger.info('加载定时trigger开始');
|
logger.info('加载定时trigger开始');
|
||||||
await this.pipelineService.onStartup(this.immediateTriggerOnce, this.preview);
|
await this.pipelineService.onStartup(this.immediateTriggerOnce, this.onlyAdminUser);
|
||||||
// logger.info(this.echoPlugin, this.echoPlugin.test);
|
// logger.info(this.echoPlugin, this.echoPlugin.test);
|
||||||
// logger.info('加载定时trigger完成');
|
// logger.info('加载定时trigger完成');
|
||||||
//
|
//
|
||||||
|
|
|
@ -136,10 +136,13 @@ export class HistoryService extends BaseService<HistoryEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteByIds(ids: number[], userId: number) {
|
async deleteByIds(ids: number[], userId: number) {
|
||||||
await this.repository.delete({
|
const condition: any = {
|
||||||
id: In(ids),
|
id: In(ids),
|
||||||
userId,
|
};
|
||||||
});
|
if (userId != null) {
|
||||||
|
condition.userId = userId;
|
||||||
|
}
|
||||||
|
await this.repository.delete(condition);
|
||||||
await this.logService.deleteByHistoryIds(ids);
|
await this.logService.deleteByHistoryIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,10 +149,10 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||||
/**
|
/**
|
||||||
* 应用启动后初始加载记录
|
* 应用启动后初始加载记录
|
||||||
*/
|
*/
|
||||||
async onStartup(immediateTriggerOnce: boolean, preview: boolean) {
|
async onStartup(immediateTriggerOnce: boolean, onlyAdminUser: boolean) {
|
||||||
logger.info('加载定时trigger开始');
|
logger.info('加载定时trigger开始');
|
||||||
await this.foreachPipeline(async entity => {
|
await this.foreachPipeline(async entity => {
|
||||||
if (preview && entity.userId !== 1) {
|
if (onlyAdminUser && entity.userId !== 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pipeline = JSON.parse(entity.content ?? '{}');
|
const pipeline = JSON.parse(entity.content ?? '{}');
|
||||||
|
|
|
@ -11,8 +11,7 @@ export class AliyunAccess {
|
||||||
component: {
|
component: {
|
||||||
placeholder: 'accessKeyId',
|
placeholder: 'accessKeyId',
|
||||||
},
|
},
|
||||||
helper:
|
helper: '注意:证书申请,需要dns解析权限;其他阿里云插件,也需要对应的权限,比如证书上传需要证书管理权限',
|
||||||
'注意:证书申请,需要dns解析权限;其他阿里云插件,也需要对应的权限,比如证书上传需要证书管理权限',
|
|
||||||
required: true,
|
required: true,
|
||||||
})
|
})
|
||||||
accessKeyId = '';
|
accessKeyId = '';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AbstractTaskPlugin, IAccessService, ILogger, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, utils } from '@certd/pipeline';
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, utils } from '@certd/pipeline';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { ROAClient } from '@alicloud/pop-core';
|
import { ROAClient } from '@alicloud/pop-core';
|
||||||
import { AliyunAccess } from '../../access/index.js';
|
import { AliyunAccess } from '../../access/index.js';
|
||||||
|
@ -106,13 +106,7 @@ export class DeployCertToAliyunAckIngressPlugin extends AbstractTaskPlugin {
|
||||||
})
|
})
|
||||||
accessId!: string;
|
accessId!: string;
|
||||||
|
|
||||||
accessService!: IAccessService;
|
async onInstance(): Promise<void> {}
|
||||||
logger!: ILogger;
|
|
||||||
|
|
||||||
async onInstance(): Promise<void> {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
console.log('开始部署证书到阿里云cdn');
|
console.log('开始部署证书到阿里云cdn');
|
||||||
const { regionId, ingressClass, clusterId, isPrivateIpAddress, cert } = this;
|
const { regionId, ingressClass, clusterId, isPrivateIpAddress, cert } = this;
|
||||||
|
@ -121,7 +115,7 @@ export class DeployCertToAliyunAckIngressPlugin extends AbstractTaskPlugin {
|
||||||
const kubeConfigStr = await this.getKubeConfig(client, clusterId, isPrivateIpAddress);
|
const kubeConfigStr = await this.getKubeConfig(client, clusterId, isPrivateIpAddress);
|
||||||
|
|
||||||
this.logger.info('kubeconfig已成功获取');
|
this.logger.info('kubeconfig已成功获取');
|
||||||
const k8sClient = new K8sClient(kubeConfigStr,this.logger);
|
const k8sClient = new K8sClient(kubeConfigStr, this.logger);
|
||||||
const ingressType = ingressClass || 'qcloud';
|
const ingressType = ingressClass || 'qcloud';
|
||||||
if (ingressType === 'qcloud') {
|
if (ingressType === 'qcloud') {
|
||||||
throw new Error('暂未实现');
|
throw new Error('暂未实现');
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
import {
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||||
AbstractTaskPlugin,
|
|
||||||
IAccessService,
|
|
||||||
ILogger,
|
|
||||||
IsTaskPlugin, pluginGroups,
|
|
||||||
RunStrategy,
|
|
||||||
TaskInput,
|
|
||||||
} from '@certd/pipeline';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import Core from '@alicloud/pop-core';
|
import Core from '@alicloud/pop-core';
|
||||||
import RPCClient from '@alicloud/pop-core';
|
import RPCClient from '@alicloud/pop-core';
|
||||||
|
@ -57,18 +50,10 @@ export class DeployCertToAliyunCDN extends AbstractTaskPlugin {
|
||||||
})
|
})
|
||||||
accessId!: string;
|
accessId!: string;
|
||||||
|
|
||||||
accessService!: IAccessService;
|
async onInstance() {}
|
||||||
logger!: ILogger;
|
|
||||||
|
|
||||||
async onInstance() {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
console.log('开始部署证书到阿里云cdn');
|
console.log('开始部署证书到阿里云cdn');
|
||||||
const access = (await this.accessService.getById(
|
const access = (await this.accessService.getById(this.accessId)) as AliyunAccess;
|
||||||
this.accessId
|
|
||||||
)) as AliyunAccess;
|
|
||||||
const client = this.getClient(access);
|
const client = this.getClient(access);
|
||||||
const params = await this.buildParams();
|
const params = await this.buildParams();
|
||||||
await this.doRequest(client, params);
|
await this.doRequest(client, params);
|
||||||
|
@ -85,8 +70,7 @@ export class DeployCertToAliyunCDN extends AbstractTaskPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
async buildParams() {
|
async buildParams() {
|
||||||
const CertName =
|
const CertName = (this.certName ?? 'certd') + '-' + dayjs().format('YYYYMMDDHHmmss');
|
||||||
(this.certName ?? 'certd') + '-' + dayjs().format('YYYYMMDDHHmmss');
|
|
||||||
const cert: any = this.cert;
|
const cert: any = this.cert;
|
||||||
return {
|
return {
|
||||||
RegionId: 'cn-hangzhou',
|
RegionId: 'cn-hangzhou',
|
||||||
|
@ -103,11 +87,7 @@ export class DeployCertToAliyunCDN extends AbstractTaskPlugin {
|
||||||
const requestOption = {
|
const requestOption = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
};
|
};
|
||||||
const ret: any = await client.request(
|
const ret: any = await client.request('SetDomainServerCertificate', params, requestOption);
|
||||||
'SetDomainServerCertificate',
|
|
||||||
params,
|
|
||||||
requestOption
|
|
||||||
);
|
|
||||||
this.checkRet(ret);
|
this.checkRet(ret);
|
||||||
this.logger.info('设置cdn证书成功:', ret.RequestId);
|
this.logger.info('设置cdn证书成功:', ret.RequestId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { AbstractTaskPlugin, IAccessService, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskOutput } from '@certd/pipeline';
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskOutput } from '@certd/pipeline';
|
||||||
import Core from '@alicloud/pop-core';
|
import Core from '@alicloud/pop-core';
|
||||||
import { AliyunAccess } from '../../access/index.js';
|
import { AliyunAccess } from '../../access/index.js';
|
||||||
import { appendTimeSuffix, checkRet, ZoneOptions } from '../../utils/index.js';
|
import { appendTimeSuffix, checkRet, ZoneOptions } from '../../utils/index.js';
|
||||||
import { Logger } from 'log4js';
|
|
||||||
|
|
||||||
@IsTaskPlugin({
|
@IsTaskPlugin({
|
||||||
name: 'uploadCertToAliyun',
|
name: 'uploadCertToAliyun',
|
||||||
|
@ -26,8 +25,7 @@ export class UploadCertToAliyun extends AbstractTaskPlugin {
|
||||||
title: '大区',
|
title: '大区',
|
||||||
value: 'cn-hangzhou',
|
value: 'cn-hangzhou',
|
||||||
component: {
|
component: {
|
||||||
name: 'a-select',
|
name: 'a-auto-complete',
|
||||||
mode: 'tags',
|
|
||||||
vModel: 'value',
|
vModel: 'value',
|
||||||
options: ZoneOptions,
|
options: ZoneOptions,
|
||||||
},
|
},
|
||||||
|
@ -61,13 +59,7 @@ export class UploadCertToAliyun extends AbstractTaskPlugin {
|
||||||
})
|
})
|
||||||
aliyunCertId!: string;
|
aliyunCertId!: string;
|
||||||
|
|
||||||
accessService!: IAccessService;
|
async onInstance() {}
|
||||||
logger!: Logger;
|
|
||||||
|
|
||||||
async onInstance() {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
console.log('开始部署证书到阿里云cdn');
|
console.log('开始部署证书到阿里云cdn');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AbstractTaskPlugin, IAccessService, ILogger, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||||
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
||||||
|
|
||||||
@IsTaskPlugin({
|
@IsTaskPlugin({
|
||||||
|
@ -28,8 +28,8 @@ export class CloudflareDeployToCDNPlugin extends AbstractTaskPlugin {
|
||||||
title: '选择框',
|
title: '选择框',
|
||||||
component: {
|
component: {
|
||||||
//前端组件配置,具体配置见组件文档 https://www.antdv.com/components/select-cn
|
//前端组件配置,具体配置见组件文档 https://www.antdv.com/components/select-cn
|
||||||
name: 'a-select',
|
name: 'a-auto-complete',
|
||||||
mode: 'tags',
|
vModel: 'value',
|
||||||
options: [
|
options: [
|
||||||
{ value: '1', label: '选项1' },
|
{ value: '1', label: '选项1' },
|
||||||
{ value: '2', label: '选项2' },
|
{ value: '2', label: '选项2' },
|
||||||
|
@ -71,13 +71,7 @@ export class CloudflareDeployToCDNPlugin extends AbstractTaskPlugin {
|
||||||
})
|
})
|
||||||
accessId!: string;
|
accessId!: string;
|
||||||
|
|
||||||
accessService!: IAccessService;
|
async onInstance() {}
|
||||||
logger!: ILogger;
|
|
||||||
|
|
||||||
async onInstance() {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
const { select, text, cert, accessId } = this;
|
const { select, text, cert, accessId } = this;
|
||||||
const certReader = new CertReader(cert);
|
const certReader = new CertReader(cert);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { AbstractTaskPlugin, IAccessService, ILogger, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||||
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
||||||
import { K8sClient } from '@certd/lib-k8s';
|
|
||||||
|
|
||||||
@IsTaskPlugin({
|
@IsTaskPlugin({
|
||||||
name: 'demoTest',
|
name: 'demoTest',
|
||||||
|
@ -28,8 +27,8 @@ export class DemoTestPlugin extends AbstractTaskPlugin {
|
||||||
title: '选择框',
|
title: '选择框',
|
||||||
component: {
|
component: {
|
||||||
//前端组件配置,具体配置见组件文档 https://www.antdv.com/components/select-cn
|
//前端组件配置,具体配置见组件文档 https://www.antdv.com/components/select-cn
|
||||||
name: 'a-select',
|
name: 'a-auto-complete',
|
||||||
mode: 'tags',
|
vModel: 'value',
|
||||||
options: [
|
options: [
|
||||||
{ value: '1', label: '选项1' },
|
{ value: '1', label: '选项1' },
|
||||||
{ value: '2', label: '选项2' },
|
{ value: '2', label: '选项2' },
|
||||||
|
@ -55,7 +54,7 @@ export class DemoTestPlugin extends AbstractTaskPlugin {
|
||||||
component: {
|
component: {
|
||||||
name: 'pi-output-selector',
|
name: 'pi-output-selector',
|
||||||
},
|
},
|
||||||
required: true,
|
// required: true,
|
||||||
})
|
})
|
||||||
cert!: CertInfo;
|
cert!: CertInfo;
|
||||||
|
|
||||||
|
@ -67,31 +66,33 @@ export class DemoTestPlugin extends AbstractTaskPlugin {
|
||||||
name: 'pi-access-selector',
|
name: 'pi-access-selector',
|
||||||
type: 'demo', //固定授权类型
|
type: 'demo', //固定授权类型
|
||||||
},
|
},
|
||||||
rules: [{ required: true, message: '此项必填' }],
|
// rules: [{ required: true, message: '此项必填' }],
|
||||||
})
|
})
|
||||||
accessId!: string;
|
accessId!: string;
|
||||||
|
|
||||||
accessService!: IAccessService;
|
async onInstance() {}
|
||||||
logger!: ILogger;
|
|
||||||
|
|
||||||
async onInstance() {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
const { select, text, cert, accessId } = this;
|
const { select, text, cert, accessId } = this;
|
||||||
const certReader = new CertReader(cert);
|
|
||||||
const access = await this.accessService.getById(accessId);
|
try {
|
||||||
this.logger.debug('access', access);
|
const access = await this.accessService.getById(accessId);
|
||||||
this.logger.debug('certReader', certReader);
|
this.logger.debug('access', access);
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('获取授权失败', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const certReader = new CertReader(cert);
|
||||||
|
this.logger.debug('certReader', certReader);
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('读取crt失败', e);
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.info('DemoTestPlugin execute');
|
this.logger.info('DemoTestPlugin execute');
|
||||||
this.logger.info('text:', text);
|
this.logger.info('text:', text);
|
||||||
this.logger.info('select:', select);
|
this.logger.info('select:', select);
|
||||||
this.logger.info('switch:', this.switch);
|
this.logger.info('switch:', this.switch);
|
||||||
this.logger.info('授权id:', accessId);
|
this.logger.info('授权id:', accessId);
|
||||||
//TODO 这里实现你要部署的执行方法
|
|
||||||
|
|
||||||
new K8sClient('111', null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO 这里实例化插件,进行注册
|
//TODO 这里实例化插件,进行注册
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AbstractTaskPlugin, IAccessService, ILogger, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||||
import { SshClient } from '../../lib/ssh.js';
|
import { SshClient } from '../../lib/ssh.js';
|
||||||
|
|
||||||
@IsTaskPlugin({
|
@IsTaskPlugin({
|
||||||
|
@ -34,12 +34,7 @@ export class HostShellExecutePlugin extends AbstractTaskPlugin {
|
||||||
})
|
})
|
||||||
script!: string;
|
script!: string;
|
||||||
|
|
||||||
accessService!: IAccessService;
|
async onInstance() {}
|
||||||
logger!: ILogger;
|
|
||||||
async onInstance() {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
const { script, accessId } = this;
|
const { script, accessId } = this;
|
||||||
const connectConf = await this.accessService.getById(accessId);
|
const connectConf = await this.accessService.getById(accessId);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AbstractTaskPlugin, IAccessService, ILogger, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskOutput } from '@certd/pipeline';
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskOutput } from '@certd/pipeline';
|
||||||
import { SshClient } from '../../lib/ssh.js';
|
import { SshClient } from '../../lib/ssh.js';
|
||||||
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
@ -86,13 +86,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||||
})
|
})
|
||||||
hostKeyPath!: string;
|
hostKeyPath!: string;
|
||||||
|
|
||||||
accessService!: IAccessService;
|
async onInstance() {}
|
||||||
logger!: ILogger;
|
|
||||||
|
|
||||||
async onInstance() {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
copyFile(srcFile: string, destFile: string) {
|
copyFile(srcFile: string, destFile: string) {
|
||||||
const dir = destFile.substring(0, destFile.lastIndexOf('/'));
|
const dir = destFile.substring(0, destFile.lastIndexOf('/'));
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './k8s-access.js';
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { IsAccess, AccessInput } from '@certd/pipeline';
|
||||||
|
|
||||||
|
@IsAccess({
|
||||||
|
name: 'k8s',
|
||||||
|
title: 'k8s授权',
|
||||||
|
desc: '',
|
||||||
|
})
|
||||||
|
export class K8sAccess {
|
||||||
|
@AccessInput({
|
||||||
|
title: 'kubeconfig',
|
||||||
|
component: {
|
||||||
|
placeholder: 'kubeconfig',
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
})
|
||||||
|
kubeconfig = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
new K8sAccess();
|
|
@ -10,8 +10,7 @@ export class DnspodAccess {
|
||||||
title: '端点',
|
title: '端点',
|
||||||
component: {
|
component: {
|
||||||
placeholder: 'endpoint',
|
placeholder: 'endpoint',
|
||||||
name: 'a-select',
|
name: 'a-auto-complete',
|
||||||
mode: 'tags',
|
|
||||||
vModel: 'value',
|
vModel: 'value',
|
||||||
options: [
|
options: [
|
||||||
{ value: 'https://dnsapi.cn', label: '中国站' },
|
{ value: 'https://dnsapi.cn', label: '中国站' },
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AbstractTaskPlugin, IAccessService, ILogger, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||||
import tencentcloud from 'tencentcloud-sdk-nodejs';
|
import tencentcloud from 'tencentcloud-sdk-nodejs';
|
||||||
import { TencentAccess } from '../../access/index.js';
|
import { TencentAccess } from '../../access/index.js';
|
||||||
import { CertInfo } from '@certd/plugin-cert';
|
import { CertInfo } from '@certd/plugin-cert';
|
||||||
|
@ -59,14 +59,7 @@ export class DeployToCdnPlugin extends AbstractTaskPlugin {
|
||||||
// })
|
// })
|
||||||
// endpoint!: string;
|
// endpoint!: string;
|
||||||
|
|
||||||
accessService!: IAccessService;
|
async onInstance() {}
|
||||||
|
|
||||||
logger!: ILogger;
|
|
||||||
|
|
||||||
async onInstance() {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
const accessProvider: TencentAccess = (await this.accessService.getById(this.accessId)) as TencentAccess;
|
const accessProvider: TencentAccess = (await this.accessService.getById(this.accessId)) as TencentAccess;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AbstractTaskPlugin, IAccessService, ILogger, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, utils } from '@certd/pipeline';
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, utils } from '@certd/pipeline';
|
||||||
import tencentcloud from 'tencentcloud-sdk-nodejs';
|
import tencentcloud from 'tencentcloud-sdk-nodejs';
|
||||||
import { TencentAccess } from '../../access/index.js';
|
import { TencentAccess } from '../../access/index.js';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
@ -17,10 +17,9 @@ import dayjs from 'dayjs';
|
||||||
export class DeployToClbPlugin extends AbstractTaskPlugin {
|
export class DeployToClbPlugin extends AbstractTaskPlugin {
|
||||||
@TaskInput({
|
@TaskInput({
|
||||||
title: '大区',
|
title: '大区',
|
||||||
value: 'ap-guangzhou',
|
|
||||||
component: {
|
component: {
|
||||||
name: 'a-select',
|
name: 'a-auto-complete',
|
||||||
mode: 'tags',
|
vModel: 'value',
|
||||||
options: [
|
options: [
|
||||||
{ value: 'ap-guangzhou' },
|
{ value: 'ap-guangzhou' },
|
||||||
{ value: 'ap-beijing' },
|
{ value: 'ap-beijing' },
|
||||||
|
@ -93,13 +92,7 @@ export class DeployToClbPlugin extends AbstractTaskPlugin {
|
||||||
})
|
})
|
||||||
accessId!: string;
|
accessId!: string;
|
||||||
|
|
||||||
accessService!: IAccessService;
|
async onInstance() {}
|
||||||
logger!: ILogger;
|
|
||||||
|
|
||||||
async onInstance() {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
const accessProvider = (await this.accessService.getById(this.accessId)) as TencentAccess;
|
const accessProvider = (await this.accessService.getById(this.accessId)) as TencentAccess;
|
||||||
const client = this.getClient(accessProvider, this.region);
|
const client = this.getClient(accessProvider, this.region);
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { AbstractTaskPlugin, IAccessService, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, utils } from '@certd/pipeline';
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, utils } from '@certd/pipeline';
|
||||||
import tencentcloud from 'tencentcloud-sdk-nodejs';
|
import tencentcloud from 'tencentcloud-sdk-nodejs';
|
||||||
import { K8sClient } from '@certd/lib-k8s';
|
import { K8sClient } from '@certd/lib-k8s';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { Logger } from 'log4js';
|
|
||||||
|
|
||||||
@IsTaskPlugin({
|
@IsTaskPlugin({
|
||||||
name: 'DeployCertToTencentTKEIngress',
|
name: 'DeployCertToTencentTKEIngress',
|
||||||
|
@ -38,8 +37,10 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
|
||||||
|
|
||||||
@TaskInput({
|
@TaskInput({
|
||||||
title: 'ingress类型',
|
title: 'ingress类型',
|
||||||
|
value: 'qcloud',
|
||||||
component: {
|
component: {
|
||||||
name: 'a-select',
|
name: 'a-auto-complete',
|
||||||
|
vModel: 'value',
|
||||||
options: [{ value: 'qcloud' }, { value: 'nginx' }],
|
options: [{ value: 'qcloud' }, { value: 'nginx' }],
|
||||||
},
|
},
|
||||||
helper: '可选 qcloud / nginx',
|
helper: '可选 qcloud / nginx',
|
||||||
|
@ -89,12 +90,7 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
|
||||||
})
|
})
|
||||||
cert!: any;
|
cert!: any;
|
||||||
|
|
||||||
logger!: Logger;
|
async onInstance() {}
|
||||||
accessService!: IAccessService;
|
|
||||||
async onInstance() {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
const accessProvider = await this.accessService.getById(this.accessId);
|
const accessProvider = await this.accessService.getById(this.accessId);
|
||||||
const tkeClient = this.getTkeClient(accessProvider, this.region);
|
const tkeClient = this.getTkeClient(accessProvider, this.region);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AbstractTaskPlugin, IAccessService, ILogger, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskOutput } from '@certd/pipeline';
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskOutput } from '@certd/pipeline';
|
||||||
import tencentcloud from 'tencentcloud-sdk-nodejs';
|
import tencentcloud from 'tencentcloud-sdk-nodejs';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
@ -43,13 +43,7 @@ export class UploadToTencentPlugin extends AbstractTaskPlugin {
|
||||||
})
|
})
|
||||||
tencentCertId?: string;
|
tencentCertId?: string;
|
||||||
|
|
||||||
accessService!: IAccessService;
|
async onInstance() {}
|
||||||
logger!: ILogger;
|
|
||||||
|
|
||||||
async onInstance() {
|
|
||||||
this.accessService = this.ctx.accessService;
|
|
||||||
this.logger = this.ctx.logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
const { accessId, name, cert } = this;
|
const { accessId, name, cert } = this;
|
||||||
|
|
Loading…
Reference in New Issue