plugin-workflow-portainer 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/README.md +31 -3
- package/client-v2.js +1 -0
- package/client.js +1 -0
- package/dist/client/127.09e6675863ac8138.js +10 -0
- package/dist/client/57.67f04a547ead06b8.js +10 -0
- package/dist/client/660.546c702d1ddf7eff.js +10 -0
- package/dist/client/981.e38099c59bf992f0.js +10 -0
- package/dist/client/index.js +10 -0
- package/dist/client-v2/127.9f65dc2e3d0df10a.js +10 -0
- package/dist/client-v2/57.a60e16e4b4e4fa28.js +10 -0
- package/dist/client-v2/660.29ae3c3b4040039d.js +10 -0
- package/dist/client-v2/981.8627062881ad83d1.js +10 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/externalVersion.js +20 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +193 -0
- package/dist/locale/vi-VN.json +193 -0
- package/dist/locale/zh-CN.json +193 -0
- package/dist/node_modules/joi/dist/joi-browser.min.js +1 -0
- package/dist/node_modules/joi/lib/annotate.js +175 -0
- package/dist/node_modules/joi/lib/base.js +1069 -0
- package/dist/node_modules/joi/lib/cache.js +143 -0
- package/dist/node_modules/joi/lib/common.js +216 -0
- package/dist/node_modules/joi/lib/compile.js +283 -0
- package/dist/node_modules/joi/lib/errors.js +271 -0
- package/dist/node_modules/joi/lib/extend.js +312 -0
- package/dist/node_modules/joi/lib/index.d.ts +2365 -0
- package/dist/node_modules/joi/lib/index.js +1 -0
- package/dist/node_modules/joi/lib/manifest.js +476 -0
- package/dist/node_modules/joi/lib/messages.js +207 -0
- package/dist/node_modules/joi/lib/modify.js +267 -0
- package/dist/node_modules/joi/lib/ref.js +414 -0
- package/dist/node_modules/joi/lib/schemas.js +302 -0
- package/dist/node_modules/joi/lib/state.js +166 -0
- package/dist/node_modules/joi/lib/template.js +463 -0
- package/dist/node_modules/joi/lib/trace.js +346 -0
- package/dist/node_modules/joi/lib/types/alternatives.js +364 -0
- package/dist/node_modules/joi/lib/types/any.js +174 -0
- package/dist/node_modules/joi/lib/types/array.js +809 -0
- package/dist/node_modules/joi/lib/types/binary.js +100 -0
- package/dist/node_modules/joi/lib/types/boolean.js +150 -0
- package/dist/node_modules/joi/lib/types/date.js +233 -0
- package/dist/node_modules/joi/lib/types/function.js +93 -0
- package/dist/node_modules/joi/lib/types/keys.js +1084 -0
- package/dist/node_modules/joi/lib/types/link.js +184 -0
- package/dist/node_modules/joi/lib/types/number.js +363 -0
- package/dist/node_modules/joi/lib/types/object.js +22 -0
- package/dist/node_modules/joi/lib/types/string.js +850 -0
- package/dist/node_modules/joi/lib/types/symbol.js +102 -0
- package/dist/node_modules/joi/lib/validator.js +750 -0
- package/dist/node_modules/joi/lib/values.js +263 -0
- package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.d.ts +60 -0
- package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.js +225 -0
- package/dist/node_modules/joi/node_modules/@hapi/topo/package.json +30 -0
- package/dist/node_modules/joi/package.json +1 -0
- package/dist/server/actions/portainer.js +317 -0
- package/dist/server/collections/portainer-instances.js +54 -0
- package/dist/server/index.js +54 -0
- package/dist/server/instructions/PortainerStackControlInstruction.js +156 -0
- package/dist/server/instructions/PortainerStackRedeployInstruction.js +254 -0
- package/dist/server/instructions/helpers.js +211 -0
- package/dist/server/plugin.js +177 -0
- package/dist/server/services/PortainerClient.js +669 -0
- package/dist/shared/collection.js +57 -0
- package/dist/shared/constants.js +66 -0
- package/dist/shared/env.js +238 -0
- package/dist/shared/types.js +24 -0
- package/package.json +50 -4
- package/server.js +1 -0
- package/src/client/index.tsx +50 -0
- package/src/client/instructions.tsx +76 -0
- package/src/client-v2/__tests__/workflow-registration.test.tsx +242 -0
- package/src/client-v2/components/ControlFieldset.tsx +46 -0
- package/src/client-v2/components/PortainerEnvEditor.tsx +223 -0
- package/src/client-v2/components/PortainerSettingsPage.tsx +707 -0
- package/src/client-v2/components/PortainerTargetFields.tsx +309 -0
- package/src/client-v2/components/RedeployFieldset.tsx +124 -0
- package/src/client-v2/components/StackDetailDrawer.tsx +790 -0
- package/src/client-v2/index.tsx +50 -0
- package/src/client-v2/instructions.tsx +162 -0
- package/src/client-v2/locale.ts +24 -0
- package/src/index.ts +11 -0
- package/src/locale/en-US.json +193 -0
- package/src/locale/vi-VN.json +193 -0
- package/src/locale/zh-CN.json +193 -0
- package/src/server/__tests__/portainer-workflow.test.ts +559 -0
- package/src/server/actions/portainer.ts +361 -0
- package/src/server/collections/portainer-instances.ts +34 -0
- package/src/server/index.ts +13 -0
- package/src/server/instructions/PortainerStackControlInstruction.ts +139 -0
- package/src/server/instructions/PortainerStackRedeployInstruction.ts +255 -0
- package/src/server/instructions/helpers.ts +237 -0
- package/src/server/plugin.ts +174 -0
- package/src/server/services/PortainerClient.ts +846 -0
- package/src/shared/collection.ts +32 -0
- package/src/shared/constants.ts +25 -0
- package/src/shared/env.ts +243 -0
- package/src/shared/types.ts +164 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var collection_exports = {};
|
|
28
|
+
__export(collection_exports, {
|
|
29
|
+
portainerInstancesCollection: () => portainerInstancesCollection
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(collection_exports);
|
|
32
|
+
var import_constants = require("./constants");
|
|
33
|
+
const portainerInstancesCollection = {
|
|
34
|
+
name: import_constants.PORTAINER_INSTANCES_COLLECTION,
|
|
35
|
+
title: "Portainer Instances",
|
|
36
|
+
hidden: true,
|
|
37
|
+
fields: [
|
|
38
|
+
{ name: "id", type: "bigInt", autoIncrement: true, primaryKey: true },
|
|
39
|
+
{ name: "name", type: "string" },
|
|
40
|
+
{ name: "baseUrl", type: "string" },
|
|
41
|
+
{ name: "apiKey", type: "text" },
|
|
42
|
+
{ name: "gitUsername", type: "string" },
|
|
43
|
+
{ name: "gitAccessToken", type: "text" },
|
|
44
|
+
{ name: "gitCredentialId", type: "integer" },
|
|
45
|
+
{ name: "allowInsecureTls", type: "boolean", defaultValue: false },
|
|
46
|
+
{ name: "defaultTimeoutMs", type: "integer", defaultValue: import_constants.DEFAULT_TIMEOUT_MS },
|
|
47
|
+
{ name: "isDefault", type: "boolean", defaultValue: false },
|
|
48
|
+
{ name: "enabled", type: "boolean", defaultValue: true },
|
|
49
|
+
{ name: "lastHealthStatus", type: "string" },
|
|
50
|
+
{ name: "lastVersion", type: "string" },
|
|
51
|
+
{ name: "lastCheckedAt", type: "date" }
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
portainerInstancesCollection
|
|
57
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var constants_exports = {};
|
|
28
|
+
__export(constants_exports, {
|
|
29
|
+
DEFAULT_TIMEOUT_MS: () => DEFAULT_TIMEOUT_MS,
|
|
30
|
+
INSTRUCTION_GROUP_KEY: () => INSTRUCTION_GROUP_KEY,
|
|
31
|
+
INSTRUCTION_TYPES: () => INSTRUCTION_TYPES,
|
|
32
|
+
MAX_TIMEOUT_MS: () => MAX_TIMEOUT_MS,
|
|
33
|
+
MIN_TIMEOUT_MS: () => MIN_TIMEOUT_MS,
|
|
34
|
+
PLUGIN_NAMESPACE: () => PLUGIN_NAMESPACE,
|
|
35
|
+
PORTAINER_ACL_SNIPPET: () => PORTAINER_ACL_SNIPPET,
|
|
36
|
+
PORTAINER_INSTANCES_COLLECTION: () => PORTAINER_INSTANCES_COLLECTION,
|
|
37
|
+
PORTAINER_RESOURCE: () => PORTAINER_RESOURCE,
|
|
38
|
+
SECRET_MASK: () => SECRET_MASK
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(constants_exports);
|
|
41
|
+
const PLUGIN_NAMESPACE = "plugin-workflow-portainer";
|
|
42
|
+
const PORTAINER_INSTANCES_COLLECTION = "portainerInstances";
|
|
43
|
+
const PORTAINER_RESOURCE = "portainerWorkflow";
|
|
44
|
+
const PORTAINER_ACL_SNIPPET = "pm.plugin-workflow-portainer";
|
|
45
|
+
const INSTRUCTION_GROUP_KEY = "portainer";
|
|
46
|
+
const INSTRUCTION_TYPES = {
|
|
47
|
+
redeploy: "portainer-stack-redeploy",
|
|
48
|
+
control: "portainer-stack-control"
|
|
49
|
+
};
|
|
50
|
+
const SECRET_MASK = "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
|
|
51
|
+
const DEFAULT_TIMEOUT_MS = 6e5;
|
|
52
|
+
const MIN_TIMEOUT_MS = 1e3;
|
|
53
|
+
const MAX_TIMEOUT_MS = 36e5;
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
DEFAULT_TIMEOUT_MS,
|
|
57
|
+
INSTRUCTION_GROUP_KEY,
|
|
58
|
+
INSTRUCTION_TYPES,
|
|
59
|
+
MAX_TIMEOUT_MS,
|
|
60
|
+
MIN_TIMEOUT_MS,
|
|
61
|
+
PLUGIN_NAMESPACE,
|
|
62
|
+
PORTAINER_ACL_SNIPPET,
|
|
63
|
+
PORTAINER_INSTANCES_COLLECTION,
|
|
64
|
+
PORTAINER_RESOURCE,
|
|
65
|
+
SECRET_MASK
|
|
66
|
+
});
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var env_exports = {};
|
|
28
|
+
__export(env_exports, {
|
|
29
|
+
buildEffectiveStackEnv: () => buildEffectiveStackEnv,
|
|
30
|
+
isLikelySensitiveKey: () => isLikelySensitiveKey,
|
|
31
|
+
isValidEnvKey: () => isValidEnvKey,
|
|
32
|
+
isWorkflowVariableValue: () => isWorkflowVariableValue,
|
|
33
|
+
normalizeGitReference: () => normalizeGitReference,
|
|
34
|
+
parseDotEnvText: () => parseDotEnvText,
|
|
35
|
+
parseDynamicEnvInput: () => parseDynamicEnvInput,
|
|
36
|
+
stringifyEnvValue: () => stringifyEnvValue,
|
|
37
|
+
toFiniteNumber: () => toFiniteNumber
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(env_exports);
|
|
40
|
+
var import_constants = require("./constants");
|
|
41
|
+
const ENV_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
42
|
+
const SENSITIVE_ENV_KEY_PATTERN = /(password|passwd|secret|token|api[_-]?key|private[_-]?key|access[_-]?key)/i;
|
|
43
|
+
function isValidEnvKey(key) {
|
|
44
|
+
return ENV_KEY_PATTERN.test(key.trim());
|
|
45
|
+
}
|
|
46
|
+
function isLikelySensitiveKey(key) {
|
|
47
|
+
return SENSITIVE_ENV_KEY_PATTERN.test(key);
|
|
48
|
+
}
|
|
49
|
+
function isWorkflowVariableValue(value) {
|
|
50
|
+
return typeof value === "string" && /^\{\{\s*[\s\S]+?\s*\}\}$/.test(value.trim());
|
|
51
|
+
}
|
|
52
|
+
function toFiniteNumber(value) {
|
|
53
|
+
if (typeof value === "number") {
|
|
54
|
+
return Number.isFinite(value) ? value : void 0;
|
|
55
|
+
}
|
|
56
|
+
if (typeof value === "string" && value.trim() !== "" && !isWorkflowVariableValue(value)) {
|
|
57
|
+
const parsed = Number(value);
|
|
58
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
59
|
+
}
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
function stripMatchingQuotes(raw) {
|
|
63
|
+
if (raw.length >= 2) {
|
|
64
|
+
const first = raw[0];
|
|
65
|
+
const last = raw[raw.length - 1];
|
|
66
|
+
if (first === '"' && last === '"' || first === "'" && last === "'") {
|
|
67
|
+
return raw.slice(1, -1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return raw;
|
|
71
|
+
}
|
|
72
|
+
function stringifyEnvValue(value) {
|
|
73
|
+
if (value === null || typeof value === "undefined") {
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
if (typeof value === "string") {
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
80
|
+
return String(value);
|
|
81
|
+
}
|
|
82
|
+
return JSON.stringify(value);
|
|
83
|
+
}
|
|
84
|
+
function parseDotEnvText(text) {
|
|
85
|
+
if (!text || typeof text !== "string") {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
const result = [];
|
|
89
|
+
const lines = text.split(/\r?\n/);
|
|
90
|
+
for (const rawLine of lines) {
|
|
91
|
+
const trimmed = rawLine.trim();
|
|
92
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const normalized = trimmed.startsWith("export ") ? trimmed.slice(7).trim() : trimmed;
|
|
96
|
+
const eqIndex = normalized.indexOf("=");
|
|
97
|
+
if (eqIndex <= 0) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const name = normalized.slice(0, eqIndex).trim();
|
|
101
|
+
if (!isValidEnvKey(name)) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const rawVal = normalized.slice(eqIndex + 1).trim();
|
|
105
|
+
result.push({
|
|
106
|
+
name,
|
|
107
|
+
value: stripMatchingQuotes(rawVal)
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
function isPlainRecord(value) {
|
|
113
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
114
|
+
}
|
|
115
|
+
function parseDynamicEnvInput(input) {
|
|
116
|
+
if (input === null || typeof input === "undefined" || input === "") {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
let resolved = input;
|
|
120
|
+
if (typeof input === "string") {
|
|
121
|
+
const trimmed = input.trim();
|
|
122
|
+
if (!trimmed) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
126
|
+
try {
|
|
127
|
+
resolved = JSON.parse(trimmed);
|
|
128
|
+
} catch {
|
|
129
|
+
throw new Error("Dynamic environment JSON is invalid");
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
return parseDotEnvText(trimmed);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (Array.isArray(resolved)) {
|
|
136
|
+
const pairs = [];
|
|
137
|
+
for (const item of resolved) {
|
|
138
|
+
if (!isPlainRecord(item)) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const rawName = typeof item.name === "string" ? item.name : typeof item.key === "string" ? item.key : "";
|
|
142
|
+
const name = rawName.trim();
|
|
143
|
+
if (!name || !isValidEnvKey(name)) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
pairs.push({
|
|
147
|
+
name,
|
|
148
|
+
value: stringifyEnvValue(item.value)
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return pairs;
|
|
152
|
+
}
|
|
153
|
+
if (isPlainRecord(resolved)) {
|
|
154
|
+
const pairs = [];
|
|
155
|
+
for (const [rawKey, val] of Object.entries(resolved)) {
|
|
156
|
+
const name = rawKey.trim();
|
|
157
|
+
if (!name || !isValidEnvKey(name)) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
pairs.push({
|
|
161
|
+
name,
|
|
162
|
+
value: stringifyEnvValue(val)
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return pairs;
|
|
166
|
+
}
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
function buildEffectiveStackEnv(options) {
|
|
170
|
+
const map = /* @__PURE__ */ new Map();
|
|
171
|
+
const explicitSecrets = /* @__PURE__ */ new Set();
|
|
172
|
+
if ((options.strategy ?? "merge") === "merge" && Array.isArray(options.existingEnv)) {
|
|
173
|
+
for (const item of options.existingEnv) {
|
|
174
|
+
const name = String((item == null ? void 0 : item.name) ?? "").trim();
|
|
175
|
+
if (name) {
|
|
176
|
+
map.set(name, stringifyEnvValue(item.value));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
for (const item of parseDynamicEnvInput(options.dynamicEnv)) {
|
|
181
|
+
map.set(item.name, item.value);
|
|
182
|
+
}
|
|
183
|
+
for (const item of parseDotEnvText(options.envText)) {
|
|
184
|
+
map.set(item.name, item.value);
|
|
185
|
+
}
|
|
186
|
+
if (Array.isArray(options.envPairs)) {
|
|
187
|
+
for (const item of options.envPairs) {
|
|
188
|
+
const name = String((item == null ? void 0 : item.name) ?? "").trim();
|
|
189
|
+
if (!name) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (!isValidEnvKey(name)) {
|
|
193
|
+
throw new Error(`Invalid environment variable name "${name}"`);
|
|
194
|
+
}
|
|
195
|
+
map.set(name, stringifyEnvValue(item.value));
|
|
196
|
+
if (item.secret) {
|
|
197
|
+
explicitSecrets.add(name);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const env = [];
|
|
202
|
+
const maskedEnv = {};
|
|
203
|
+
const secretKeys = [];
|
|
204
|
+
for (const [name, value] of map.entries()) {
|
|
205
|
+
env.push({ name, value });
|
|
206
|
+
const shouldMask = explicitSecrets.has(name) || isLikelySensitiveKey(name);
|
|
207
|
+
if (shouldMask) {
|
|
208
|
+
secretKeys.push(name);
|
|
209
|
+
maskedEnv[name] = import_constants.SECRET_MASK;
|
|
210
|
+
} else {
|
|
211
|
+
maskedEnv[name] = value;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { env, maskedEnv, secretKeys };
|
|
215
|
+
}
|
|
216
|
+
function normalizeGitReference(ref, fallback) {
|
|
217
|
+
const raw = String(ref ?? "").trim();
|
|
218
|
+
if (!raw) {
|
|
219
|
+
const fb = String(fallback ?? "").trim();
|
|
220
|
+
return fb || "refs/heads/main";
|
|
221
|
+
}
|
|
222
|
+
if (raw.startsWith("refs/")) {
|
|
223
|
+
return raw;
|
|
224
|
+
}
|
|
225
|
+
return `refs/heads/${raw}`;
|
|
226
|
+
}
|
|
227
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
228
|
+
0 && (module.exports = {
|
|
229
|
+
buildEffectiveStackEnv,
|
|
230
|
+
isLikelySensitiveKey,
|
|
231
|
+
isValidEnvKey,
|
|
232
|
+
isWorkflowVariableValue,
|
|
233
|
+
normalizeGitReference,
|
|
234
|
+
parseDotEnvText,
|
|
235
|
+
parseDynamicEnvInput,
|
|
236
|
+
stringifyEnvValue,
|
|
237
|
+
toFiniteNumber
|
|
238
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var types_exports = {};
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plugin-workflow-portainer",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"displayName": "Portainer Workflows",
|
|
4
|
+
"displayName.zh-CN": "Portainer 工作流",
|
|
5
|
+
"displayName.vi-VN": "Luồng công việc Portainer",
|
|
6
|
+
"description": "Workflow nodes and connection management for running, redeploying, and controlling Portainer stacks across environments.",
|
|
7
|
+
"description.zh-CN": "用于在多环境中运行、重新部署和控制 Portainer Stack 的工作流节点与连接管理插件。",
|
|
8
|
+
"description.vi-VN": "Cung cấp các node Workflow và quản lý kết nối để chạy, redeploy và kiểm soát Portainer Stack đa môi trường.",
|
|
9
|
+
"version": "0.2.0",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"main": "dist/server/index.js",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"NocoBase",
|
|
14
|
+
"Workflow",
|
|
15
|
+
"Portainer",
|
|
16
|
+
"Docker",
|
|
17
|
+
"CI/CD",
|
|
18
|
+
"GitOps"
|
|
19
|
+
],
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"src",
|
|
23
|
+
"client.js",
|
|
24
|
+
"client-v2.js",
|
|
25
|
+
"server.js"
|
|
26
|
+
],
|
|
27
|
+
"nocobase": {
|
|
28
|
+
"supportedVersions": [
|
|
29
|
+
"2.x"
|
|
30
|
+
],
|
|
31
|
+
"editionLevel": 0
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@nocobase/actions": "2.x",
|
|
35
|
+
"@nocobase/client": "2.x",
|
|
36
|
+
"@nocobase/client-v2": "2.x",
|
|
37
|
+
"@nocobase/database": "2.x",
|
|
38
|
+
"@nocobase/flow-engine": "2.x",
|
|
39
|
+
"@nocobase/server": "2.x",
|
|
40
|
+
"@nocobase/plugin-workflow": "2.x"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/OrgGem/nocobase-beta.git",
|
|
45
|
+
"directory": "packages/plugins/plugin-workflow-portainer"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "80fa4ca378070b31799b572a8cdc1d4fbbac00d5",
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public",
|
|
50
|
+
"registry": "https://registry.npmjs.org/"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Plugin } from '@nocobase/client';
|
|
11
|
+
import type { Instruction } from '@nocobase/plugin-workflow/client';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import type { WorkflowInstructionRegistryLike } from '../client-v2/instructions';
|
|
14
|
+
import { portainerInstancesCollection } from '../shared/collection';
|
|
15
|
+
import { PORTAINER_ACL_SNIPPET } from '../shared/constants';
|
|
16
|
+
import { registerInstructionsV1 } from './instructions';
|
|
17
|
+
|
|
18
|
+
const PortainerSettingsPage = React.lazy(() => import('../client-v2/components/PortainerSettingsPage'));
|
|
19
|
+
|
|
20
|
+
export class PluginWorkflowPortainerClient extends Plugin {
|
|
21
|
+
async load() {
|
|
22
|
+
const dataSource = this.app.dataSourceManager.getDataSource('main');
|
|
23
|
+
if (dataSource) {
|
|
24
|
+
const registerCollection = () => {
|
|
25
|
+
if (!dataSource.collectionManager.getCollection(portainerInstancesCollection.name)) {
|
|
26
|
+
dataSource.collectionManager.addCollections([portainerInstancesCollection]);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
registerCollection();
|
|
30
|
+
dataSource.addReloadCallback(registerCollection);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const workflow = (this.app.pm.get('workflow') || this.app.pm.get('@nocobase/plugin-workflow')) as
|
|
34
|
+
| WorkflowInstructionRegistryLike<Instruction>
|
|
35
|
+
| undefined;
|
|
36
|
+
|
|
37
|
+
if (workflow) {
|
|
38
|
+
registerInstructionsV1(workflow);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.app.pluginSettingsManager.add('workflow-portainer', {
|
|
42
|
+
title: this.t('Portainer Workflows'),
|
|
43
|
+
icon: 'CloudServerOutlined',
|
|
44
|
+
Component: PortainerSettingsPage,
|
|
45
|
+
aclSnippet: PORTAINER_ACL_SNIPPET,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default PluginWorkflowPortainerClient;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { CloudUploadOutlined, ClusterOutlined } from '@ant-design/icons';
|
|
11
|
+
import { Instruction } from '@nocobase/plugin-workflow/client';
|
|
12
|
+
import type { UseVariableOptions } from '@nocobase/plugin-workflow/client-v2';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import {
|
|
15
|
+
buildControlVariableOption,
|
|
16
|
+
buildRedeployVariableOption,
|
|
17
|
+
defaultControlConfig,
|
|
18
|
+
defaultRedeployConfig,
|
|
19
|
+
type WorkflowInstructionRegistryLike,
|
|
20
|
+
} from '../client-v2/instructions';
|
|
21
|
+
import { tExpr } from '../client-v2/locale';
|
|
22
|
+
import { INSTRUCTION_GROUP_KEY, INSTRUCTION_TYPES } from '../shared/constants';
|
|
23
|
+
|
|
24
|
+
type NodeLike = {
|
|
25
|
+
key: string;
|
|
26
|
+
title: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export class PortainerStackRedeployInstructionV1 extends Instruction {
|
|
30
|
+
type = INSTRUCTION_TYPES.redeploy;
|
|
31
|
+
title = tExpr('Run / Redeploy Stack');
|
|
32
|
+
description = tExpr(
|
|
33
|
+
'Pull Git changes, build compose services, or redeploy a Portainer Stack with full environment variable control.',
|
|
34
|
+
);
|
|
35
|
+
group = INSTRUCTION_GROUP_KEY;
|
|
36
|
+
icon = (<CloudUploadOutlined />);
|
|
37
|
+
testable = true;
|
|
38
|
+
FieldsetLoader = () =>
|
|
39
|
+
import('../client-v2/components/RedeployFieldset').then((module) => ({ default: module.RedeployFieldset }));
|
|
40
|
+
|
|
41
|
+
createDefaultConfig() {
|
|
42
|
+
return defaultRedeployConfig();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
useVariables(node: NodeLike, options?: UseVariableOptions) {
|
|
46
|
+
return buildRedeployVariableOption(node, options);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class PortainerStackControlInstructionV1 extends Instruction {
|
|
51
|
+
type = INSTRUCTION_TYPES.control;
|
|
52
|
+
title = tExpr('Control / Inspect Stack');
|
|
53
|
+
description = tExpr('Inspect Stack container health, start, or stop a Portainer Stack in an environment.');
|
|
54
|
+
group = INSTRUCTION_GROUP_KEY;
|
|
55
|
+
icon = (<ClusterOutlined />);
|
|
56
|
+
testable = true;
|
|
57
|
+
FieldsetLoader = () =>
|
|
58
|
+
import('../client-v2/components/ControlFieldset').then((module) => ({ default: module.ControlFieldset }));
|
|
59
|
+
|
|
60
|
+
createDefaultConfig() {
|
|
61
|
+
return defaultControlConfig();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
useVariables(node: NodeLike, options?: UseVariableOptions) {
|
|
65
|
+
return buildControlVariableOption(node, options);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function registerInstructionsV1(workflow: WorkflowInstructionRegistryLike<Instruction>) {
|
|
70
|
+
workflow.registerInstructionGroup?.(INSTRUCTION_GROUP_KEY, {
|
|
71
|
+
key: INSTRUCTION_GROUP_KEY,
|
|
72
|
+
label: tExpr('Portainer'),
|
|
73
|
+
});
|
|
74
|
+
workflow.registerInstruction?.(INSTRUCTION_TYPES.redeploy, PortainerStackRedeployInstructionV1);
|
|
75
|
+
workflow.registerInstruction?.(INSTRUCTION_TYPES.control, PortainerStackControlInstructionV1);
|
|
76
|
+
}
|