mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
refactor: register
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { IAccessService } from "@certd/pipeline";
|
||||
import { hauweiSecret } from "../user.secret";
|
||||
import { HuaweiAccess } from "@certd/plugin-huawei";
|
||||
export class AccessServiceTest implements IAccessService {
|
||||
async getById(id: any): Promise<any> {
|
||||
return {
|
||||
...hauweiSecret,
|
||||
} as HuaweiAccess;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import { ConcurrencyStrategy, NextStrategy, Pipeline, RunStrategy } from "@certd/pipeline";
|
||||
|
||||
let idIndex = 0;
|
||||
function generateId() {
|
||||
idIndex++;
|
||||
return idIndex + "";
|
||||
}
|
||||
export const pipeline: Pipeline = {
|
||||
version: 1,
|
||||
id: generateId(),
|
||||
title: "华为管道测试",
|
||||
userId: 1,
|
||||
triggers: [],
|
||||
stages: [
|
||||
{
|
||||
id: generateId(),
|
||||
title: "证书申请阶段",
|
||||
concurrency: ConcurrencyStrategy.Serial,
|
||||
next: NextStrategy.AllSuccess,
|
||||
tasks: [
|
||||
{
|
||||
id: generateId(),
|
||||
title: "申请证书任务",
|
||||
steps: [
|
||||
{
|
||||
id: generateId(),
|
||||
title: "申请证书",
|
||||
type: "CertApply",
|
||||
input: {
|
||||
domains: ["*.powerleader.chat"],
|
||||
email: "xiaojunnuo@qq.com",
|
||||
dnsProviderType: "huawei",
|
||||
accessId: "111",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: generateId(),
|
||||
title: "证书部署阶段",
|
||||
concurrency: ConcurrencyStrategy.Serial,
|
||||
next: NextStrategy.AllSuccess,
|
||||
tasks: [
|
||||
{
|
||||
id: generateId(),
|
||||
title: "测试输出参数任务",
|
||||
steps: [
|
||||
{
|
||||
id: generateId(),
|
||||
title: "输出参数(echo插件)",
|
||||
type: "EchoPlugin",
|
||||
input: {
|
||||
cert: "cert",
|
||||
},
|
||||
strategy: {
|
||||
runStrategy: RunStrategy.SkipWhenSucceed,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
//import { expect } from "chai";
|
||||
import "mocha";
|
||||
import { Executor, RunHistory, FileStorage } from "@certd/pipeline";
|
||||
import { pipeline } from "./pipeline.huawei";
|
||||
import { AccessServiceTest } from "./access-service-test";
|
||||
import "../../src";
|
||||
import "../plugin/echo-plugin";
|
||||
describe("pipeline-hauwei-test", function () {
|
||||
it("#pipeline", async function () {
|
||||
this.timeout(120000);
|
||||
function onChanged(history: RunHistory) {
|
||||
console.log("changed:");
|
||||
}
|
||||
|
||||
const executor = new Executor({ userId: "test", pipeline, onChanged, accessService: new AccessServiceTest(), storage: new FileStorage() });
|
||||
await executor.run(1, "user");
|
||||
// expect(define.name).eq("EchoPlugin");
|
||||
});
|
||||
});
|
||||
@@ -4,6 +4,7 @@ import { Executor, RunHistory, FileStorage } from "@certd/pipeline";
|
||||
import { pipeline } from "./pipeline.define";
|
||||
import { AccessServiceTest } from "./access-service-test";
|
||||
import "../../src";
|
||||
import "../plugin/echo-plugin";
|
||||
describe("pipeline", function () {
|
||||
it("#pipeline", async function () {
|
||||
this.timeout(120000);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Autowire, IsTaskPlugin, TaskInput, ITaskPlugin } from "@certd/pipeline";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: "EchoPlugin",
|
||||
title: "测试插件",
|
||||
desc: "test",
|
||||
})
|
||||
export class EchoPlugin implements ITaskPlugin {
|
||||
@TaskInput({
|
||||
title: "测试属性",
|
||||
component: {
|
||||
name: "text",
|
||||
},
|
||||
})
|
||||
test?: string;
|
||||
|
||||
async execute(): Promise<void> {
|
||||
console.log("output", this.test);
|
||||
}
|
||||
|
||||
onInstance(): Promise<void> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
new EchoPlugin();
|
||||
Reference in New Issue
Block a user