@kwirthmagnify/kwirth-plugin-ops 0.1.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/back.js +1457 -0
- package/front.js +19174 -0
- package/package.json +8 -0
package/back.js
ADDED
|
@@ -0,0 +1,1457 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
|
|
32
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/Channel.js
|
|
33
|
+
var require_Channel = __commonJS({
|
|
34
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/Channel.js"(exports2) {
|
|
35
|
+
"use strict";
|
|
36
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37
|
+
exports2.EClusterType = exports2.ClusterTypeEnum = void 0;
|
|
38
|
+
var ClusterTypeEnum;
|
|
39
|
+
(function(ClusterTypeEnum2) {
|
|
40
|
+
ClusterTypeEnum2["KUBERNETES"] = "kubernetes";
|
|
41
|
+
ClusterTypeEnum2["DOCKER"] = "docker";
|
|
42
|
+
})(ClusterTypeEnum || (exports2.ClusterTypeEnum = ClusterTypeEnum = {}));
|
|
43
|
+
var EClusterType2;
|
|
44
|
+
(function(EClusterType3) {
|
|
45
|
+
EClusterType3["KUBERNETES"] = "kubernetes";
|
|
46
|
+
EClusterType3["DOCKER"] = "docker";
|
|
47
|
+
})(EClusterType2 || (exports2.EClusterType = EClusterType2 = {}));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/Sender.js
|
|
52
|
+
var require_Sender = __commonJS({
|
|
53
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/Sender.js"(exports2) {
|
|
54
|
+
"use strict";
|
|
55
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/InstanceMessage.js
|
|
60
|
+
var require_InstanceMessage = __commonJS({
|
|
61
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/InstanceMessage.js"(exports2) {
|
|
62
|
+
"use strict";
|
|
63
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
64
|
+
exports2.EInstanceMessageFlow = exports2.InstanceMessageFlowEnum = exports2.EInstanceMessageAction = exports2.InstanceMessageActionEnum = exports2.EInstanceMessageType = exports2.InstanceMessageTypeEnum = exports2.EInstanceMessageChannel = exports2.InstanceMessageChannelEnum = void 0;
|
|
65
|
+
var InstanceMessageChannelEnum2;
|
|
66
|
+
(function(InstanceMessageChannelEnum3) {
|
|
67
|
+
InstanceMessageChannelEnum3["NONE"] = "none";
|
|
68
|
+
InstanceMessageChannelEnum3["LOG"] = "log";
|
|
69
|
+
InstanceMessageChannelEnum3["METRICS"] = "metrics";
|
|
70
|
+
InstanceMessageChannelEnum3["AUDIT"] = "audit";
|
|
71
|
+
InstanceMessageChannelEnum3["OPS"] = "ops";
|
|
72
|
+
InstanceMessageChannelEnum3["ALERT"] = "alert";
|
|
73
|
+
InstanceMessageChannelEnum3["TRIVY"] = "trivy";
|
|
74
|
+
})(InstanceMessageChannelEnum2 || (exports2.InstanceMessageChannelEnum = InstanceMessageChannelEnum2 = {}));
|
|
75
|
+
var EInstanceMessageChannel;
|
|
76
|
+
(function(EInstanceMessageChannel2) {
|
|
77
|
+
EInstanceMessageChannel2["NONE"] = "none";
|
|
78
|
+
EInstanceMessageChannel2["LOG"] = "log";
|
|
79
|
+
EInstanceMessageChannel2["METRICS"] = "metrics";
|
|
80
|
+
EInstanceMessageChannel2["AUDIT"] = "audit";
|
|
81
|
+
EInstanceMessageChannel2["OPS"] = "ops";
|
|
82
|
+
EInstanceMessageChannel2["ALERT"] = "alert";
|
|
83
|
+
EInstanceMessageChannel2["TRIVY"] = "trivy";
|
|
84
|
+
EInstanceMessageChannel2["MAGNIFY"] = "magnify";
|
|
85
|
+
})(EInstanceMessageChannel || (exports2.EInstanceMessageChannel = EInstanceMessageChannel = {}));
|
|
86
|
+
var InstanceMessageTypeEnum;
|
|
87
|
+
(function(InstanceMessageTypeEnum2) {
|
|
88
|
+
InstanceMessageTypeEnum2["DATA"] = "data";
|
|
89
|
+
InstanceMessageTypeEnum2["SIGNAL"] = "signal";
|
|
90
|
+
})(InstanceMessageTypeEnum || (exports2.InstanceMessageTypeEnum = InstanceMessageTypeEnum = {}));
|
|
91
|
+
var EInstanceMessageType4;
|
|
92
|
+
(function(EInstanceMessageType5) {
|
|
93
|
+
EInstanceMessageType5["DATA"] = "data";
|
|
94
|
+
EInstanceMessageType5["SIGNAL"] = "signal";
|
|
95
|
+
})(EInstanceMessageType4 || (exports2.EInstanceMessageType = EInstanceMessageType4 = {}));
|
|
96
|
+
var InstanceMessageActionEnum;
|
|
97
|
+
(function(InstanceMessageActionEnum2) {
|
|
98
|
+
InstanceMessageActionEnum2["NONE"] = "none";
|
|
99
|
+
InstanceMessageActionEnum2["ROUTE"] = "route";
|
|
100
|
+
InstanceMessageActionEnum2["START"] = "start";
|
|
101
|
+
InstanceMessageActionEnum2["STOP"] = "stop";
|
|
102
|
+
InstanceMessageActionEnum2["PAUSE"] = "pause";
|
|
103
|
+
InstanceMessageActionEnum2["CONTINUE"] = "continue";
|
|
104
|
+
InstanceMessageActionEnum2["MODIFY"] = "modify";
|
|
105
|
+
InstanceMessageActionEnum2["PING"] = "ping";
|
|
106
|
+
InstanceMessageActionEnum2["RECONNECT"] = "reconnect";
|
|
107
|
+
InstanceMessageActionEnum2["COMMAND"] = "command";
|
|
108
|
+
InstanceMessageActionEnum2["WEBSOCKET"] = "websocket";
|
|
109
|
+
})(InstanceMessageActionEnum || (exports2.InstanceMessageActionEnum = InstanceMessageActionEnum = {}));
|
|
110
|
+
var EInstanceMessageAction2;
|
|
111
|
+
(function(EInstanceMessageAction3) {
|
|
112
|
+
EInstanceMessageAction3["NONE"] = "none";
|
|
113
|
+
EInstanceMessageAction3["RI"] = "ri";
|
|
114
|
+
EInstanceMessageAction3["ROUTE"] = "route";
|
|
115
|
+
EInstanceMessageAction3["START"] = "start";
|
|
116
|
+
EInstanceMessageAction3["STOP"] = "stop";
|
|
117
|
+
EInstanceMessageAction3["PAUSE"] = "pause";
|
|
118
|
+
EInstanceMessageAction3["CONTINUE"] = "continue";
|
|
119
|
+
EInstanceMessageAction3["MODIFY"] = "modify";
|
|
120
|
+
EInstanceMessageAction3["PING"] = "ping";
|
|
121
|
+
EInstanceMessageAction3["RECONNECT"] = "reconnect";
|
|
122
|
+
EInstanceMessageAction3["COMMAND"] = "command";
|
|
123
|
+
EInstanceMessageAction3["WEBSOCKET"] = "websocket";
|
|
124
|
+
})(EInstanceMessageAction2 || (exports2.EInstanceMessageAction = EInstanceMessageAction2 = {}));
|
|
125
|
+
var InstanceMessageFlowEnum;
|
|
126
|
+
(function(InstanceMessageFlowEnum2) {
|
|
127
|
+
InstanceMessageFlowEnum2["IMMEDIATE"] = "immediate";
|
|
128
|
+
InstanceMessageFlowEnum2["REQUEST"] = "request";
|
|
129
|
+
InstanceMessageFlowEnum2["RESPONSE"] = "response";
|
|
130
|
+
InstanceMessageFlowEnum2["UNSOLICITED"] = "unsolicited";
|
|
131
|
+
})(InstanceMessageFlowEnum || (exports2.InstanceMessageFlowEnum = InstanceMessageFlowEnum = {}));
|
|
132
|
+
var EInstanceMessageFlow4;
|
|
133
|
+
(function(EInstanceMessageFlow5) {
|
|
134
|
+
EInstanceMessageFlow5["IMMEDIATE"] = "immediate";
|
|
135
|
+
EInstanceMessageFlow5["REQUEST"] = "request";
|
|
136
|
+
EInstanceMessageFlow5["RESPONSE"] = "response";
|
|
137
|
+
EInstanceMessageFlow5["UNSOLICITED"] = "unsolicited";
|
|
138
|
+
})(EInstanceMessageFlow4 || (exports2.EInstanceMessageFlow = EInstanceMessageFlow4 = {}));
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/InstanceConfig.js
|
|
143
|
+
var require_InstanceConfig = __commonJS({
|
|
144
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/InstanceConfig.js"(exports2) {
|
|
145
|
+
"use strict";
|
|
146
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
147
|
+
exports2.EInstanceConfigScope = exports2.EInstanceConfigView = exports2.EInstanceConfigObject = exports2.InstanceConfigScopeEnum = exports2.InstanceConfigViewEnum = exports2.InstanceConfigObjectEnum = void 0;
|
|
148
|
+
var InstanceConfigObjectEnum;
|
|
149
|
+
(function(InstanceConfigObjectEnum2) {
|
|
150
|
+
InstanceConfigObjectEnum2["PODS"] = "pods";
|
|
151
|
+
InstanceConfigObjectEnum2["EVENTS"] = "events";
|
|
152
|
+
})(InstanceConfigObjectEnum || (exports2.InstanceConfigObjectEnum = InstanceConfigObjectEnum = {}));
|
|
153
|
+
var InstanceConfigViewEnum;
|
|
154
|
+
(function(InstanceConfigViewEnum2) {
|
|
155
|
+
InstanceConfigViewEnum2["NONE"] = "none";
|
|
156
|
+
InstanceConfigViewEnum2["CLUSTER"] = "cluster";
|
|
157
|
+
InstanceConfigViewEnum2["NAMESPACE"] = "namespace";
|
|
158
|
+
InstanceConfigViewEnum2["GROUP"] = "group";
|
|
159
|
+
InstanceConfigViewEnum2["POD"] = "pod";
|
|
160
|
+
InstanceConfigViewEnum2["CONTAINER"] = "container";
|
|
161
|
+
})(InstanceConfigViewEnum || (exports2.InstanceConfigViewEnum = InstanceConfigViewEnum = {}));
|
|
162
|
+
var InstanceConfigScopeEnum;
|
|
163
|
+
(function(InstanceConfigScopeEnum2) {
|
|
164
|
+
InstanceConfigScopeEnum2["NONE"] = "none";
|
|
165
|
+
InstanceConfigScopeEnum2["API"] = "api";
|
|
166
|
+
InstanceConfigScopeEnum2["CLUSTER"] = "cluster";
|
|
167
|
+
InstanceConfigScopeEnum2["FILTER"] = "filter";
|
|
168
|
+
InstanceConfigScopeEnum2["VIEW"] = "view";
|
|
169
|
+
InstanceConfigScopeEnum2["SNAPSHOT"] = "snapshot";
|
|
170
|
+
InstanceConfigScopeEnum2["STREAM"] = "stream";
|
|
171
|
+
InstanceConfigScopeEnum2["CREATE"] = "create";
|
|
172
|
+
InstanceConfigScopeEnum2["SUBSCRIBE"] = "subscribe";
|
|
173
|
+
InstanceConfigScopeEnum2["GET"] = "get";
|
|
174
|
+
InstanceConfigScopeEnum2["EXECUTE"] = "execute";
|
|
175
|
+
InstanceConfigScopeEnum2["RESTART"] = "restart";
|
|
176
|
+
InstanceConfigScopeEnum2["WORKLOAD"] = "workload";
|
|
177
|
+
InstanceConfigScopeEnum2["KUBERNETES"] = "kubernetes";
|
|
178
|
+
})(InstanceConfigScopeEnum || (exports2.InstanceConfigScopeEnum = InstanceConfigScopeEnum = {}));
|
|
179
|
+
var EInstanceConfigObject;
|
|
180
|
+
(function(EInstanceConfigObject2) {
|
|
181
|
+
EInstanceConfigObject2["PODS"] = "pods";
|
|
182
|
+
EInstanceConfigObject2["EVENTS"] = "events";
|
|
183
|
+
})(EInstanceConfigObject || (exports2.EInstanceConfigObject = EInstanceConfigObject = {}));
|
|
184
|
+
var EInstanceConfigView;
|
|
185
|
+
(function(EInstanceConfigView2) {
|
|
186
|
+
EInstanceConfigView2["NONE"] = "none";
|
|
187
|
+
EInstanceConfigView2["CLUSTER"] = "cluster";
|
|
188
|
+
EInstanceConfigView2["NAMESPACE"] = "namespace";
|
|
189
|
+
EInstanceConfigView2["GROUP"] = "group";
|
|
190
|
+
EInstanceConfigView2["POD"] = "pod";
|
|
191
|
+
EInstanceConfigView2["CONTAINER"] = "container";
|
|
192
|
+
})(EInstanceConfigView || (exports2.EInstanceConfigView = EInstanceConfigView = {}));
|
|
193
|
+
var EInstanceConfigScope;
|
|
194
|
+
(function(EInstanceConfigScope2) {
|
|
195
|
+
EInstanceConfigScope2["NONE"] = "none";
|
|
196
|
+
EInstanceConfigScope2["API"] = "api";
|
|
197
|
+
EInstanceConfigScope2["CLUSTER"] = "cluster";
|
|
198
|
+
EInstanceConfigScope2["FILTER"] = "filter";
|
|
199
|
+
EInstanceConfigScope2["VIEW"] = "view";
|
|
200
|
+
EInstanceConfigScope2["SNAPSHOT"] = "snapshot";
|
|
201
|
+
EInstanceConfigScope2["STREAM"] = "stream";
|
|
202
|
+
EInstanceConfigScope2["CREATE"] = "create";
|
|
203
|
+
EInstanceConfigScope2["SUBSCRIBE"] = "subscribe";
|
|
204
|
+
EInstanceConfigScope2["GET"] = "get";
|
|
205
|
+
EInstanceConfigScope2["EXECUTE"] = "execute";
|
|
206
|
+
EInstanceConfigScope2["RESTART"] = "restart";
|
|
207
|
+
EInstanceConfigScope2["WORKLOAD"] = "workload";
|
|
208
|
+
EInstanceConfigScope2["KUBERNETES"] = "kubernetes";
|
|
209
|
+
})(EInstanceConfigScope || (exports2.EInstanceConfigScope = EInstanceConfigScope = {}));
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/RouteMessage.js
|
|
214
|
+
var require_RouteMessage = __commonJS({
|
|
215
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/RouteMessage.js"(exports2) {
|
|
216
|
+
"use strict";
|
|
217
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/SignalMessage.js
|
|
222
|
+
var require_SignalMessage = __commonJS({
|
|
223
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/SignalMessage.js"(exports2) {
|
|
224
|
+
"use strict";
|
|
225
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
226
|
+
exports2.ESignalMessageEvent = exports2.ESignalMessageLevel = exports2.SignalMessageEventEnum = exports2.SignalMessageLevelEnum = void 0;
|
|
227
|
+
var SignalMessageLevelEnum;
|
|
228
|
+
(function(SignalMessageLevelEnum2) {
|
|
229
|
+
SignalMessageLevelEnum2["INFO"] = "info";
|
|
230
|
+
SignalMessageLevelEnum2["WARNING"] = "warning";
|
|
231
|
+
SignalMessageLevelEnum2["ERROR"] = "error";
|
|
232
|
+
})(SignalMessageLevelEnum || (exports2.SignalMessageLevelEnum = SignalMessageLevelEnum = {}));
|
|
233
|
+
var SignalMessageEventEnum;
|
|
234
|
+
(function(SignalMessageEventEnum2) {
|
|
235
|
+
SignalMessageEventEnum2["ADD"] = "add";
|
|
236
|
+
SignalMessageEventEnum2["DELETE"] = "delete";
|
|
237
|
+
SignalMessageEventEnum2["OTHER"] = "other";
|
|
238
|
+
})(SignalMessageEventEnum || (exports2.SignalMessageEventEnum = SignalMessageEventEnum = {}));
|
|
239
|
+
var ESignalMessageLevel2;
|
|
240
|
+
(function(ESignalMessageLevel3) {
|
|
241
|
+
ESignalMessageLevel3["INFO"] = "info";
|
|
242
|
+
ESignalMessageLevel3["WARNING"] = "warning";
|
|
243
|
+
ESignalMessageLevel3["ERROR"] = "error";
|
|
244
|
+
})(ESignalMessageLevel2 || (exports2.ESignalMessageLevel = ESignalMessageLevel2 = {}));
|
|
245
|
+
var ESignalMessageEvent;
|
|
246
|
+
(function(ESignalMessageEvent2) {
|
|
247
|
+
ESignalMessageEvent2["ADD"] = "add";
|
|
248
|
+
ESignalMessageEvent2["DELETE"] = "delete";
|
|
249
|
+
ESignalMessageEvent2["OTHER"] = "other";
|
|
250
|
+
})(ESignalMessageEvent || (exports2.ESignalMessageEvent = ESignalMessageEvent = {}));
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/ApiKey.js
|
|
255
|
+
var require_ApiKey = __commonJS({
|
|
256
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/ApiKey.js"(exports2) {
|
|
257
|
+
"use strict";
|
|
258
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// node_modules/uuid/dist/cjs/max.js
|
|
263
|
+
var require_max = __commonJS({
|
|
264
|
+
"node_modules/uuid/dist/cjs/max.js"(exports2) {
|
|
265
|
+
"use strict";
|
|
266
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
267
|
+
exports2.default = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// node_modules/uuid/dist/cjs/nil.js
|
|
272
|
+
var require_nil = __commonJS({
|
|
273
|
+
"node_modules/uuid/dist/cjs/nil.js"(exports2) {
|
|
274
|
+
"use strict";
|
|
275
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
276
|
+
exports2.default = "00000000-0000-0000-0000-000000000000";
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// node_modules/uuid/dist/cjs/regex.js
|
|
281
|
+
var require_regex = __commonJS({
|
|
282
|
+
"node_modules/uuid/dist/cjs/regex.js"(exports2) {
|
|
283
|
+
"use strict";
|
|
284
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
285
|
+
exports2.default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// node_modules/uuid/dist/cjs/validate.js
|
|
290
|
+
var require_validate = __commonJS({
|
|
291
|
+
"node_modules/uuid/dist/cjs/validate.js"(exports2) {
|
|
292
|
+
"use strict";
|
|
293
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
294
|
+
var regex_js_1 = require_regex();
|
|
295
|
+
function validate(uuid) {
|
|
296
|
+
return typeof uuid === "string" && regex_js_1.default.test(uuid);
|
|
297
|
+
}
|
|
298
|
+
exports2.default = validate;
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// node_modules/uuid/dist/cjs/parse.js
|
|
303
|
+
var require_parse = __commonJS({
|
|
304
|
+
"node_modules/uuid/dist/cjs/parse.js"(exports2) {
|
|
305
|
+
"use strict";
|
|
306
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
307
|
+
var validate_js_1 = require_validate();
|
|
308
|
+
function parse(uuid) {
|
|
309
|
+
if (!(0, validate_js_1.default)(uuid)) {
|
|
310
|
+
throw TypeError("Invalid UUID");
|
|
311
|
+
}
|
|
312
|
+
let v;
|
|
313
|
+
return Uint8Array.of((v = parseInt(uuid.slice(0, 8), 16)) >>> 24, v >>> 16 & 255, v >>> 8 & 255, v & 255, (v = parseInt(uuid.slice(9, 13), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(14, 18), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(19, 23), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255, v / 4294967296 & 255, v >>> 24 & 255, v >>> 16 & 255, v >>> 8 & 255, v & 255);
|
|
314
|
+
}
|
|
315
|
+
exports2.default = parse;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
// node_modules/uuid/dist/cjs/stringify.js
|
|
320
|
+
var require_stringify = __commonJS({
|
|
321
|
+
"node_modules/uuid/dist/cjs/stringify.js"(exports2) {
|
|
322
|
+
"use strict";
|
|
323
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
324
|
+
exports2.unsafeStringify = void 0;
|
|
325
|
+
var validate_js_1 = require_validate();
|
|
326
|
+
var byteToHex = [];
|
|
327
|
+
for (let i = 0; i < 256; ++i) {
|
|
328
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
329
|
+
}
|
|
330
|
+
function unsafeStringify(arr, offset = 0) {
|
|
331
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
332
|
+
}
|
|
333
|
+
exports2.unsafeStringify = unsafeStringify;
|
|
334
|
+
function stringify(arr, offset = 0) {
|
|
335
|
+
const uuid = unsafeStringify(arr, offset);
|
|
336
|
+
if (!(0, validate_js_1.default)(uuid)) {
|
|
337
|
+
throw TypeError("Stringified UUID is invalid");
|
|
338
|
+
}
|
|
339
|
+
return uuid;
|
|
340
|
+
}
|
|
341
|
+
exports2.default = stringify;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// node_modules/uuid/dist/cjs/rng.js
|
|
346
|
+
var require_rng = __commonJS({
|
|
347
|
+
"node_modules/uuid/dist/cjs/rng.js"(exports2) {
|
|
348
|
+
"use strict";
|
|
349
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
350
|
+
var crypto_1 = require("crypto");
|
|
351
|
+
var rnds8Pool = new Uint8Array(256);
|
|
352
|
+
var poolPtr = rnds8Pool.length;
|
|
353
|
+
function rng() {
|
|
354
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
|
355
|
+
(0, crypto_1.randomFillSync)(rnds8Pool);
|
|
356
|
+
poolPtr = 0;
|
|
357
|
+
}
|
|
358
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
359
|
+
}
|
|
360
|
+
exports2.default = rng;
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// node_modules/uuid/dist/cjs/v1.js
|
|
365
|
+
var require_v1 = __commonJS({
|
|
366
|
+
"node_modules/uuid/dist/cjs/v1.js"(exports2) {
|
|
367
|
+
"use strict";
|
|
368
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
369
|
+
exports2.updateV1State = void 0;
|
|
370
|
+
var rng_js_1 = require_rng();
|
|
371
|
+
var stringify_js_1 = require_stringify();
|
|
372
|
+
var _state = {};
|
|
373
|
+
function v1(options, buf, offset) {
|
|
374
|
+
let bytes;
|
|
375
|
+
const isV6 = options?._v6 ?? false;
|
|
376
|
+
if (options) {
|
|
377
|
+
const optionsKeys = Object.keys(options);
|
|
378
|
+
if (optionsKeys.length === 1 && optionsKeys[0] === "_v6") {
|
|
379
|
+
options = void 0;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (options) {
|
|
383
|
+
bytes = v1Bytes(options.random ?? options.rng?.() ?? (0, rng_js_1.default)(), options.msecs, options.nsecs, options.clockseq, options.node, buf, offset);
|
|
384
|
+
} else {
|
|
385
|
+
const now = Date.now();
|
|
386
|
+
const rnds = (0, rng_js_1.default)();
|
|
387
|
+
updateV1State(_state, now, rnds);
|
|
388
|
+
bytes = v1Bytes(rnds, _state.msecs, _state.nsecs, isV6 ? void 0 : _state.clockseq, isV6 ? void 0 : _state.node, buf, offset);
|
|
389
|
+
}
|
|
390
|
+
return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
|
|
391
|
+
}
|
|
392
|
+
function updateV1State(state, now, rnds) {
|
|
393
|
+
state.msecs ??= -Infinity;
|
|
394
|
+
state.nsecs ??= 0;
|
|
395
|
+
if (now === state.msecs) {
|
|
396
|
+
state.nsecs++;
|
|
397
|
+
if (state.nsecs >= 1e4) {
|
|
398
|
+
state.node = void 0;
|
|
399
|
+
state.nsecs = 0;
|
|
400
|
+
}
|
|
401
|
+
} else if (now > state.msecs) {
|
|
402
|
+
state.nsecs = 0;
|
|
403
|
+
} else if (now < state.msecs) {
|
|
404
|
+
state.node = void 0;
|
|
405
|
+
}
|
|
406
|
+
if (!state.node) {
|
|
407
|
+
state.node = rnds.slice(10, 16);
|
|
408
|
+
state.node[0] |= 1;
|
|
409
|
+
state.clockseq = (rnds[8] << 8 | rnds[9]) & 16383;
|
|
410
|
+
}
|
|
411
|
+
state.msecs = now;
|
|
412
|
+
return state;
|
|
413
|
+
}
|
|
414
|
+
exports2.updateV1State = updateV1State;
|
|
415
|
+
function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
|
|
416
|
+
if (rnds.length < 16) {
|
|
417
|
+
throw new Error("Random bytes length must be >= 16");
|
|
418
|
+
}
|
|
419
|
+
if (!buf) {
|
|
420
|
+
buf = new Uint8Array(16);
|
|
421
|
+
offset = 0;
|
|
422
|
+
} else {
|
|
423
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
424
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
msecs ??= Date.now();
|
|
428
|
+
nsecs ??= 0;
|
|
429
|
+
clockseq ??= (rnds[8] << 8 | rnds[9]) & 16383;
|
|
430
|
+
node ??= rnds.slice(10, 16);
|
|
431
|
+
msecs += 122192928e5;
|
|
432
|
+
const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
|
|
433
|
+
buf[offset++] = tl >>> 24 & 255;
|
|
434
|
+
buf[offset++] = tl >>> 16 & 255;
|
|
435
|
+
buf[offset++] = tl >>> 8 & 255;
|
|
436
|
+
buf[offset++] = tl & 255;
|
|
437
|
+
const tmh = msecs / 4294967296 * 1e4 & 268435455;
|
|
438
|
+
buf[offset++] = tmh >>> 8 & 255;
|
|
439
|
+
buf[offset++] = tmh & 255;
|
|
440
|
+
buf[offset++] = tmh >>> 24 & 15 | 16;
|
|
441
|
+
buf[offset++] = tmh >>> 16 & 255;
|
|
442
|
+
buf[offset++] = clockseq >>> 8 | 128;
|
|
443
|
+
buf[offset++] = clockseq & 255;
|
|
444
|
+
for (let n = 0; n < 6; ++n) {
|
|
445
|
+
buf[offset++] = node[n];
|
|
446
|
+
}
|
|
447
|
+
return buf;
|
|
448
|
+
}
|
|
449
|
+
exports2.default = v1;
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
// node_modules/uuid/dist/cjs/v1ToV6.js
|
|
454
|
+
var require_v1ToV6 = __commonJS({
|
|
455
|
+
"node_modules/uuid/dist/cjs/v1ToV6.js"(exports2) {
|
|
456
|
+
"use strict";
|
|
457
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
458
|
+
var parse_js_1 = require_parse();
|
|
459
|
+
var stringify_js_1 = require_stringify();
|
|
460
|
+
function v1ToV6(uuid) {
|
|
461
|
+
const v1Bytes = typeof uuid === "string" ? (0, parse_js_1.default)(uuid) : uuid;
|
|
462
|
+
const v6Bytes = _v1ToV6(v1Bytes);
|
|
463
|
+
return typeof uuid === "string" ? (0, stringify_js_1.unsafeStringify)(v6Bytes) : v6Bytes;
|
|
464
|
+
}
|
|
465
|
+
exports2.default = v1ToV6;
|
|
466
|
+
function _v1ToV6(v1Bytes) {
|
|
467
|
+
return Uint8Array.of((v1Bytes[6] & 15) << 4 | v1Bytes[7] >> 4 & 15, (v1Bytes[7] & 15) << 4 | (v1Bytes[4] & 240) >> 4, (v1Bytes[4] & 15) << 4 | (v1Bytes[5] & 240) >> 4, (v1Bytes[5] & 15) << 4 | (v1Bytes[0] & 240) >> 4, (v1Bytes[0] & 15) << 4 | (v1Bytes[1] & 240) >> 4, (v1Bytes[1] & 15) << 4 | (v1Bytes[2] & 240) >> 4, 96 | v1Bytes[2] & 15, v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
// node_modules/uuid/dist/cjs/md5.js
|
|
473
|
+
var require_md5 = __commonJS({
|
|
474
|
+
"node_modules/uuid/dist/cjs/md5.js"(exports2) {
|
|
475
|
+
"use strict";
|
|
476
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
477
|
+
var crypto_1 = require("crypto");
|
|
478
|
+
function md5(bytes) {
|
|
479
|
+
if (Array.isArray(bytes)) {
|
|
480
|
+
bytes = Buffer.from(bytes);
|
|
481
|
+
} else if (typeof bytes === "string") {
|
|
482
|
+
bytes = Buffer.from(bytes, "utf8");
|
|
483
|
+
}
|
|
484
|
+
return (0, crypto_1.createHash)("md5").update(bytes).digest();
|
|
485
|
+
}
|
|
486
|
+
exports2.default = md5;
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
// node_modules/uuid/dist/cjs/v35.js
|
|
491
|
+
var require_v35 = __commonJS({
|
|
492
|
+
"node_modules/uuid/dist/cjs/v35.js"(exports2) {
|
|
493
|
+
"use strict";
|
|
494
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
495
|
+
exports2.URL = exports2.DNS = exports2.stringToBytes = void 0;
|
|
496
|
+
var parse_js_1 = require_parse();
|
|
497
|
+
var stringify_js_1 = require_stringify();
|
|
498
|
+
function stringToBytes(str) {
|
|
499
|
+
str = unescape(encodeURIComponent(str));
|
|
500
|
+
const bytes = new Uint8Array(str.length);
|
|
501
|
+
for (let i = 0; i < str.length; ++i) {
|
|
502
|
+
bytes[i] = str.charCodeAt(i);
|
|
503
|
+
}
|
|
504
|
+
return bytes;
|
|
505
|
+
}
|
|
506
|
+
exports2.stringToBytes = stringToBytes;
|
|
507
|
+
exports2.DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
|
508
|
+
exports2.URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
|
509
|
+
function v35(version, hash, value, namespace, buf, offset) {
|
|
510
|
+
const valueBytes = typeof value === "string" ? stringToBytes(value) : value;
|
|
511
|
+
const namespaceBytes = typeof namespace === "string" ? (0, parse_js_1.default)(namespace) : namespace;
|
|
512
|
+
if (typeof namespace === "string") {
|
|
513
|
+
namespace = (0, parse_js_1.default)(namespace);
|
|
514
|
+
}
|
|
515
|
+
if (namespace?.length !== 16) {
|
|
516
|
+
throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
|
|
517
|
+
}
|
|
518
|
+
let bytes = new Uint8Array(16 + valueBytes.length);
|
|
519
|
+
bytes.set(namespaceBytes);
|
|
520
|
+
bytes.set(valueBytes, namespaceBytes.length);
|
|
521
|
+
bytes = hash(bytes);
|
|
522
|
+
bytes[6] = bytes[6] & 15 | version;
|
|
523
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
524
|
+
if (buf) {
|
|
525
|
+
offset = offset || 0;
|
|
526
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
527
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
528
|
+
}
|
|
529
|
+
for (let i = 0; i < 16; ++i) {
|
|
530
|
+
buf[offset + i] = bytes[i];
|
|
531
|
+
}
|
|
532
|
+
return buf;
|
|
533
|
+
}
|
|
534
|
+
return (0, stringify_js_1.unsafeStringify)(bytes);
|
|
535
|
+
}
|
|
536
|
+
exports2.default = v35;
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
// node_modules/uuid/dist/cjs/v3.js
|
|
541
|
+
var require_v3 = __commonJS({
|
|
542
|
+
"node_modules/uuid/dist/cjs/v3.js"(exports2) {
|
|
543
|
+
"use strict";
|
|
544
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
545
|
+
exports2.URL = exports2.DNS = void 0;
|
|
546
|
+
var md5_js_1 = require_md5();
|
|
547
|
+
var v35_js_1 = require_v35();
|
|
548
|
+
var v35_js_2 = require_v35();
|
|
549
|
+
Object.defineProperty(exports2, "DNS", { enumerable: true, get: function() {
|
|
550
|
+
return v35_js_2.DNS;
|
|
551
|
+
} });
|
|
552
|
+
Object.defineProperty(exports2, "URL", { enumerable: true, get: function() {
|
|
553
|
+
return v35_js_2.URL;
|
|
554
|
+
} });
|
|
555
|
+
function v3(value, namespace, buf, offset) {
|
|
556
|
+
return (0, v35_js_1.default)(48, md5_js_1.default, value, namespace, buf, offset);
|
|
557
|
+
}
|
|
558
|
+
v3.DNS = v35_js_1.DNS;
|
|
559
|
+
v3.URL = v35_js_1.URL;
|
|
560
|
+
exports2.default = v3;
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
// node_modules/uuid/dist/cjs/native.js
|
|
565
|
+
var require_native = __commonJS({
|
|
566
|
+
"node_modules/uuid/dist/cjs/native.js"(exports2) {
|
|
567
|
+
"use strict";
|
|
568
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
569
|
+
var crypto_1 = require("crypto");
|
|
570
|
+
exports2.default = { randomUUID: crypto_1.randomUUID };
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
// node_modules/uuid/dist/cjs/v4.js
|
|
575
|
+
var require_v4 = __commonJS({
|
|
576
|
+
"node_modules/uuid/dist/cjs/v4.js"(exports2) {
|
|
577
|
+
"use strict";
|
|
578
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
579
|
+
var native_js_1 = require_native();
|
|
580
|
+
var rng_js_1 = require_rng();
|
|
581
|
+
var stringify_js_1 = require_stringify();
|
|
582
|
+
function v4(options, buf, offset) {
|
|
583
|
+
if (native_js_1.default.randomUUID && !buf && !options) {
|
|
584
|
+
return native_js_1.default.randomUUID();
|
|
585
|
+
}
|
|
586
|
+
options = options || {};
|
|
587
|
+
const rnds = options.random ?? options.rng?.() ?? (0, rng_js_1.default)();
|
|
588
|
+
if (rnds.length < 16) {
|
|
589
|
+
throw new Error("Random bytes length must be >= 16");
|
|
590
|
+
}
|
|
591
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
592
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
593
|
+
if (buf) {
|
|
594
|
+
offset = offset || 0;
|
|
595
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
596
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
597
|
+
}
|
|
598
|
+
for (let i = 0; i < 16; ++i) {
|
|
599
|
+
buf[offset + i] = rnds[i];
|
|
600
|
+
}
|
|
601
|
+
return buf;
|
|
602
|
+
}
|
|
603
|
+
return (0, stringify_js_1.unsafeStringify)(rnds);
|
|
604
|
+
}
|
|
605
|
+
exports2.default = v4;
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// node_modules/uuid/dist/cjs/sha1.js
|
|
610
|
+
var require_sha1 = __commonJS({
|
|
611
|
+
"node_modules/uuid/dist/cjs/sha1.js"(exports2) {
|
|
612
|
+
"use strict";
|
|
613
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
614
|
+
var crypto_1 = require("crypto");
|
|
615
|
+
function sha1(bytes) {
|
|
616
|
+
if (Array.isArray(bytes)) {
|
|
617
|
+
bytes = Buffer.from(bytes);
|
|
618
|
+
} else if (typeof bytes === "string") {
|
|
619
|
+
bytes = Buffer.from(bytes, "utf8");
|
|
620
|
+
}
|
|
621
|
+
return (0, crypto_1.createHash)("sha1").update(bytes).digest();
|
|
622
|
+
}
|
|
623
|
+
exports2.default = sha1;
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
// node_modules/uuid/dist/cjs/v5.js
|
|
628
|
+
var require_v5 = __commonJS({
|
|
629
|
+
"node_modules/uuid/dist/cjs/v5.js"(exports2) {
|
|
630
|
+
"use strict";
|
|
631
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
632
|
+
exports2.URL = exports2.DNS = void 0;
|
|
633
|
+
var sha1_js_1 = require_sha1();
|
|
634
|
+
var v35_js_1 = require_v35();
|
|
635
|
+
var v35_js_2 = require_v35();
|
|
636
|
+
Object.defineProperty(exports2, "DNS", { enumerable: true, get: function() {
|
|
637
|
+
return v35_js_2.DNS;
|
|
638
|
+
} });
|
|
639
|
+
Object.defineProperty(exports2, "URL", { enumerable: true, get: function() {
|
|
640
|
+
return v35_js_2.URL;
|
|
641
|
+
} });
|
|
642
|
+
function v5(value, namespace, buf, offset) {
|
|
643
|
+
return (0, v35_js_1.default)(80, sha1_js_1.default, value, namespace, buf, offset);
|
|
644
|
+
}
|
|
645
|
+
v5.DNS = v35_js_1.DNS;
|
|
646
|
+
v5.URL = v35_js_1.URL;
|
|
647
|
+
exports2.default = v5;
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
// node_modules/uuid/dist/cjs/v6.js
|
|
652
|
+
var require_v6 = __commonJS({
|
|
653
|
+
"node_modules/uuid/dist/cjs/v6.js"(exports2) {
|
|
654
|
+
"use strict";
|
|
655
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
656
|
+
var stringify_js_1 = require_stringify();
|
|
657
|
+
var v1_js_1 = require_v1();
|
|
658
|
+
var v1ToV6_js_1 = require_v1ToV6();
|
|
659
|
+
function v6(options, buf, offset) {
|
|
660
|
+
options ??= {};
|
|
661
|
+
offset ??= 0;
|
|
662
|
+
let bytes = (0, v1_js_1.default)({ ...options, _v6: true }, new Uint8Array(16));
|
|
663
|
+
bytes = (0, v1ToV6_js_1.default)(bytes);
|
|
664
|
+
if (buf) {
|
|
665
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
666
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
667
|
+
}
|
|
668
|
+
for (let i = 0; i < 16; i++) {
|
|
669
|
+
buf[offset + i] = bytes[i];
|
|
670
|
+
}
|
|
671
|
+
return buf;
|
|
672
|
+
}
|
|
673
|
+
return (0, stringify_js_1.unsafeStringify)(bytes);
|
|
674
|
+
}
|
|
675
|
+
exports2.default = v6;
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
// node_modules/uuid/dist/cjs/v6ToV1.js
|
|
680
|
+
var require_v6ToV1 = __commonJS({
|
|
681
|
+
"node_modules/uuid/dist/cjs/v6ToV1.js"(exports2) {
|
|
682
|
+
"use strict";
|
|
683
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
684
|
+
var parse_js_1 = require_parse();
|
|
685
|
+
var stringify_js_1 = require_stringify();
|
|
686
|
+
function v6ToV1(uuid) {
|
|
687
|
+
const v6Bytes = typeof uuid === "string" ? (0, parse_js_1.default)(uuid) : uuid;
|
|
688
|
+
const v1Bytes = _v6ToV1(v6Bytes);
|
|
689
|
+
return typeof uuid === "string" ? (0, stringify_js_1.unsafeStringify)(v1Bytes) : v1Bytes;
|
|
690
|
+
}
|
|
691
|
+
exports2.default = v6ToV1;
|
|
692
|
+
function _v6ToV1(v6Bytes) {
|
|
693
|
+
return Uint8Array.of((v6Bytes[3] & 15) << 4 | v6Bytes[4] >> 4 & 15, (v6Bytes[4] & 15) << 4 | (v6Bytes[5] & 240) >> 4, (v6Bytes[5] & 15) << 4 | v6Bytes[6] & 15, v6Bytes[7], (v6Bytes[1] & 15) << 4 | (v6Bytes[2] & 240) >> 4, (v6Bytes[2] & 15) << 4 | (v6Bytes[3] & 240) >> 4, 16 | (v6Bytes[0] & 240) >> 4, (v6Bytes[0] & 15) << 4 | (v6Bytes[1] & 240) >> 4, v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
// node_modules/uuid/dist/cjs/v7.js
|
|
699
|
+
var require_v7 = __commonJS({
|
|
700
|
+
"node_modules/uuid/dist/cjs/v7.js"(exports2) {
|
|
701
|
+
"use strict";
|
|
702
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
703
|
+
exports2.updateV7State = void 0;
|
|
704
|
+
var rng_js_1 = require_rng();
|
|
705
|
+
var stringify_js_1 = require_stringify();
|
|
706
|
+
var _state = {};
|
|
707
|
+
function v7(options, buf, offset) {
|
|
708
|
+
let bytes;
|
|
709
|
+
if (options) {
|
|
710
|
+
bytes = v7Bytes(options.random ?? options.rng?.() ?? (0, rng_js_1.default)(), options.msecs, options.seq, buf, offset);
|
|
711
|
+
} else {
|
|
712
|
+
const now = Date.now();
|
|
713
|
+
const rnds = (0, rng_js_1.default)();
|
|
714
|
+
updateV7State(_state, now, rnds);
|
|
715
|
+
bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
|
|
716
|
+
}
|
|
717
|
+
return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
|
|
718
|
+
}
|
|
719
|
+
function updateV7State(state, now, rnds) {
|
|
720
|
+
state.msecs ??= -Infinity;
|
|
721
|
+
state.seq ??= 0;
|
|
722
|
+
if (now > state.msecs) {
|
|
723
|
+
state.seq = rnds[6] << 23 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
|
724
|
+
state.msecs = now;
|
|
725
|
+
} else {
|
|
726
|
+
state.seq = state.seq + 1 | 0;
|
|
727
|
+
if (state.seq === 0) {
|
|
728
|
+
state.msecs++;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return state;
|
|
732
|
+
}
|
|
733
|
+
exports2.updateV7State = updateV7State;
|
|
734
|
+
function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
|
|
735
|
+
if (rnds.length < 16) {
|
|
736
|
+
throw new Error("Random bytes length must be >= 16");
|
|
737
|
+
}
|
|
738
|
+
if (!buf) {
|
|
739
|
+
buf = new Uint8Array(16);
|
|
740
|
+
offset = 0;
|
|
741
|
+
} else {
|
|
742
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
743
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
msecs ??= Date.now();
|
|
747
|
+
seq ??= rnds[6] * 127 << 24 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
|
|
748
|
+
buf[offset++] = msecs / 1099511627776 & 255;
|
|
749
|
+
buf[offset++] = msecs / 4294967296 & 255;
|
|
750
|
+
buf[offset++] = msecs / 16777216 & 255;
|
|
751
|
+
buf[offset++] = msecs / 65536 & 255;
|
|
752
|
+
buf[offset++] = msecs / 256 & 255;
|
|
753
|
+
buf[offset++] = msecs & 255;
|
|
754
|
+
buf[offset++] = 112 | seq >>> 28 & 15;
|
|
755
|
+
buf[offset++] = seq >>> 20 & 255;
|
|
756
|
+
buf[offset++] = 128 | seq >>> 14 & 63;
|
|
757
|
+
buf[offset++] = seq >>> 6 & 255;
|
|
758
|
+
buf[offset++] = seq << 2 & 255 | rnds[10] & 3;
|
|
759
|
+
buf[offset++] = rnds[11];
|
|
760
|
+
buf[offset++] = rnds[12];
|
|
761
|
+
buf[offset++] = rnds[13];
|
|
762
|
+
buf[offset++] = rnds[14];
|
|
763
|
+
buf[offset++] = rnds[15];
|
|
764
|
+
return buf;
|
|
765
|
+
}
|
|
766
|
+
exports2.default = v7;
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
// node_modules/uuid/dist/cjs/version.js
|
|
771
|
+
var require_version = __commonJS({
|
|
772
|
+
"node_modules/uuid/dist/cjs/version.js"(exports2) {
|
|
773
|
+
"use strict";
|
|
774
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
775
|
+
var validate_js_1 = require_validate();
|
|
776
|
+
function version(uuid) {
|
|
777
|
+
if (!(0, validate_js_1.default)(uuid)) {
|
|
778
|
+
throw TypeError("Invalid UUID");
|
|
779
|
+
}
|
|
780
|
+
return parseInt(uuid.slice(14, 15), 16);
|
|
781
|
+
}
|
|
782
|
+
exports2.default = version;
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
|
|
786
|
+
// node_modules/uuid/dist/cjs/index.js
|
|
787
|
+
var require_cjs = __commonJS({
|
|
788
|
+
"node_modules/uuid/dist/cjs/index.js"(exports2) {
|
|
789
|
+
"use strict";
|
|
790
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
791
|
+
exports2.version = exports2.validate = exports2.v7 = exports2.v6ToV1 = exports2.v6 = exports2.v5 = exports2.v4 = exports2.v3 = exports2.v1ToV6 = exports2.v1 = exports2.stringify = exports2.parse = exports2.NIL = exports2.MAX = void 0;
|
|
792
|
+
var max_js_1 = require_max();
|
|
793
|
+
Object.defineProperty(exports2, "MAX", { enumerable: true, get: function() {
|
|
794
|
+
return max_js_1.default;
|
|
795
|
+
} });
|
|
796
|
+
var nil_js_1 = require_nil();
|
|
797
|
+
Object.defineProperty(exports2, "NIL", { enumerable: true, get: function() {
|
|
798
|
+
return nil_js_1.default;
|
|
799
|
+
} });
|
|
800
|
+
var parse_js_1 = require_parse();
|
|
801
|
+
Object.defineProperty(exports2, "parse", { enumerable: true, get: function() {
|
|
802
|
+
return parse_js_1.default;
|
|
803
|
+
} });
|
|
804
|
+
var stringify_js_1 = require_stringify();
|
|
805
|
+
Object.defineProperty(exports2, "stringify", { enumerable: true, get: function() {
|
|
806
|
+
return stringify_js_1.default;
|
|
807
|
+
} });
|
|
808
|
+
var v1_js_1 = require_v1();
|
|
809
|
+
Object.defineProperty(exports2, "v1", { enumerable: true, get: function() {
|
|
810
|
+
return v1_js_1.default;
|
|
811
|
+
} });
|
|
812
|
+
var v1ToV6_js_1 = require_v1ToV6();
|
|
813
|
+
Object.defineProperty(exports2, "v1ToV6", { enumerable: true, get: function() {
|
|
814
|
+
return v1ToV6_js_1.default;
|
|
815
|
+
} });
|
|
816
|
+
var v3_js_1 = require_v3();
|
|
817
|
+
Object.defineProperty(exports2, "v3", { enumerable: true, get: function() {
|
|
818
|
+
return v3_js_1.default;
|
|
819
|
+
} });
|
|
820
|
+
var v4_js_1 = require_v4();
|
|
821
|
+
Object.defineProperty(exports2, "v4", { enumerable: true, get: function() {
|
|
822
|
+
return v4_js_1.default;
|
|
823
|
+
} });
|
|
824
|
+
var v5_js_1 = require_v5();
|
|
825
|
+
Object.defineProperty(exports2, "v5", { enumerable: true, get: function() {
|
|
826
|
+
return v5_js_1.default;
|
|
827
|
+
} });
|
|
828
|
+
var v6_js_1 = require_v6();
|
|
829
|
+
Object.defineProperty(exports2, "v6", { enumerable: true, get: function() {
|
|
830
|
+
return v6_js_1.default;
|
|
831
|
+
} });
|
|
832
|
+
var v6ToV1_js_1 = require_v6ToV1();
|
|
833
|
+
Object.defineProperty(exports2, "v6ToV1", { enumerable: true, get: function() {
|
|
834
|
+
return v6ToV1_js_1.default;
|
|
835
|
+
} });
|
|
836
|
+
var v7_js_1 = require_v7();
|
|
837
|
+
Object.defineProperty(exports2, "v7", { enumerable: true, get: function() {
|
|
838
|
+
return v7_js_1.default;
|
|
839
|
+
} });
|
|
840
|
+
var validate_js_1 = require_validate();
|
|
841
|
+
Object.defineProperty(exports2, "validate", { enumerable: true, get: function() {
|
|
842
|
+
return validate_js_1.default;
|
|
843
|
+
} });
|
|
844
|
+
var version_js_1 = require_version();
|
|
845
|
+
Object.defineProperty(exports2, "version", { enumerable: true, get: function() {
|
|
846
|
+
return version_js_1.default;
|
|
847
|
+
} });
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
|
|
851
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/AccessKey.js
|
|
852
|
+
var require_AccessKey = __commonJS({
|
|
853
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/AccessKey.js"(exports2) {
|
|
854
|
+
"use strict";
|
|
855
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
856
|
+
exports2.AccessKey = void 0;
|
|
857
|
+
exports2.accessKeyBuild = accessKeyBuild;
|
|
858
|
+
exports2.accessKeyCreate = accessKeyCreate;
|
|
859
|
+
exports2.accessKeyDeserialize = accessKeyDeserialize2;
|
|
860
|
+
exports2.accessKeySerialize = accessKeySerialize;
|
|
861
|
+
exports2.parseResource = parseResource;
|
|
862
|
+
exports2.parseResources = parseResources2;
|
|
863
|
+
exports2.buildResource = buildResource;
|
|
864
|
+
var uuid_1 = require_cjs();
|
|
865
|
+
var AccessKey2 = class {
|
|
866
|
+
constructor() {
|
|
867
|
+
this.id = "";
|
|
868
|
+
this.type = "volatile";
|
|
869
|
+
this.resources = "";
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
exports2.AccessKey = AccessKey2;
|
|
873
|
+
function accessKeyCreate(type, resources) {
|
|
874
|
+
let accessKey = new AccessKey2();
|
|
875
|
+
accessKey.id = (0, uuid_1.v4)();
|
|
876
|
+
accessKey.type = type;
|
|
877
|
+
accessKey.resources = resources;
|
|
878
|
+
return accessKey;
|
|
879
|
+
}
|
|
880
|
+
function accessKeyBuild(id, type, resources) {
|
|
881
|
+
let accessKey = new AccessKey2();
|
|
882
|
+
accessKey.id = id;
|
|
883
|
+
accessKey.type = type;
|
|
884
|
+
accessKey.resources = resources;
|
|
885
|
+
return accessKey;
|
|
886
|
+
}
|
|
887
|
+
function accessKeySerialize(accessKey) {
|
|
888
|
+
return `${accessKey.id}|${accessKey.type}|${accessKey.resources}`;
|
|
889
|
+
}
|
|
890
|
+
function accessKeyDeserialize2(key) {
|
|
891
|
+
var parts = key.split("|");
|
|
892
|
+
return accessKeyBuild(parts[0], parts[1], parts[2]);
|
|
893
|
+
}
|
|
894
|
+
function parseResource(key) {
|
|
895
|
+
var parts = key.split(":");
|
|
896
|
+
return {
|
|
897
|
+
scopes: parts[0],
|
|
898
|
+
namespaces: parts[1],
|
|
899
|
+
groups: parts[2],
|
|
900
|
+
pods: parts[3],
|
|
901
|
+
containers: parts[4]
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
function parseResources2(key) {
|
|
905
|
+
if (!key)
|
|
906
|
+
return [];
|
|
907
|
+
let ress = key.split(";");
|
|
908
|
+
let result = [];
|
|
909
|
+
for (var res of ress) {
|
|
910
|
+
result.push(parseResource(res));
|
|
911
|
+
}
|
|
912
|
+
return result;
|
|
913
|
+
}
|
|
914
|
+
function buildResource(scopes, namespaces, groups, pods, containers) {
|
|
915
|
+
return `${scopes.join(",")}:${namespaces.join(",")}:${groups.join(",")}:${pods.join(",")}:${containers.join(",")}`;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
});
|
|
919
|
+
|
|
920
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/Global.js
|
|
921
|
+
var require_Global = __commonJS({
|
|
922
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/Global.js"(exports2) {
|
|
923
|
+
"use strict";
|
|
924
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
925
|
+
}
|
|
926
|
+
});
|
|
927
|
+
|
|
928
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/Version.js
|
|
929
|
+
var require_Version = __commonJS({
|
|
930
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/Version.js"(exports2) {
|
|
931
|
+
"use strict";
|
|
932
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
933
|
+
exports2.versionGreaterThan = exports2.versionGreatOrEqualThan = void 0;
|
|
934
|
+
var versionGreatOrEqualThan = (version1, version2) => {
|
|
935
|
+
return versionGreaterThan(version1, version2) || version1 === version2;
|
|
936
|
+
};
|
|
937
|
+
exports2.versionGreatOrEqualThan = versionGreatOrEqualThan;
|
|
938
|
+
var versionGreaterThan = (version1, version2) => {
|
|
939
|
+
const v1 = version1.split(".").map(Number);
|
|
940
|
+
const v2 = version2.split(".").map(Number);
|
|
941
|
+
for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
|
|
942
|
+
const num1 = v1[i] || 0;
|
|
943
|
+
const num2 = v2[i] || 0;
|
|
944
|
+
if (num1 > num2)
|
|
945
|
+
return true;
|
|
946
|
+
else if (num1 < num2)
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
949
|
+
return false;
|
|
950
|
+
};
|
|
951
|
+
exports2.versionGreaterThan = versionGreaterThan;
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/FrontChannel.js
|
|
956
|
+
var require_FrontChannel = __commonJS({
|
|
957
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/FrontChannel.js"(exports2) {
|
|
958
|
+
"use strict";
|
|
959
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
960
|
+
exports2.EChannelRefreshAction = exports2.ENotifyLevel = void 0;
|
|
961
|
+
var ENotifyLevel;
|
|
962
|
+
(function(ENotifyLevel2) {
|
|
963
|
+
ENotifyLevel2["INFO"] = "info";
|
|
964
|
+
ENotifyLevel2["ERROR"] = "error";
|
|
965
|
+
ENotifyLevel2["WARNING"] = "warning";
|
|
966
|
+
ENotifyLevel2["SUCCESS"] = "success";
|
|
967
|
+
})(ENotifyLevel || (exports2.ENotifyLevel = ENotifyLevel = {}));
|
|
968
|
+
var EChannelRefreshAction;
|
|
969
|
+
(function(EChannelRefreshAction2) {
|
|
970
|
+
EChannelRefreshAction2[EChannelRefreshAction2["NONE"] = 0] = "NONE";
|
|
971
|
+
EChannelRefreshAction2[EChannelRefreshAction2["REFRESH"] = 1] = "REFRESH";
|
|
972
|
+
EChannelRefreshAction2[EChannelRefreshAction2["STOP"] = 2] = "STOP";
|
|
973
|
+
})(EChannelRefreshAction || (exports2.EChannelRefreshAction = EChannelRefreshAction = {}));
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/Daemon.js
|
|
978
|
+
var require_Daemon = __commonJS({
|
|
979
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/Daemon.js"(exports2) {
|
|
980
|
+
"use strict";
|
|
981
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
|
|
985
|
+
// node_modules/@kwirthmagnify/kwirth-common/dist/index.js
|
|
986
|
+
var require_dist = __commonJS({
|
|
987
|
+
"node_modules/@kwirthmagnify/kwirth-common/dist/index.js"(exports2) {
|
|
988
|
+
"use strict";
|
|
989
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
990
|
+
if (k2 === void 0) k2 = k;
|
|
991
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
992
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
993
|
+
desc = { enumerable: true, get: function() {
|
|
994
|
+
return m[k];
|
|
995
|
+
} };
|
|
996
|
+
}
|
|
997
|
+
Object.defineProperty(o, k2, desc);
|
|
998
|
+
}) : (function(o, m, k, k2) {
|
|
999
|
+
if (k2 === void 0) k2 = k;
|
|
1000
|
+
o[k2] = m[k];
|
|
1001
|
+
}));
|
|
1002
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
1003
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
1004
|
+
};
|
|
1005
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1006
|
+
__exportStar(require_Channel(), exports2);
|
|
1007
|
+
__exportStar(require_Sender(), exports2);
|
|
1008
|
+
__exportStar(require_InstanceMessage(), exports2);
|
|
1009
|
+
__exportStar(require_InstanceConfig(), exports2);
|
|
1010
|
+
__exportStar(require_RouteMessage(), exports2);
|
|
1011
|
+
__exportStar(require_SignalMessage(), exports2);
|
|
1012
|
+
__exportStar(require_ApiKey(), exports2);
|
|
1013
|
+
__exportStar(require_AccessKey(), exports2);
|
|
1014
|
+
__exportStar(require_Global(), exports2);
|
|
1015
|
+
__exportStar(require_Version(), exports2);
|
|
1016
|
+
__exportStar(require_FrontChannel(), exports2);
|
|
1017
|
+
__exportStar(require_Daemon(), exports2);
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
|
|
1021
|
+
// src/back/index.ts
|
|
1022
|
+
var index_exports = {};
|
|
1023
|
+
__export(index_exports, {
|
|
1024
|
+
OpsChannel: () => OpsChannel
|
|
1025
|
+
});
|
|
1026
|
+
module.exports = __toCommonJS(index_exports);
|
|
1027
|
+
var import_kwirth_common3 = __toESM(require_dist(), 1);
|
|
1028
|
+
var import_stream = require("stream");
|
|
1029
|
+
|
|
1030
|
+
// src/back/GetCommand.ts
|
|
1031
|
+
var import_kwirth_common = __toESM(require_dist(), 1);
|
|
1032
|
+
async function execCommandDescribe(clusterInfo, opsMessage) {
|
|
1033
|
+
let execResponse = {
|
|
1034
|
+
action: opsMessage.action,
|
|
1035
|
+
flow: import_kwirth_common.EInstanceMessageFlow.RESPONSE,
|
|
1036
|
+
type: import_kwirth_common.EInstanceMessageType.SIGNAL,
|
|
1037
|
+
channel: opsMessage.channel,
|
|
1038
|
+
instance: opsMessage.instance,
|
|
1039
|
+
command: opsMessage.command,
|
|
1040
|
+
id: opsMessage.id,
|
|
1041
|
+
namespace: opsMessage.namespace,
|
|
1042
|
+
group: opsMessage.group,
|
|
1043
|
+
pod: opsMessage.pod,
|
|
1044
|
+
container: opsMessage.container,
|
|
1045
|
+
msgtype: "opsmessageresponse"
|
|
1046
|
+
};
|
|
1047
|
+
if (!opsMessage.namespace) {
|
|
1048
|
+
execResponse.data = `Namespace, pod and container must be specified`;
|
|
1049
|
+
return execResponse;
|
|
1050
|
+
}
|
|
1051
|
+
try {
|
|
1052
|
+
if (!opsMessage.pod && !opsMessage.container) {
|
|
1053
|
+
execResponse.data = await clusterInfo.coreApi.readNamespace({ name: opsMessage.namespace });
|
|
1054
|
+
execResponse.type = import_kwirth_common.EInstanceMessageType.DATA;
|
|
1055
|
+
return execResponse;
|
|
1056
|
+
}
|
|
1057
|
+
let presp = await clusterInfo.coreApi.readNamespacedPod({ name: opsMessage.pod, namespace: opsMessage.namespace });
|
|
1058
|
+
if (!opsMessage.container) {
|
|
1059
|
+
execResponse.data = presp;
|
|
1060
|
+
execResponse.type = import_kwirth_common.EInstanceMessageType.DATA;
|
|
1061
|
+
} else {
|
|
1062
|
+
let cont = presp.spec?.containers.find((c) => c.name === opsMessage.container);
|
|
1063
|
+
if (cont) {
|
|
1064
|
+
execResponse.data = JSON.stringify(cont, null, 2);
|
|
1065
|
+
execResponse.type = import_kwirth_common.EInstanceMessageType.DATA;
|
|
1066
|
+
} else {
|
|
1067
|
+
execResponse.data = "Container not found";
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
return execResponse;
|
|
1071
|
+
} catch (err) {
|
|
1072
|
+
console.error("[ops] execCommandDescribe error:", err);
|
|
1073
|
+
execResponse.data = "Cannot read data";
|
|
1074
|
+
}
|
|
1075
|
+
return execResponse;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
// src/back/RestartCommand.ts
|
|
1079
|
+
var import_kwirth_common2 = __toESM(require_dist(), 1);
|
|
1080
|
+
async function restartPod(clusterInfo, podNamespace, podName) {
|
|
1081
|
+
try {
|
|
1082
|
+
await clusterInfo.coreApi.deleteNamespacedPod({ name: podName, namespace: podNamespace });
|
|
1083
|
+
return `Pod ${podNamespace}/${podName} restarted`;
|
|
1084
|
+
} catch (err) {
|
|
1085
|
+
return `Error restarting pod ${podNamespace}/${podName}: ${err}`;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
async function execCommandRestart(clusterInfo, instance, opsMessage) {
|
|
1089
|
+
let execResponse = {
|
|
1090
|
+
action: opsMessage.action,
|
|
1091
|
+
flow: import_kwirth_common2.EInstanceMessageFlow.RESPONSE,
|
|
1092
|
+
type: import_kwirth_common2.EInstanceMessageType.SIGNAL,
|
|
1093
|
+
channel: opsMessage.channel,
|
|
1094
|
+
instance: opsMessage.instance,
|
|
1095
|
+
command: opsMessage.command,
|
|
1096
|
+
id: opsMessage.id,
|
|
1097
|
+
namespace: opsMessage.namespace,
|
|
1098
|
+
group: opsMessage.group,
|
|
1099
|
+
pod: opsMessage.pod,
|
|
1100
|
+
container: opsMessage.container,
|
|
1101
|
+
msgtype: "opsmessageresponse"
|
|
1102
|
+
};
|
|
1103
|
+
switch (opsMessage.command) {
|
|
1104
|
+
case "restartpod" /* RESTARTPOD */:
|
|
1105
|
+
if (!opsMessage.namespace || !opsMessage.pod) {
|
|
1106
|
+
execResponse.data = `Namespace and pod must be specified`;
|
|
1107
|
+
return execResponse;
|
|
1108
|
+
}
|
|
1109
|
+
if (instance.assets.find((a) => a.podNamespace === opsMessage.namespace && a.podName === opsMessage.pod)) {
|
|
1110
|
+
execResponse.data = await restartPod(clusterInfo, opsMessage.namespace, opsMessage.pod);
|
|
1111
|
+
execResponse.type = import_kwirth_common2.EInstanceMessageType.DATA;
|
|
1112
|
+
} else {
|
|
1113
|
+
execResponse.data = `Cannot find pod '${opsMessage.namespace}/${opsMessage.pod}'`;
|
|
1114
|
+
return execResponse;
|
|
1115
|
+
}
|
|
1116
|
+
break;
|
|
1117
|
+
case "restartns" /* RESTARTNS */:
|
|
1118
|
+
if (!opsMessage.namespace) {
|
|
1119
|
+
execResponse.data = `Namespace must be specified`;
|
|
1120
|
+
return execResponse;
|
|
1121
|
+
}
|
|
1122
|
+
execResponse.data = "";
|
|
1123
|
+
for (let asset of instance.assets) {
|
|
1124
|
+
if (asset.podNamespace === opsMessage.namespace) {
|
|
1125
|
+
try {
|
|
1126
|
+
execResponse.data += await restartPod(clusterInfo, asset.podNamespace, asset.podName) + "\n";
|
|
1127
|
+
} catch (err) {
|
|
1128
|
+
execResponse.data += `Error restarting pod ${asset.podNamespace}/${asset.podName}: ${err}
|
|
1129
|
+
`;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
execResponse.type = import_kwirth_common2.EInstanceMessageType.DATA;
|
|
1134
|
+
break;
|
|
1135
|
+
default:
|
|
1136
|
+
execResponse.data = `Invalid command '${opsMessage.command}'`;
|
|
1137
|
+
break;
|
|
1138
|
+
}
|
|
1139
|
+
return execResponse;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
// src/back/index.ts
|
|
1143
|
+
var checkResource = (resource, namespace, pod, container) => {
|
|
1144
|
+
const parts = (resource.resources || "").split(":");
|
|
1145
|
+
const match = (pattern, value) => !pattern || pattern === "*" || pattern === value;
|
|
1146
|
+
return match(parts[0] || "*", namespace) && match(parts[1] || "*", pod) && match(parts[2] || "*", container);
|
|
1147
|
+
};
|
|
1148
|
+
var OpsChannel = class {
|
|
1149
|
+
channelId = "ops";
|
|
1150
|
+
requirements = { storage: false, providers: [] };
|
|
1151
|
+
clusterInfo;
|
|
1152
|
+
backChannelObject;
|
|
1153
|
+
webSockets = [];
|
|
1154
|
+
constructor(clusterInfo, backChannelObject) {
|
|
1155
|
+
this.clusterInfo = clusterInfo;
|
|
1156
|
+
this.backChannelObject = backChannelObject;
|
|
1157
|
+
}
|
|
1158
|
+
getChannelData() {
|
|
1159
|
+
return {
|
|
1160
|
+
id: "ops",
|
|
1161
|
+
routable: true,
|
|
1162
|
+
pauseable: false,
|
|
1163
|
+
modifiable: false,
|
|
1164
|
+
reconnectable: false,
|
|
1165
|
+
metrics: false,
|
|
1166
|
+
sources: [import_kwirth_common3.EClusterType.KUBERNETES],
|
|
1167
|
+
endpoints: [],
|
|
1168
|
+
websocket: true,
|
|
1169
|
+
cluster: false,
|
|
1170
|
+
resourced: true
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
getChannelScopeLevel(scope) {
|
|
1174
|
+
return ["", "ops$get", "ops$execute", "ops$shell", "ops$restart", "cluster"].indexOf(scope);
|
|
1175
|
+
}
|
|
1176
|
+
startChannel = async () => {
|
|
1177
|
+
};
|
|
1178
|
+
processProviderEvent(_providerId, _obj) {
|
|
1179
|
+
}
|
|
1180
|
+
async endpointRequest(_endpoint, _req, _res) {
|
|
1181
|
+
}
|
|
1182
|
+
async websocketRequest(wso, instanceId, instanceConfig) {
|
|
1183
|
+
let instance = this.getInstance(instanceId);
|
|
1184
|
+
if (!instance) {
|
|
1185
|
+
console.log("[ops] no instance");
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
let asset = instance.assets.find((a) => a.podNamespace === instanceConfig.namespace && a.podName === instanceConfig.pod && a.containerName === instanceConfig.container);
|
|
1189
|
+
if (!asset) {
|
|
1190
|
+
console.log("[ops] no asset");
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
const stdoutStream = new import_stream.PassThrough();
|
|
1194
|
+
const stderrStream = new import_stream.PassThrough();
|
|
1195
|
+
const stdinStream = new import_stream.PassThrough();
|
|
1196
|
+
wso.onmessage = async (event) => {
|
|
1197
|
+
const data = typeof event.data === "string" ? event.data : Buffer.from(await event.data.arrayBuffer());
|
|
1198
|
+
stdinStream.write(data);
|
|
1199
|
+
};
|
|
1200
|
+
wso.onclose = () => {
|
|
1201
|
+
stdinStream.end();
|
|
1202
|
+
};
|
|
1203
|
+
stdoutStream.on("data", (chunk) => wso.send(chunk.toString("utf-8")));
|
|
1204
|
+
stderrStream.on("data", (chunk) => wso.send(chunk.toString("utf-8")));
|
|
1205
|
+
let startCommand = ["/bin/sh"];
|
|
1206
|
+
if (instanceConfig.data) startCommand = instanceConfig.data;
|
|
1207
|
+
await this.clusterInfo.execApi.exec(
|
|
1208
|
+
asset.podNamespace,
|
|
1209
|
+
asset.podName,
|
|
1210
|
+
asset.containerName,
|
|
1211
|
+
startCommand,
|
|
1212
|
+
stdoutStream,
|
|
1213
|
+
stderrStream,
|
|
1214
|
+
stdinStream,
|
|
1215
|
+
true,
|
|
1216
|
+
(status) => {
|
|
1217
|
+
wso.send("Connection to pod has been interrupted\r\n");
|
|
1218
|
+
wso.close();
|
|
1219
|
+
let socket = this.webSockets.find((s) => s.instances.some((i) => i.instanceId === instanceId));
|
|
1220
|
+
if (socket?.ws) {
|
|
1221
|
+
if (status.status === "Success" || status.reason === "NonZeroExitCode")
|
|
1222
|
+
this.sendSignalMessage(socket.ws, import_kwirth_common3.EInstanceMessageAction.NONE, import_kwirth_common3.EInstanceMessageFlow.UNSOLICITED, import_kwirth_common3.ESignalMessageLevel.INFO, instanceConfig.instance, `XTerm session ended`);
|
|
1223
|
+
else
|
|
1224
|
+
this.sendSignalMessage(socket.ws, import_kwirth_common3.EInstanceMessageAction.NONE, import_kwirth_common3.EInstanceMessageFlow.UNSOLICITED, import_kwirth_common3.ESignalMessageLevel.ERROR, instanceConfig.instance, status.message || "Error launching shell");
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1229
|
+
containsAsset = (webSocket, podNamespace, podName, containerName) => {
|
|
1230
|
+
let socket = this.webSockets.find((s) => s.ws === webSocket);
|
|
1231
|
+
if (socket) return socket.instances.some((i) => i.assets.some((a) => a.podNamespace === podNamespace && a.podName === podName && a.containerName === containerName));
|
|
1232
|
+
return false;
|
|
1233
|
+
};
|
|
1234
|
+
containsInstance(instanceId) {
|
|
1235
|
+
return this.webSockets.some((s) => s.instances.find((i) => i.instanceId === instanceId));
|
|
1236
|
+
}
|
|
1237
|
+
async processCommand(webSocket, instanceMessage) {
|
|
1238
|
+
if (instanceMessage.flow === import_kwirth_common3.EInstanceMessageFlow.IMMEDIATE) {
|
|
1239
|
+
let resp2 = await this.executeImmediateCommand(instanceMessage);
|
|
1240
|
+
if (resp2) webSocket.send(JSON.stringify(resp2));
|
|
1241
|
+
return Boolean(resp2);
|
|
1242
|
+
}
|
|
1243
|
+
let socket = this.webSockets.find((s) => s.ws === webSocket);
|
|
1244
|
+
if (!socket) return false;
|
|
1245
|
+
let instance = socket.instances.find((i) => i.instanceId === instanceMessage.instance);
|
|
1246
|
+
if (!instance) {
|
|
1247
|
+
this.sendSignalMessage(webSocket, instanceMessage.action, import_kwirth_common3.EInstanceMessageFlow.RESPONSE, import_kwirth_common3.ESignalMessageLevel.ERROR, instanceMessage.instance, `Instance not found`);
|
|
1248
|
+
return false;
|
|
1249
|
+
}
|
|
1250
|
+
let opsMessage = instanceMessage;
|
|
1251
|
+
let resp = await this.executeCommand(webSocket, instance, opsMessage);
|
|
1252
|
+
if (resp) webSocket.send(JSON.stringify(resp));
|
|
1253
|
+
return Boolean(resp);
|
|
1254
|
+
}
|
|
1255
|
+
addObject = async (webSocket, instanceConfig, podNamespace, podName, containerName) => {
|
|
1256
|
+
let socket = this.webSockets.find((s) => s.ws === webSocket);
|
|
1257
|
+
if (!socket) {
|
|
1258
|
+
let len = this.webSockets.push({ ws: webSocket, lastRefresh: Date.now(), instances: [] });
|
|
1259
|
+
socket = this.webSockets[len - 1];
|
|
1260
|
+
}
|
|
1261
|
+
let instances = socket.instances;
|
|
1262
|
+
let instance = instances.find((i) => i.instanceId === instanceConfig.instance);
|
|
1263
|
+
if (!instance) {
|
|
1264
|
+
instance = { accessKey: (0, import_kwirth_common3.accessKeyDeserialize)(instanceConfig.accessKey), instanceId: instanceConfig.instance, assets: [] };
|
|
1265
|
+
instances.push(instance);
|
|
1266
|
+
}
|
|
1267
|
+
instance.assets.push({ podNamespace, podName, containerName, inShellMode: false, shellSocket: void 0, stdin: void 0, stdout: void 0, stderr: void 0, shellId: "", termSocket: void 0, wsterm: void 0 });
|
|
1268
|
+
return true;
|
|
1269
|
+
};
|
|
1270
|
+
deleteObject = async (webSocket, instanceConfig, podNamespace, podName, containerName) => {
|
|
1271
|
+
const socket = this.webSockets.find((s) => s.ws === webSocket);
|
|
1272
|
+
const instance = socket?.instances.find((i) => i.instanceId === instanceConfig.instance);
|
|
1273
|
+
if (instance) instance.assets = instance.assets.filter((a) => !(a.podNamespace === podNamespace && a.podName === podName && (containerName === "" || a.containerName === containerName)));
|
|
1274
|
+
return true;
|
|
1275
|
+
};
|
|
1276
|
+
pauseContinueInstance(_webSocket, _instanceConfig, _action) {
|
|
1277
|
+
}
|
|
1278
|
+
modifyInstance(_webSocket, _instanceConfig) {
|
|
1279
|
+
}
|
|
1280
|
+
stopInstance(webSocket, instanceConfig) {
|
|
1281
|
+
if (this.webSockets.find((s) => s.ws === webSocket)?.instances.find((i) => i.instanceId === instanceConfig.instance)) {
|
|
1282
|
+
this.removeInstance(webSocket, instanceConfig.instance);
|
|
1283
|
+
this.sendSignalMessage(webSocket, import_kwirth_common3.EInstanceMessageAction.STOP, import_kwirth_common3.EInstanceMessageFlow.RESPONSE, import_kwirth_common3.ESignalMessageLevel.INFO, instanceConfig.instance, "Ops instance stopped");
|
|
1284
|
+
} else {
|
|
1285
|
+
this.sendSignalMessage(webSocket, import_kwirth_common3.EInstanceMessageAction.STOP, import_kwirth_common3.EInstanceMessageFlow.RESPONSE, import_kwirth_common3.ESignalMessageLevel.ERROR, instanceConfig.instance, `Instance not found`);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
removeInstance(webSocket, instanceId) {
|
|
1289
|
+
let socket = this.webSockets.find((s) => s.ws === webSocket);
|
|
1290
|
+
if (socket) {
|
|
1291
|
+
let pos = socket.instances.findIndex((t) => t.instanceId === instanceId);
|
|
1292
|
+
if (pos >= 0) {
|
|
1293
|
+
let instance = socket.instances[pos];
|
|
1294
|
+
for (let asset of instance.assets) {
|
|
1295
|
+
asset.shellSocket?.close();
|
|
1296
|
+
asset.stdin?.destroy();
|
|
1297
|
+
asset.stdout?.destroy();
|
|
1298
|
+
asset.stderr?.destroy();
|
|
1299
|
+
}
|
|
1300
|
+
socket.instances.splice(pos, 1);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
containsConnection(webSocket) {
|
|
1305
|
+
return Boolean(this.webSockets.find((s) => s.ws === webSocket));
|
|
1306
|
+
}
|
|
1307
|
+
removeConnection(webSocket) {
|
|
1308
|
+
let socket = this.webSockets.find((s) => s.ws === webSocket);
|
|
1309
|
+
if (socket) {
|
|
1310
|
+
const ids = socket.instances.map((i) => i.instanceId);
|
|
1311
|
+
for (const id of ids) this.removeInstance(webSocket, id);
|
|
1312
|
+
let pos = this.webSockets.findIndex((s) => s.ws === webSocket);
|
|
1313
|
+
this.webSockets.splice(pos, 1);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
refreshConnection(webSocket) {
|
|
1317
|
+
let socket = this.webSockets.find((s) => s.ws === webSocket);
|
|
1318
|
+
if (socket) {
|
|
1319
|
+
socket.lastRefresh = Date.now();
|
|
1320
|
+
return true;
|
|
1321
|
+
}
|
|
1322
|
+
return false;
|
|
1323
|
+
}
|
|
1324
|
+
updateConnection(_newWebSocket, _instanceId) {
|
|
1325
|
+
return false;
|
|
1326
|
+
}
|
|
1327
|
+
// ─── PRIVATE ────────────────────────────────────────────────────────────────
|
|
1328
|
+
sendSignalMessage = (ws, action, flow, level, instanceId, text) => {
|
|
1329
|
+
ws.send(JSON.stringify({ action, flow, channel: import_kwirth_common3.InstanceMessageChannelEnum.OPS, instance: instanceId, type: import_kwirth_common3.EInstanceMessageType.SIGNAL, text, level }));
|
|
1330
|
+
};
|
|
1331
|
+
sendDataMessage = (ws, instanceId, text) => {
|
|
1332
|
+
ws.send(JSON.stringify({ action: import_kwirth_common3.EInstanceMessageAction.NONE, flow: import_kwirth_common3.EInstanceMessageFlow.UNSOLICITED, channel: import_kwirth_common3.InstanceMessageChannelEnum.OPS, instance: instanceId, type: import_kwirth_common3.EInstanceMessageType.DATA, text }));
|
|
1333
|
+
};
|
|
1334
|
+
async executeLinuxCommand(webSocket, instance, podNamespace, podName, containerName, id, command) {
|
|
1335
|
+
let stdout = new import_stream.Writable({});
|
|
1336
|
+
let stderr = new import_stream.Writable({});
|
|
1337
|
+
let stdin = new import_stream.Readable({ read() {
|
|
1338
|
+
} });
|
|
1339
|
+
let shellSocket = await this.clusterInfo.execApi.exec(podNamespace, podName, containerName, ["/bin/sh", "-i"], stdout, stderr, stdin, true, (_st) => {
|
|
1340
|
+
});
|
|
1341
|
+
shellSocket.onmessage = (event) => {
|
|
1342
|
+
let text = event.data.toString("utf8").substring(1);
|
|
1343
|
+
webSocket.send(JSON.stringify({ action: import_kwirth_common3.EInstanceMessageAction.NONE, flow: import_kwirth_common3.EInstanceMessageFlow.UNSOLICITED, channel: import_kwirth_common3.InstanceMessageChannelEnum.OPS, instance: instance.instanceId, type: import_kwirth_common3.EInstanceMessageType.DATA, id, command: "execute" /* EXECUTE */, namespace: podNamespace, group: "", pod: podName, container: containerName, data: text, msgtype: "opsmessageresponse" }));
|
|
1344
|
+
};
|
|
1345
|
+
shellSocket.onclose = () => {
|
|
1346
|
+
this.sendDataMessage(webSocket, instance.instanceId, "Connection to container has been interrupted");
|
|
1347
|
+
};
|
|
1348
|
+
stdin?.push(command + "\n");
|
|
1349
|
+
}
|
|
1350
|
+
checkAssetScope = (instance, asset, scope) => {
|
|
1351
|
+
let resources = (0, import_kwirth_common3.parseResources)(instance.accessKey.resources);
|
|
1352
|
+
let requiredLevel = this.getChannelScopeLevel(scope);
|
|
1353
|
+
return resources.some((r) => r.scopes.split(",").some((sc) => this.getChannelScopeLevel(sc) >= requiredLevel) && checkResource(r, asset.podNamespace, asset.podName, asset.containerName));
|
|
1354
|
+
};
|
|
1355
|
+
async executeImmediateCommand(instanceMessage) {
|
|
1356
|
+
let opsMessage = instanceMessage;
|
|
1357
|
+
let instance = {
|
|
1358
|
+
accessKey: (0, import_kwirth_common3.accessKeyDeserialize)(opsMessage.accessKey),
|
|
1359
|
+
instanceId: opsMessage.instance,
|
|
1360
|
+
assets: [{ podNamespace: opsMessage.namespace, podName: opsMessage.pod, containerName: opsMessage.container, inShellMode: false, shellSocket: void 0, stdin: void 0, stdout: void 0, stderr: void 0, shellId: "", termSocket: void 0, wsterm: void 0 }]
|
|
1361
|
+
};
|
|
1362
|
+
let resp = { action: opsMessage.action, flow: import_kwirth_common3.EInstanceMessageFlow.RESPONSE, type: import_kwirth_common3.EInstanceMessageType.SIGNAL, channel: opsMessage.channel, instance: opsMessage.instance, command: opsMessage.command, id: opsMessage.id, namespace: opsMessage.namespace, group: opsMessage.group, pod: opsMessage.pod, container: opsMessage.container, msgtype: "opsmessageresponse" };
|
|
1363
|
+
switch (opsMessage.command) {
|
|
1364
|
+
case "describe" /* DESCRIBE */:
|
|
1365
|
+
resp = this.checkAssetScope(instance, instance.assets[0], "ops$get") ? await execCommandDescribe(this.clusterInfo, opsMessage) : { ...resp, data: "Insufficient scope for GET" };
|
|
1366
|
+
break;
|
|
1367
|
+
case "restartpod" /* RESTARTPOD */:
|
|
1368
|
+
case "restartns" /* RESTARTNS */:
|
|
1369
|
+
resp = this.checkAssetScope(instance, instance.assets[0], "ops$restart") ? await execCommandRestart(this.clusterInfo, instance, opsMessage) : { ...resp, data: "Insufficient scope for RESTART" };
|
|
1370
|
+
break;
|
|
1371
|
+
default:
|
|
1372
|
+
resp.data = `Invalid command for route: '${opsMessage.command}'`;
|
|
1373
|
+
}
|
|
1374
|
+
return { msgtype: "routemessageresponse", action: import_kwirth_common3.EInstanceMessageAction.ROUTE, flow: import_kwirth_common3.EInstanceMessageFlow.RESPONSE, type: import_kwirth_common3.EInstanceMessageType.SIGNAL, channel: import_kwirth_common3.InstanceMessageChannelEnum.OPS, instance: instanceMessage.instance, data: resp };
|
|
1375
|
+
}
|
|
1376
|
+
async executeCommand(webSocket, instance, opsMessage) {
|
|
1377
|
+
let execResponse = { action: opsMessage.action, flow: import_kwirth_common3.EInstanceMessageFlow.RESPONSE, type: import_kwirth_common3.EInstanceMessageType.SIGNAL, channel: opsMessage.channel, instance: opsMessage.instance, command: opsMessage.command, id: opsMessage.id, namespace: opsMessage.namespace, group: opsMessage.group, pod: opsMessage.pod, container: opsMessage.container, msgtype: "opsmessageresponse" };
|
|
1378
|
+
if (!opsMessage.command) {
|
|
1379
|
+
execResponse.data = "No command received";
|
|
1380
|
+
return execResponse;
|
|
1381
|
+
}
|
|
1382
|
+
switch (opsMessage.command) {
|
|
1383
|
+
case "describe" /* DESCRIBE */: {
|
|
1384
|
+
let asset = instance.assets.find((a) => a.podNamespace === opsMessage.namespace && a.podName === opsMessage.pod && a.containerName === opsMessage.container);
|
|
1385
|
+
if (!asset) {
|
|
1386
|
+
execResponse.data = "Asset not found";
|
|
1387
|
+
return execResponse;
|
|
1388
|
+
}
|
|
1389
|
+
if (!this.checkAssetScope(instance, asset, "ops$get")) {
|
|
1390
|
+
execResponse.data = "Insufficient scope for GET/DESCRIBE";
|
|
1391
|
+
return execResponse;
|
|
1392
|
+
}
|
|
1393
|
+
execResponse = await execCommandDescribe(this.clusterInfo, opsMessage);
|
|
1394
|
+
break;
|
|
1395
|
+
}
|
|
1396
|
+
case "restart" /* RESTART */: {
|
|
1397
|
+
if (!opsMessage.namespace || !opsMessage.pod || !opsMessage.container) {
|
|
1398
|
+
execResponse.data = "Namespace, pod and container required";
|
|
1399
|
+
return execResponse;
|
|
1400
|
+
}
|
|
1401
|
+
let asset = instance.assets.find((a) => a.podNamespace === opsMessage.namespace && a.podName === opsMessage.pod && a.containerName === opsMessage.container);
|
|
1402
|
+
if (!asset) {
|
|
1403
|
+
execResponse.data = "Asset not found";
|
|
1404
|
+
return execResponse;
|
|
1405
|
+
}
|
|
1406
|
+
if (!this.checkAssetScope(instance, asset, "ops$restart")) {
|
|
1407
|
+
execResponse.data = "Insufficient scope to RESTART CONTAINER";
|
|
1408
|
+
return execResponse;
|
|
1409
|
+
}
|
|
1410
|
+
try {
|
|
1411
|
+
await this.executeLinuxCommand(webSocket, instance, asset.podNamespace, asset.podName, asset.containerName, opsMessage.id, "/usr/sbin/killall5");
|
|
1412
|
+
this.sendSignalMessage(webSocket, import_kwirth_common3.EInstanceMessageAction.COMMAND, import_kwirth_common3.EInstanceMessageFlow.RESPONSE, import_kwirth_common3.ESignalMessageLevel.INFO, instance.instanceId, `Container ${asset.podNamespace}/${asset.podName}/${asset.containerName} restarted`);
|
|
1413
|
+
} catch (err) {
|
|
1414
|
+
this.sendSignalMessage(webSocket, import_kwirth_common3.EInstanceMessageAction.COMMAND, import_kwirth_common3.EInstanceMessageFlow.RESPONSE, import_kwirth_common3.ESignalMessageLevel.ERROR, instance.instanceId, `Error restarting: ${err}`);
|
|
1415
|
+
}
|
|
1416
|
+
execResponse.type = import_kwirth_common3.EInstanceMessageType.DATA;
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
case "restartns" /* RESTARTNS */:
|
|
1420
|
+
for (let asset of instance.assets) {
|
|
1421
|
+
if (!this.checkAssetScope(instance, asset, "ops$restart")) {
|
|
1422
|
+
execResponse.data = `No RESTART scope on [${asset.podNamespace}/${asset.podName}/${asset.containerName}]`;
|
|
1423
|
+
return execResponse;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
execResponse = await execCommandRestart(this.clusterInfo, instance, opsMessage);
|
|
1427
|
+
break;
|
|
1428
|
+
case "restartpod" /* RESTARTPOD */: {
|
|
1429
|
+
if (!opsMessage.namespace || !opsMessage.pod) {
|
|
1430
|
+
execResponse.data = "Namespace and pod required";
|
|
1431
|
+
return execResponse;
|
|
1432
|
+
}
|
|
1433
|
+
let asset = instance.assets.find((a) => a.podNamespace === opsMessage.namespace && a.podName === opsMessage.pod);
|
|
1434
|
+
if (!asset) {
|
|
1435
|
+
execResponse.data = "Asset not found";
|
|
1436
|
+
return execResponse;
|
|
1437
|
+
}
|
|
1438
|
+
if (!this.checkAssetScope(instance, asset, "ops$restart")) {
|
|
1439
|
+
execResponse.data = "Insufficient scope to RESTARTPOD";
|
|
1440
|
+
return execResponse;
|
|
1441
|
+
}
|
|
1442
|
+
execResponse = await execCommandRestart(this.clusterInfo, instance, opsMessage);
|
|
1443
|
+
break;
|
|
1444
|
+
}
|
|
1445
|
+
default:
|
|
1446
|
+
execResponse.data = `Invalid command '${opsMessage.command}'`;
|
|
1447
|
+
}
|
|
1448
|
+
return execResponse;
|
|
1449
|
+
}
|
|
1450
|
+
getInstance(instanceId) {
|
|
1451
|
+
return this.webSockets.find((s) => s.instances.some((i) => i.instanceId === instanceId))?.instances.find((i) => i.instanceId === instanceId);
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1455
|
+
0 && (module.exports = {
|
|
1456
|
+
OpsChannel
|
|
1457
|
+
});
|