@catladder/cli 1.0.4 → 1.0.5
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/dist/apps/catenv/catenv.d.ts +2 -0
- package/dist/apps/catenv/catenv.js +135 -0
- package/dist/apps/catenv/catenv.js.map +1 -0
- package/dist/apps/cli/cli.d.ts +2 -0
- package/dist/apps/cli/cli.js +81 -0
- package/dist/apps/cli/cli.js.map +1 -0
- package/dist/apps/cli/commands/general/index.d.ts +4 -0
- package/dist/apps/cli/commands/general/index.js +274 -0
- package/dist/apps/cli/commands/general/index.js.map +1 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.d.ts +3 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.js +56 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.js.map +1 -0
- package/dist/apps/cli/commands/general/portForward.d.ts +3 -0
- package/dist/apps/cli/commands/general/portForward.js +98 -0
- package/dist/apps/cli/commands/general/portForward.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/index.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/index.js +53 -0
- package/dist/apps/cli/commands/mongodb/index.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +190 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js +96 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +105 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/utils/index.d.ts +13 -0
- package/dist/apps/cli/commands/mongodb/utils/index.js +167 -0
- package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +128 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +254 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -0
- package/dist/apps/cli/commands/project/commandCopyDB.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandCopyDB.js +102 -0
- package/dist/apps/cli/commands/project/commandCopyDB.js.map +1 -0
- package/dist/apps/cli/commands/project/commandDeletePods.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandDeletePods.js +119 -0
- package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.js +97 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.js.map +1 -0
- package/dist/apps/cli/commands/project/commandEnvVars.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandEnvVars.js +74 -0
- package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +58 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGetShell.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGetShell.js +92 -0
- package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.js +185 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -0
- package/dist/apps/cli/commands/project/commandInitGitlab.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandInitGitlab.js +245 -0
- package/dist/apps/cli/commands/project/commandInitGitlab.js.map +1 -0
- package/dist/apps/cli/commands/project/commandInitProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandInitProject.js +345 -0
- package/dist/apps/cli/commands/project/commandInitProject.js.map +1 -0
- package/dist/apps/cli/commands/project/commandListPods.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandListPods.js +78 -0
- package/dist/apps/cli/commands/project/commandListPods.js.map +1 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +7 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js +113 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -0
- package/dist/apps/cli/commands/project/commandNamespace.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandNamespace.js +70 -0
- package/dist/apps/cli/commands/project/commandNamespace.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +83 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.js +92 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.js +80 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGit.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGit.js +56 -0
- package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.js +83 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +99 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.js +87 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -0
- package/dist/apps/cli/commands/project/commandPauseProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandPauseProject.js +97 -0
- package/dist/apps/cli/commands/project/commandPauseProject.js.map +1 -0
- package/dist/apps/cli/commands/project/commandPortForward.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandPortForward.js +106 -0
- package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -0
- package/dist/apps/cli/commands/project/commandReloadConfig.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandReloadConfig.js +62 -0
- package/dist/apps/cli/commands/project/commandReloadConfig.js.map +1 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js +144 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -0
- package/dist/apps/cli/commands/project/index.d.ts +3 -0
- package/dist/apps/cli/commands/project/index.js +97 -0
- package/dist/apps/cli/commands/project/index.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.d.ts +3 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.js +96 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.d.ts +1 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.js +84 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js +92 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +2 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.js +58 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.js.map +1 -0
- package/dist/apps/cli/commands/shared/index.d.ts +2 -0
- package/dist/apps/cli/commands/shared/index.js +72 -0
- package/dist/apps/cli/commands/shared/index.js.map +1 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +3 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +131 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -0
- package/dist/apps/cli/config/writeConfig.d.ts +5 -0
- package/dist/apps/cli/config/writeConfig.js +104 -0
- package/dist/apps/cli/config/writeConfig.js.map +1 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.d.ts +1 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.js +69 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -0
- package/dist/apps/cli/verify/index.d.ts +2 -0
- package/dist/apps/cli/verify/index.js +90 -0
- package/dist/apps/cli/verify/index.js.map +1 -0
- package/dist/apps/cli/verify/migration/fromv2.d.ts +3 -0
- package/dist/apps/cli/verify/migration/fromv2.js +322 -0
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +4 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.js +88 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +17 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.js +26 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -0
- package/dist/catenv.d.ts +1 -0
- package/dist/catenv.js +8 -0
- package/dist/catenv.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/clusters.d.ts +14 -0
- package/dist/config/clusters.js +72 -0
- package/dist/config/clusters.js.map +1 -0
- package/dist/config/constants.d.ts +4 -0
- package/dist/config/constants.js +8 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/getProjectConfig.d.ts +21 -0
- package/dist/config/getProjectConfig.js +212 -0
- package/dist/config/getProjectConfig.js.map +1 -0
- package/dist/k8sApi/index.d.ts +5 -0
- package/dist/k8sApi/index.js +11 -0
- package/dist/k8sApi/index.js.map +1 -0
- package/dist/packageInfos.d.ts +2 -0
- package/dist/packageInfos.js +6 -0
- package/dist/packageInfos.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/types.d.ts +18 -0
- package/dist/types/types.js +3 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/cluster.d.ts +12 -0
- package/dist/utils/cluster.js +100 -0
- package/dist/utils/cluster.js.map +1 -0
- package/dist/utils/editAsFile.d.ts +1 -0
- package/dist/utils/editAsFile.js +85 -0
- package/dist/utils/editAsFile.js.map +1 -0
- package/dist/utils/files.d.ts +2 -0
- package/dist/utils/files.js +83 -0
- package/dist/utils/files.js.map +1 -0
- package/dist/utils/formatEnvVars.d.ts +2 -0
- package/dist/utils/formatEnvVars.js +10 -0
- package/dist/utils/formatEnvVars.js.map +1 -0
- package/dist/utils/getEditor.d.ts +4 -0
- package/dist/utils/getEditor.js +70 -0
- package/dist/utils/getEditor.js.map +1 -0
- package/dist/utils/gitlab.d.ts +21 -0
- package/dist/utils/gitlab.js +258 -0
- package/dist/utils/gitlab.js.map +1 -0
- package/dist/utils/log.d.ts +1 -0
- package/dist/utils/log.js +14 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/passwordstore/index.d.ts +8 -0
- package/dist/utils/passwordstore/index.js +378 -0
- package/dist/utils/passwordstore/index.js.map +1 -0
- package/dist/utils/portForward.d.ts +4 -0
- package/dist/utils/portForward.js +116 -0
- package/dist/utils/portForward.js.map +1 -0
- package/dist/utils/preferences/index.d.ts +3 -0
- package/dist/utils/preferences/index.js +119 -0
- package/dist/utils/preferences/index.js.map +1 -0
- package/dist/utils/projects/index.d.ts +8 -0
- package/dist/utils/projects/index.js +150 -0
- package/dist/utils/projects/index.js.map +1 -0
- package/dist/utils/promise.d.ts +2 -0
- package/dist/utils/promise.js +62 -0
- package/dist/utils/promise.js.map +1 -0
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.js +81 -0
- package/dist/utils/shell.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
exports.__esModule = true;
|
|
42
|
+
var log_1 = require("../../../../utils/log");
|
|
43
|
+
var portForward_1 = require("../../../../utils/portForward");
|
|
44
|
+
var k8sApi_1 = __importDefault(require("../../../../k8sApi"));
|
|
45
|
+
var namespaceAutoCompletion_1 = require("./namespaceAutoCompletion");
|
|
46
|
+
exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
return [2 /*return*/, vorpal
|
|
49
|
+
.command("port-forward <namespace>", "start port-forwarding")
|
|
50
|
+
.autocomplete(namespaceAutoCompletion_1.namespaceAutoCompletion)
|
|
51
|
+
.action(function (_a) {
|
|
52
|
+
var namespace = _a.namespace;
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var res, podNames, podName, localPort, remotePort;
|
|
55
|
+
return __generator(this, function (_b) {
|
|
56
|
+
switch (_b.label) {
|
|
57
|
+
case 0: return [4 /*yield*/, k8sApi_1["default"].listNamespacedPod(namespace)];
|
|
58
|
+
case 1:
|
|
59
|
+
res = _b.sent();
|
|
60
|
+
if (res.body.items.length === 0) {
|
|
61
|
+
(0, log_1.logError)(this, "sorry, no pods found");
|
|
62
|
+
return [2 /*return*/];
|
|
63
|
+
}
|
|
64
|
+
podNames = res.body.items.map(function (i) { return i.metadata.name; });
|
|
65
|
+
if (podNames.length === 0) {
|
|
66
|
+
(0, log_1.logError)(this, "sorry, no pods found");
|
|
67
|
+
return [2 /*return*/];
|
|
68
|
+
}
|
|
69
|
+
return [4 /*yield*/, this.prompt({
|
|
70
|
+
type: "list",
|
|
71
|
+
name: "podName",
|
|
72
|
+
choices: podNames,
|
|
73
|
+
message: "Which pod? 🤔"
|
|
74
|
+
})];
|
|
75
|
+
case 2:
|
|
76
|
+
podName = (_b.sent()).podName;
|
|
77
|
+
return [4 /*yield*/, this.prompt({
|
|
78
|
+
type: "number",
|
|
79
|
+
name: "localPort",
|
|
80
|
+
message: "Local port: "
|
|
81
|
+
})];
|
|
82
|
+
case 3:
|
|
83
|
+
localPort = (_b.sent()).localPort;
|
|
84
|
+
return [4 /*yield*/, this.prompt({
|
|
85
|
+
type: "number",
|
|
86
|
+
name: "remotePort",
|
|
87
|
+
message: "Remote port: "
|
|
88
|
+
})];
|
|
89
|
+
case 4:
|
|
90
|
+
remotePort = (_b.sent()).remotePort;
|
|
91
|
+
return [2 /*return*/, (0, portForward_1.startPortForward)(podName, localPort, remotePort, namespace)];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
})];
|
|
96
|
+
});
|
|
97
|
+
}); });
|
|
98
|
+
//# sourceMappingURL=portForward.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portForward.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/general/portForward.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAiD;AAEjD,6DAAiE;AAEjE,8DAAwC;AACxC,qEAAoE;AAEpE,sBAAe,UAAO,MAAc;;QAClC,sBAAA,MAAM;iBACH,OAAO,CAAC,0BAA0B,EAAE,uBAAuB,CAAC;iBAC5D,YAAY,CAAC,iDAAuB,CAAC;iBACrC,MAAM,CAAC,UAAgB,EAAa;oBAAX,SAAS,eAAA;;;;;oCACrB,qBAAM,mBAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAA;;gCAA/C,GAAG,GAAG,SAAyC;gCACrD,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;oCAC/B,IAAA,cAAQ,EAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;oCACvC,sBAAO;iCACR;gCACK,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAf,CAAe,CAAC,CAAC;gCAE5D,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;oCACzB,IAAA,cAAQ,EAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;oCACvC,sBAAO;iCACR;gCACmB,qBAAM,IAAI,CAAC,MAAM,CAAC;wCACpC,IAAI,EAAE,MAAM;wCACZ,IAAI,EAAE,SAAS;wCACf,OAAO,EAAE,QAAQ;wCACjB,OAAO,EAAE,eAAe;qCACzB,CAAC,EAAA;;gCALM,OAAO,GAAK,CAAA,SAKlB,CAAA,QALa;gCAOO,qBAAM,IAAI,CAAC,MAAM,CAAC;wCACtC,IAAI,EAAE,QAAQ;wCACd,IAAI,EAAE,WAAW;wCAEjB,OAAO,EAAE,cAAc;qCACxB,CAAC,EAAA;;gCALM,SAAS,GAAK,CAAA,SAKpB,CAAA,UALe;gCAOM,qBAAM,IAAI,CAAC,MAAM,CAAC;wCACvC,IAAI,EAAE,QAAQ;wCACd,IAAI,EAAE,YAAY;wCAElB,OAAO,EAAE,eAAe;qCACzB,CAAC,EAAA;;gCALM,UAAU,GAAK,CAAA,SAKrB,CAAA,WALgB;gCAOlB,sBAAO,IAAA,8BAAgB,EAAC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,EAAC;;;;aACpE,CAAC,EAAA;;KAAA,EAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
exports.__esModule = true;
|
|
42
|
+
var projectMongoDestroyMember_1 = __importDefault(require("./projectMongoDestroyMember"));
|
|
43
|
+
var projectMongoGetShell_1 = __importDefault(require("./projectMongoGetShell"));
|
|
44
|
+
var projectMongoPortForward_1 = __importDefault(require("./projectMongoPortForward"));
|
|
45
|
+
exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
(0, projectMongoGetShell_1["default"])(vorpal);
|
|
48
|
+
(0, projectMongoPortForward_1["default"])(vorpal);
|
|
49
|
+
(0, projectMongoDestroyMember_1["default"])(vorpal);
|
|
50
|
+
return [2 /*return*/];
|
|
51
|
+
});
|
|
52
|
+
}); });
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/mongodb/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0FAAoE;AACpE,gFAA0D;AAC1D,sFAAgE;AAEhE,sBAAe,UAAO,MAAc;;QAClC,IAAA,iCAAoB,EAAC,MAAM,CAAC,CAAC;QAC7B,IAAA,oCAAuB,EAAC,MAAM,CAAC,CAAC;QAChC,IAAA,sCAAyB,EAAC,MAAM,CAAC,CAAC;;;KACnC,EAAC"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
exports.__esModule = true;
|
|
42
|
+
var child_process_promise_1 = require("child-process-promise");
|
|
43
|
+
var log_1 = require("../../../../utils/log");
|
|
44
|
+
var projects_1 = require("../../../../utils/projects");
|
|
45
|
+
var autocompletions_1 = require("../project/utils/autocompletions");
|
|
46
|
+
var ensureCluster_1 = __importDefault(require("../project/utils/ensureCluster"));
|
|
47
|
+
var utils_1 = require("./utils");
|
|
48
|
+
var removeFinalizer = function (namespace, type, name) { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
return [2 /*return*/, (0, child_process_promise_1.exec)("kubectl patch --namespace ".concat(namespace, " ").concat(type, " ").concat(name, " -p '{\"metadata\":{\"finalizers\":null}}'"))];
|
|
51
|
+
});
|
|
52
|
+
}); };
|
|
53
|
+
var deleteResource = function (namespace, type, name) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
54
|
+
return [2 /*return*/, (0, child_process_promise_1.exec)("kubectl delete --namespace ".concat(namespace, " ").concat(type, " ").concat(name))];
|
|
55
|
+
}); }); };
|
|
56
|
+
var removeFinalizerAndDelete = function (namespace, type, name) { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
return __generator(this, function (_d) {
|
|
59
|
+
switch (_d.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
_b = (_a = Promise).all;
|
|
62
|
+
_c = [removeFinalizer(namespace, type, name)];
|
|
63
|
+
return [4 /*yield*/, deleteResource(namespace, type, name)];
|
|
64
|
+
case 1: return [2 /*return*/, _b.apply(_a, [_c.concat([
|
|
65
|
+
_d.sent()
|
|
66
|
+
])])];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}); };
|
|
70
|
+
exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
return __generator(this, function (_c) {
|
|
73
|
+
switch (_c.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
_b = (_a = vorpal
|
|
76
|
+
.command("project-mongo-destroy-member <envComponent>", "DESTROY a member of a replicaset in order to reinitialize it"))
|
|
77
|
+
.autocomplete;
|
|
78
|
+
return [4 /*yield*/, (0, autocompletions_1.envAndComponents)()];
|
|
79
|
+
case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])
|
|
80
|
+
.action(function (_a) {
|
|
81
|
+
var envComponent = _a.envComponent;
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
var understood, namespace, mongodbPods, pvcs, secondaries, podName, thePvc, shouldContinue, e_1, e_2;
|
|
84
|
+
return __generator(this, function (_b) {
|
|
85
|
+
switch (_b.label) {
|
|
86
|
+
case 0: return [4 /*yield*/, ensureCluster_1["default"].call(this, envComponent)];
|
|
87
|
+
case 1:
|
|
88
|
+
_b.sent();
|
|
89
|
+
this.log("this command tries to delete a (secondary) member of the replicaset, it's persistent volume claim (pvc) and the volume");
|
|
90
|
+
this.log("");
|
|
91
|
+
this.log("this is useful, if you update the stateful set with new volume configuration (different size or storage class)");
|
|
92
|
+
this.log("");
|
|
93
|
+
this.log("Kubernetes will usually recreate the missing member with the updated config and mongodb will start synchronizing the new member.");
|
|
94
|
+
this.log("");
|
|
95
|
+
this.log("This works without downtime, but should be done when load on the db is low. Also it has not been tested with large dbs (> 10gi)");
|
|
96
|
+
this.log("");
|
|
97
|
+
this.log("Deleting the volume and claim often stuck, just wait or cancel and restart.");
|
|
98
|
+
this.log("");
|
|
99
|
+
return [4 /*yield*/, this.prompt({
|
|
100
|
+
"default": true,
|
|
101
|
+
message: "DO YOU UNDERSTAND?",
|
|
102
|
+
name: "understood",
|
|
103
|
+
type: "confirm"
|
|
104
|
+
})];
|
|
105
|
+
case 2:
|
|
106
|
+
understood = (_b.sent()).understood;
|
|
107
|
+
if (!understood) {
|
|
108
|
+
throw new Error("abort");
|
|
109
|
+
}
|
|
110
|
+
return [4 /*yield*/, (0, projects_1.getProjectNamespace)(envComponent)];
|
|
111
|
+
case 3:
|
|
112
|
+
namespace = _b.sent();
|
|
113
|
+
return [4 /*yield*/, (0, utils_1.getMongoDbPodsWithReplInfo)(envComponent)];
|
|
114
|
+
case 4:
|
|
115
|
+
mongodbPods = _b.sent();
|
|
116
|
+
return [4 /*yield*/, (0, projects_1.getProjectPvcs)(envComponent)];
|
|
117
|
+
case 5:
|
|
118
|
+
pvcs = _b.sent();
|
|
119
|
+
secondaries = mongodbPods.filter(function (pod) { return !pod.isMaster; });
|
|
120
|
+
if (secondaries.length === 0) {
|
|
121
|
+
(0, log_1.logError)(this, "sorry, no pods found");
|
|
122
|
+
return [2 /*return*/];
|
|
123
|
+
}
|
|
124
|
+
return [4 /*yield*/, this.prompt({
|
|
125
|
+
type: "list",
|
|
126
|
+
name: "podName",
|
|
127
|
+
choices: secondaries.map(function (p) { return ({
|
|
128
|
+
name: "[ secondary ] ".concat(p.podName),
|
|
129
|
+
value: p.podName
|
|
130
|
+
}); }),
|
|
131
|
+
message: "Which pod? 🤔"
|
|
132
|
+
})];
|
|
133
|
+
case 6:
|
|
134
|
+
podName = (_b.sent()).podName;
|
|
135
|
+
thePvc = pvcs.find(function (pvc) { return pvc.metadata.name === "datadir-".concat(podName); });
|
|
136
|
+
if (!thePvc) {
|
|
137
|
+
(0, log_1.logError)(this, "sorry, no pvc found for ".concat(podName));
|
|
138
|
+
return [2 /*return*/];
|
|
139
|
+
}
|
|
140
|
+
return [4 /*yield*/, this.prompt({
|
|
141
|
+
"default": true,
|
|
142
|
+
message: "THIS WILL DESTROY THE POD, ITS VOLUME AND ALL ITS DATA 🙀🙀🙀!!! continue? 🤔",
|
|
143
|
+
name: "shouldContinue",
|
|
144
|
+
type: "confirm"
|
|
145
|
+
})];
|
|
146
|
+
case 7:
|
|
147
|
+
shouldContinue = (_b.sent()).shouldContinue;
|
|
148
|
+
if (!shouldContinue) {
|
|
149
|
+
throw new Error("abort");
|
|
150
|
+
}
|
|
151
|
+
// force delete, see https://github.com/kubernetes/kubernetes/issues/77258#issuecomment-502209800
|
|
152
|
+
this.log("destroying volume...");
|
|
153
|
+
_b.label = 8;
|
|
154
|
+
case 8:
|
|
155
|
+
_b.trys.push([8, 10, , 11]);
|
|
156
|
+
return [4 /*yield*/, removeFinalizerAndDelete(namespace, "pv", thePvc.spec.volumeName)];
|
|
157
|
+
case 9:
|
|
158
|
+
_b.sent();
|
|
159
|
+
return [3 /*break*/, 11];
|
|
160
|
+
case 10:
|
|
161
|
+
e_1 = _b.sent();
|
|
162
|
+
this.log(e_1.message);
|
|
163
|
+
return [3 /*break*/, 11];
|
|
164
|
+
case 11:
|
|
165
|
+
this.log("destroying volume claim...");
|
|
166
|
+
_b.label = 12;
|
|
167
|
+
case 12:
|
|
168
|
+
_b.trys.push([12, 14, , 15]);
|
|
169
|
+
return [4 /*yield*/, removeFinalizerAndDelete(namespace, "pvc", thePvc.metadata.name)];
|
|
170
|
+
case 13:
|
|
171
|
+
_b.sent();
|
|
172
|
+
return [3 /*break*/, 15];
|
|
173
|
+
case 14:
|
|
174
|
+
e_2 = _b.sent();
|
|
175
|
+
this.log(e_2.message);
|
|
176
|
+
return [3 /*break*/, 15];
|
|
177
|
+
case 15:
|
|
178
|
+
this.log("destroying pod...");
|
|
179
|
+
return [4 /*yield*/, removeFinalizerAndDelete(namespace, "pod", podName)];
|
|
180
|
+
case 16:
|
|
181
|
+
_b.sent();
|
|
182
|
+
return [2 /*return*/];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
})];
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}); });
|
|
190
|
+
//# sourceMappingURL=projectMongoDestroyMember.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectMongoDestroyMember.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA6C;AAE7C,6CAAiD;AACjD,uDAGoC;AACpC,oEAAoE;AACpE,iFAA2D;AAC3D,iCAAqD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,GAAC,CAAC,OAAO,CAAC,CAAC;;;oCAEtB,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;oCAC9B,qBAAM,wBAAwB,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,EAAA;;oCAAzD,SAAyD,CAAC;;;;;iBAC3D,CAAC,EAAA;;;KAAA,EAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
exports.__esModule = true;
|
|
42
|
+
var log_1 = require("../../../../utils/log");
|
|
43
|
+
var projects_1 = require("../../../../utils/projects");
|
|
44
|
+
var autocompletions_1 = require("../project/utils/autocompletions");
|
|
45
|
+
var ensureCluster_1 = __importDefault(require("../project/utils/ensureCluster"));
|
|
46
|
+
var utils_1 = require("./utils");
|
|
47
|
+
exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
return __generator(this, function (_c) {
|
|
50
|
+
switch (_c.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
_b = (_a = vorpal
|
|
53
|
+
.command("project-mongo-get-shell <envComponent>", "get a shell to a mongodb in the environment"))
|
|
54
|
+
.autocomplete;
|
|
55
|
+
return [4 /*yield*/, (0, autocompletions_1.envAndComponents)()];
|
|
56
|
+
case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])
|
|
57
|
+
.action(function (_a) {
|
|
58
|
+
var envComponent = _a.envComponent;
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
var namespace, podNames, podName;
|
|
61
|
+
return __generator(this, function (_b) {
|
|
62
|
+
switch (_b.label) {
|
|
63
|
+
case 0: return [4 /*yield*/, ensureCluster_1["default"].call(this, envComponent)];
|
|
64
|
+
case 1:
|
|
65
|
+
_b.sent();
|
|
66
|
+
return [4 /*yield*/, (0, projects_1.getProjectNamespace)(envComponent)];
|
|
67
|
+
case 2:
|
|
68
|
+
namespace = _b.sent();
|
|
69
|
+
return [4 /*yield*/, (0, utils_1.getProjectMongodbAllPodsSortedWithLabel)(envComponent)];
|
|
70
|
+
case 3:
|
|
71
|
+
podNames = _b.sent();
|
|
72
|
+
if (podNames.length === 0) {
|
|
73
|
+
(0, log_1.logError)(this, "sorry, no pods found");
|
|
74
|
+
return [2 /*return*/];
|
|
75
|
+
}
|
|
76
|
+
if (!(podNames.length === 1)) return [3 /*break*/, 4];
|
|
77
|
+
podName = podNames[0];
|
|
78
|
+
return [3 /*break*/, 6];
|
|
79
|
+
case 4: return [4 /*yield*/, this.prompt({
|
|
80
|
+
type: "list",
|
|
81
|
+
name: "podName",
|
|
82
|
+
choices: podNames,
|
|
83
|
+
message: "Which pod? 🤔"
|
|
84
|
+
})];
|
|
85
|
+
case 5:
|
|
86
|
+
podName = (_b.sent()).podName;
|
|
87
|
+
_b.label = 6;
|
|
88
|
+
case 6: return [2 /*return*/, (0, utils_1.getMongodbShell)(namespace, podName)];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
})];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}); });
|
|
96
|
+
//# sourceMappingURL=projectMongoGetShell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectMongoGetShell.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/mongodb/projectMongoGetShell.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAiD;AACjD,uDAAiE;AACjE,oEAAoE;AACpE,iFAA2D;AAC3D,iCAGiB;AAEjB,sBAAe,UAAO,MAAc;;;;;gBAClC,KAAA,CAAA,KAAA,MAAM;qBACH,OAAO,CACN,wCAAwC,EACxC,6CAA6C,CAC9C,CAAA;qBACA,YAAY,CAAA;gBAAC,qBAAM,IAAA,kCAAgB,GAAE,EAAA;oBALxC,sBAAA,cAKgB,SAAwB,EAAC;qBACtC,MAAM,CAAC,UAAgB,EAAgB;wBAAd,YAAY,kBAAA;;;;;wCACpC,qBAAM,0BAAa,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAA;;oCAA5C,SAA4C,CAAC;oCAC3B,qBAAM,IAAA,8BAAmB,EAAC,YAAY,CAAC,EAAA;;oCAAnD,SAAS,GAAG,SAAuC;oCACxC,qBAAM,IAAA,+CAAuC,EAC5D,YAAY,CACb,EAAA;;oCAFK,QAAQ,GAAG,SAEhB;oCACD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;wCACzB,IAAA,cAAQ,EAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;wCACvC,sBAAO;qCACR;yCAEG,CAAA,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAA,EAArB,wBAAqB;oCACvB,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;;wCAGpB,qBAAM,IAAI,CAAC,MAAM,CAAC;wCAChB,IAAI,EAAE,MAAM;wCACZ,IAAI,EAAE,SAAS;wCACf,OAAO,EAAE,QAAQ;wCACjB,OAAO,EAAE,eAAe;qCACzB,CAAC,EAAA;;oCANJ,OAAO,GAAG,CACR,SAKE,CACH,CAAC,OAAO,CAAC;;wCAGZ,sBAAO,IAAA,uBAAe,EAAC,SAAS,EAAE,OAAO,CAAC,EAAC;;;;iBAC5C,CAAC,EAAA;;;KAAA,EAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
exports.__esModule = true;
|
|
42
|
+
var log_1 = require("../../../../utils/log");
|
|
43
|
+
var portForward_1 = require("../../../../utils/portForward");
|
|
44
|
+
var projects_1 = require("../../../../utils/projects");
|
|
45
|
+
var autocompletions_1 = require("../project/utils/autocompletions");
|
|
46
|
+
var ensureCluster_1 = __importDefault(require("../project/utils/ensureCluster"));
|
|
47
|
+
var utils_1 = require("./utils");
|
|
48
|
+
exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
return __generator(this, function (_c) {
|
|
51
|
+
switch (_c.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
_b = (_a = vorpal
|
|
54
|
+
.command("project-mongo-port-forward <envComponent>", "port foward to a mongodb"))
|
|
55
|
+
.autocomplete;
|
|
56
|
+
return [4 /*yield*/, (0, autocompletions_1.envAndComponents)()];
|
|
57
|
+
case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])
|
|
58
|
+
.action(function (_a) {
|
|
59
|
+
var envComponent = _a.envComponent;
|
|
60
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
var namespace, podNames, podName, localPort;
|
|
62
|
+
return __generator(this, function (_b) {
|
|
63
|
+
switch (_b.label) {
|
|
64
|
+
case 0: return [4 /*yield*/, ensureCluster_1["default"].call(this, envComponent)];
|
|
65
|
+
case 1:
|
|
66
|
+
_b.sent();
|
|
67
|
+
return [4 /*yield*/, (0, projects_1.getProjectNamespace)(envComponent)];
|
|
68
|
+
case 2:
|
|
69
|
+
namespace = _b.sent();
|
|
70
|
+
return [4 /*yield*/, (0, utils_1.getProjectMongodbAllPodsSortedWithLabel)(envComponent)];
|
|
71
|
+
case 3:
|
|
72
|
+
podNames = _b.sent();
|
|
73
|
+
if (podNames.length === 0) {
|
|
74
|
+
(0, log_1.logError)(this, "sorry, no pods found");
|
|
75
|
+
return [2 /*return*/];
|
|
76
|
+
}
|
|
77
|
+
if (!(podNames.length === 1)) return [3 /*break*/, 4];
|
|
78
|
+
podName = podNames[0].value;
|
|
79
|
+
return [3 /*break*/, 6];
|
|
80
|
+
case 4: return [4 /*yield*/, this.prompt({
|
|
81
|
+
type: "list",
|
|
82
|
+
name: "podName",
|
|
83
|
+
choices: podNames,
|
|
84
|
+
message: "Which pod? 🤔"
|
|
85
|
+
})];
|
|
86
|
+
case 5:
|
|
87
|
+
podName = (_b.sent()).podName;
|
|
88
|
+
_b.label = 6;
|
|
89
|
+
case 6: return [4 /*yield*/, this.prompt({
|
|
90
|
+
type: "number",
|
|
91
|
+
name: "localPort",
|
|
92
|
+
"default": "30000",
|
|
93
|
+
message: "Local port: "
|
|
94
|
+
})];
|
|
95
|
+
case 7:
|
|
96
|
+
localPort = (_b.sent()).localPort;
|
|
97
|
+
return [2 /*return*/, (0, portForward_1.startPortForward)(podName, localPort, 27017, namespace)];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
})];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}); });
|
|
105
|
+
//# sourceMappingURL=projectMongoPortForward.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectMongoPortForward.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/mongodb/projectMongoPortForward.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAiD;AACjD,6DAAiE;AACjE,uDAAiE;AACjE,oEAAoE;AACpE,iFAA2D;AAC3D,iCAAkE;AAElE,sBAAe,UAAO,MAAc;;;;;gBAClC,KAAA,CAAA,KAAA,MAAM;qBACH,OAAO,CACN,2CAA2C,EAC3C,0BAA0B,CAC3B,CAAA;qBACA,YAAY,CAAA;gBAAC,qBAAM,IAAA,kCAAgB,GAAE,EAAA;oBALxC,sBAAA,cAKgB,SAAwB,EAAC;qBACtC,MAAM,CAAC,UAAgB,EAAgB;wBAAd,YAAY,kBAAA;;;;;wCACpC,qBAAM,0BAAa,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAA;;oCAA5C,SAA4C,CAAC;oCAC3B,qBAAM,IAAA,8BAAmB,EAAC,YAAY,CAAC,EAAA;;oCAAnD,SAAS,GAAG,SAAuC;oCACxC,qBAAM,IAAA,+CAAuC,EAC5D,YAAY,CACb,EAAA;;oCAFK,QAAQ,GAAG,SAEhB;oCACD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;wCACzB,IAAA,cAAQ,EAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;wCACvC,sBAAO;qCACR;yCAEG,CAAA,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAA,EAArB,wBAAqB;oCACvB,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;;wCAG1B,qBAAM,IAAI,CAAC,MAAM,CAAC;wCAChB,IAAI,EAAE,MAAM;wCACZ,IAAI,EAAE,SAAS;wCACf,OAAO,EAAE,QAAQ;wCACjB,OAAO,EAAE,eAAe;qCACzB,CAAC,EAAA;;oCANJ,OAAO,GAAG,CACR,SAKE,CACH,CAAC,OAAO,CAAC;;wCAGU,qBAAM,IAAI,CAAC,MAAM,CAAC;wCACtC,IAAI,EAAE,QAAQ;wCACd,IAAI,EAAE,WAAW;wCACjB,SAAO,EAAE,OAAO;wCAChB,OAAO,EAAE,cAAc;qCACxB,CAAC,EAAA;;oCALM,SAAS,GAAK,CAAA,SAKpB,CAAA,UALe;oCAMjB,sBAAO,IAAA,8BAAgB,EAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,EAAC;;;;iBAC/D,CAAC,EAAA;;;KAAA,EAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const getProjectMongodbAllPods: (envComponent: string) => Promise<string[]>;
|
|
2
|
+
export declare const getMongodbShell: (namespace: string, podName: string) => Promise<void>;
|
|
3
|
+
export declare const executeMongodbCommand: (namespace: string, podName: string, mongoCommand: string) => Promise<any>;
|
|
4
|
+
export declare const podIsMaster: (namespace: string, podName: string) => Promise<any>;
|
|
5
|
+
export declare const getMongoDbPodsWithReplInfo: (envComponent: string) => Promise<{
|
|
6
|
+
podName: string;
|
|
7
|
+
componentName: string;
|
|
8
|
+
isMaster: any;
|
|
9
|
+
}[]>;
|
|
10
|
+
export declare const getProjectMongodbAllPodsSortedWithLabel: (envComponent: string) => Promise<{
|
|
11
|
+
value: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}[]>;
|