mirror of https://github.com/certd/certd
refactor: fix bugs
parent
146ac49703
commit
6094a4af79
|
@ -28,9 +28,10 @@ export class Executor {
|
|||
this.pipelineContext = this.contextFactory.getContext("pipeline", this.pipeline.id);
|
||||
}
|
||||
|
||||
async run(runtimeId: any = 0) {
|
||||
async run(runtimeId: any = 0, triggerType: string) {
|
||||
try {
|
||||
this.runtime = new RunHistory(runtimeId, this.pipeline);
|
||||
const trigger = { type: triggerType };
|
||||
this.runtime = new RunHistory(runtimeId, trigger, this.pipeline);
|
||||
this.logger.info(`pipeline.${this.pipeline.id} start`);
|
||||
await this.runWithHistory(this.pipeline, "pipeline", async () => {
|
||||
await this.runStages();
|
||||
|
@ -62,7 +63,6 @@ export class Executor {
|
|||
await this.onChanged(this.runtime);
|
||||
return ResultType.success;
|
||||
} catch (e: any) {
|
||||
this.logger.error(e);
|
||||
this.runtime.error(runnable, e);
|
||||
await this.pipelineContext.set(contextKey, ResultType.error);
|
||||
await this.onChanged(this.runtime);
|
||||
|
@ -140,7 +140,7 @@ export class Executor {
|
|||
const define = taskPlugin.getDefine();
|
||||
//从outputContext读取输入参数
|
||||
_.forEach(define.input, (item, key) => {
|
||||
if (item.component?.name === "output-selector") {
|
||||
if (item.component?.name === "pi-output-selector") {
|
||||
const contextKey = step.input[key];
|
||||
if (contextKey != null) {
|
||||
step.input[key] = this.runtime.context[contextKey];
|
||||
|
|
|
@ -8,6 +8,9 @@ export type HistoryStatus = {
|
|||
logs: string[];
|
||||
};
|
||||
|
||||
export type RunTrigger = {
|
||||
type: string; // user , timer
|
||||
};
|
||||
export class RunHistory {
|
||||
id: string;
|
||||
//运行时上下文变量
|
||||
|
@ -19,9 +22,11 @@ export class RunHistory {
|
|||
loggers: {
|
||||
[runnableId: string]: Logger;
|
||||
} = {};
|
||||
constructor(runtimeId: any, pipeline: Pipeline) {
|
||||
trigger: RunTrigger;
|
||||
constructor(runtimeId: any, trigger: RunTrigger, pipeline: Pipeline) {
|
||||
this.id = runtimeId;
|
||||
this.pipeline = pipeline;
|
||||
this.trigger = trigger;
|
||||
}
|
||||
|
||||
start(runnable: Runnable): HistoryResult {
|
||||
|
@ -72,7 +77,7 @@ export class RunHistory {
|
|||
message: e.message,
|
||||
});
|
||||
|
||||
this.log(runnable, `执行异常:${e.message}`);
|
||||
this.logError(runnable, e);
|
||||
}
|
||||
|
||||
log(runnable: Runnable, text: string) {
|
||||
|
@ -80,6 +85,11 @@ export class RunHistory {
|
|||
this.loggers[runnable.id].info(`[${runnable.title}]<id:${runnable.id}> [${runnable.runnableType}]`, text);
|
||||
}
|
||||
|
||||
logError(runnable: Runnable, e: Error) {
|
||||
// @ts-ignore
|
||||
this.loggers[runnable.id].error(`[${runnable.title}]<id:${runnable.id}> [${runnable.runnableType}]`, e);
|
||||
}
|
||||
|
||||
finally(runnable: Runnable) {
|
||||
//
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ export type Trigger = {
|
|||
id: string;
|
||||
title: string;
|
||||
cron: string;
|
||||
type: string;
|
||||
};
|
||||
|
||||
export type Runnable = {
|
||||
|
@ -60,6 +61,9 @@ export type Runnable = {
|
|||
strategy?: RunnableStrategy;
|
||||
runnableType?: string; // pipeline, stage, task , step
|
||||
status?: HistoryResult;
|
||||
default?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
|
||||
export type Pipeline = Runnable & {
|
||||
|
|
|
@ -23,6 +23,7 @@ export type CertInfo = {
|
|||
vModel: "value",
|
||||
mode: "tags",
|
||||
},
|
||||
required: true,
|
||||
col: {
|
||||
span: 24,
|
||||
},
|
||||
|
@ -34,6 +35,7 @@ export type CertInfo = {
|
|||
name: "a-input",
|
||||
vModel: "value",
|
||||
},
|
||||
required: true,
|
||||
helper: "请输入邮箱",
|
||||
},
|
||||
dnsProviderType: {
|
||||
|
@ -41,6 +43,7 @@ export type CertInfo = {
|
|||
component: {
|
||||
name: "pi-dns-provider-selector",
|
||||
},
|
||||
required: true,
|
||||
helper: "请选择dns解析提供商",
|
||||
},
|
||||
dnsProviderAccess: {
|
||||
|
@ -48,20 +51,20 @@ export type CertInfo = {
|
|||
component: {
|
||||
name: "pi-access-selector",
|
||||
},
|
||||
required: true,
|
||||
helper: "请选择dns解析提供商授权",
|
||||
},
|
||||
renewDays: {
|
||||
title: "更新天数",
|
||||
value: 20,
|
||||
component: {
|
||||
name: "a-input-number",
|
||||
vModel: "value",
|
||||
},
|
||||
required: true,
|
||||
helper: "到期前多少天后更新证书",
|
||||
},
|
||||
forceUpdate: {
|
||||
title: "强制更新",
|
||||
value: false,
|
||||
component: {
|
||||
name: "a-switch",
|
||||
vModel: "checked",
|
||||
|
@ -69,6 +72,12 @@ export type CertInfo = {
|
|||
helper: "是否强制重新申请证书",
|
||||
},
|
||||
},
|
||||
default: {
|
||||
input: {
|
||||
renewDays: 20,
|
||||
forceUpdate: false,
|
||||
},
|
||||
},
|
||||
output: {
|
||||
cert: {
|
||||
key: "cert",
|
||||
|
|
|
@ -5,6 +5,7 @@ import Core from "@alicloud/pop-core";
|
|||
import RPCClient from "@alicloud/pop-core";
|
||||
import { AliyunAccess } from "../../../access";
|
||||
import { CertInfo } from "../cert-plugin";
|
||||
import { RunStrategy } from "../../../d.ts";
|
||||
|
||||
@IsTask(() => {
|
||||
return {
|
||||
|
@ -14,16 +15,12 @@ import { CertInfo } from "../cert-plugin";
|
|||
input: {
|
||||
domainName: {
|
||||
title: "CDN加速域名",
|
||||
component: {
|
||||
placeholder: "你在阿里云上配置的CDN加速域名,比如certd.docmirror.cn",
|
||||
},
|
||||
helper: "你在阿里云上配置的CDN加速域名,比如certd.docmirror.cn",
|
||||
required: true,
|
||||
},
|
||||
certName: {
|
||||
title: "证书名称",
|
||||
component: {
|
||||
placeholder: "上传后将以此名称作为前缀备注",
|
||||
},
|
||||
helper: "上传后将以此名称作为前缀备注",
|
||||
},
|
||||
cert: {
|
||||
title: "域名证书",
|
||||
|
@ -44,6 +41,11 @@ import { CertInfo } from "../cert-plugin";
|
|||
},
|
||||
},
|
||||
output: {},
|
||||
default: {
|
||||
strategy: {
|
||||
runStrategy: RunStrategy.SkipWhenSucceed,
|
||||
},
|
||||
},
|
||||
};
|
||||
})
|
||||
export class DeployCertToAliyunCDN extends AbstractPlugin implements TaskPlugin {
|
||||
|
|
|
@ -2,7 +2,7 @@ import log4js, { LoggingEvent } from "log4js";
|
|||
|
||||
const OutputAppender = {
|
||||
configure: (config: any, layouts: any, findAppender: any, levels: any) => {
|
||||
let layout = layouts.colouredLayout;
|
||||
let layout = layouts.basicLayout;
|
||||
if (config.layout) {
|
||||
layout = layouts.layout(config.layout.type, config.layout);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ describe("pipeline", function () {
|
|||
}
|
||||
|
||||
const executor = new Executor({ userId: "test", pipeline, onChanged, accessService: new AccessServiceTest(), storage: new FileStorage() });
|
||||
await executor.run();
|
||||
await executor.run(1, "user");
|
||||
// expect(define.name).eq("EchoPlugin");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue