feat: plugin-huawei

This commit is contained in:
xiaojunnuo
2023-05-09 09:19:17 +08:00
parent d602df4c70
commit 003ea9310b
36 changed files with 1640 additions and 61 deletions
@@ -0,0 +1,10 @@
import { IAccessService } from "../../src/access/access-service";
import { AbstractAccess, HuaweiAccess } from "../../src";
import { aliyunSecret } from "../user.secret";
export class AccessServiceTest implements IAccessService {
async getById(id: any): Promise<AbstractAccess> {
return {
...aliyunSecret,
} as HuaweiAccess;
}
}
@@ -0,0 +1,15 @@
import { ContextFactory } from "../../src/core/context";
import { FileStorage } from "../../src/core/storage";
import { AccessServiceTest } from "./access-service-test";
import { logger } from "../../src/utils/util.log";
const contextFactory = new ContextFactory(new FileStorage());
const userContext = contextFactory.getContext("user", "test");
const pipelineContext = contextFactory.getContext("pipeline", "test");
export const pluginInitProps = {
accessService: new AccessServiceTest(),
pipelineContext: pipelineContext,
userContext: userContext,
logger: logger,
};
@@ -0,0 +1,66 @@
import { ConcurrencyStrategy, NextStrategy, Pipeline, RunStrategy } from "../../src";
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: ["*.docmirror.cn"],
email: "xiaojunnuo@qq.com",
dnsProviderType: "aliyun",
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,18 @@
//import { expect } from "chai";
import "mocha";
import { Executor, RunHistory } from "../../src";
import { pipeline } from "./pipeline.define";
import { AccessServiceTest } from "./access-service-test";
import { FileStorage } from "../../src/core/storage";
describe("pipeline", 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");
});
});