@catladder/cli 0.0.0-node16-ddfae617 → 0.0.0-prettier-cbceeed9
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/bin/catenv +1 -1
- package/bin/catenv-dev +3 -0
- package/bin/catladder +1 -1
- package/bin/catladder-dev +3 -0
- package/dist/apps/catenv/catenv.d.ts +4 -1
- package/dist/apps/catenv/catenv.js +28 -20
- package/dist/apps/catenv/catenv.js.map +1 -1
- package/dist/apps/cli/cli.js +4 -2
- package/dist/apps/cli/cli.js.map +1 -1
- package/dist/apps/cli/commands/{project/commandCopyDB.d.ts → cloudSQL/commandRestoreDb.d.ts} +1 -1
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js +192 -0
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +1 -0
- package/dist/apps/cli/commands/cloudSQL/index.d.ts +3 -0
- package/dist/apps/cli/commands/cloudSQL/index.js +50 -0
- package/dist/apps/cli/commands/cloudSQL/index.js.map +1 -0
- package/dist/apps/cli/commands/general/index.d.ts +1 -1
- package/dist/apps/cli/commands/general/index.js +11 -11
- package/dist/apps/cli/commands/general/index.js.map +1 -1
- package/dist/apps/cli/commands/general/portForward.d.ts +1 -1
- package/dist/apps/cli/commands/general/portForward.js +3 -3
- package/dist/apps/cli/commands/general/portForward.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/index.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +2 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +27 -11
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/utils/index.js +16 -4
- package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -1
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +109 -45
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +29 -51
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/apps/cli/commands/project/commandDeletePods.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandDeletePods.js +2 -1
- package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -1
- package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandEnvVars.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +1 -1
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -1
- package/dist/apps/cli/commands/project/commandGetShell.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetShell.js +2 -1
- package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -1
- package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
- package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandListPods.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandListPods.js +2 -2
- package/dist/apps/cli/commands/project/commandListPods.js.map +1 -1
- package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js +1 -2
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -1
- package/dist/apps/cli/commands/project/commandNamespace.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +2 -2
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenDashboard.js +19 -20
- package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGit.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGit.js +2 -7
- package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafana.js +2 -2
- package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +4 -3
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenLogs.js +7 -20
- package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -1
- package/dist/apps/cli/commands/project/commandPauseProject.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandPortForward.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandPortForward.js +98 -36
- package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -1
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
- package/dist/apps/cli/commands/project/commandSetup.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -1
- package/dist/apps/cli/commands/project/index.d.ts +1 -1
- package/dist/apps/cli/commands/project/index.js +2 -2
- package/dist/apps/cli/commands/project/index.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/index.d.ts +1 -1
- package/dist/apps/cli/commands/project/setup/index.js +11 -7
- package/dist/apps/cli/commands/project/setup/index.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -1
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +5 -4
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupCloudRun.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.js +118 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.js +56 -0
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
- package/dist/apps/cli/commands/project/setup/setupContext.js +17 -3
- package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js +12 -16
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupTopic.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.js +69 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -1
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
- package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -1
- package/dist/apps/cli/config/writeConfig.d.ts +2 -2
- package/dist/apps/cli/verify/index.d.ts +1 -1
- package/dist/apps/cli/verify/migration/fromv2.d.ts +1 -1
- package/dist/apps/cli/verify/migration/fromv2.js +2 -0
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
- package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +3 -3
- package/dist/apps/cli/verify/migration/migrateSecrets.js +4 -3
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +1 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.js +1 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -1
- package/dist/bundles/catenv/index.js +44895 -0
- package/dist/bundles/catenv/xdg-open +1066 -0
- package/dist/bundles/cli/clipboard_i686.exe +0 -0
- package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
- package/dist/bundles/cli/exec-child.js +39 -0
- package/dist/bundles/cli/index.js +358730 -0
- package/dist/bundles/cli/xdg-open +1066 -0
- package/dist/bundles/cli/xsel +0 -0
- package/dist/catenv.js +3 -3
- package/dist/catenv.js.map +1 -1
- package/dist/cli.js +0 -7
- package/dist/cli.js.map +1 -1
- package/dist/config/constants.d.ts +0 -1
- package/dist/config/constants.js +1 -2
- package/dist/config/constants.js.map +1 -1
- package/dist/config/getProjectConfig.d.ts +4 -7
- package/dist/config/getProjectConfig.js +21 -9
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/config/parseChoice.d.ts +4 -0
- package/dist/config/parseChoice.js +9 -0
- package/dist/config/parseChoice.js.map +1 -0
- package/dist/gcloud/artifactsRegistry.d.ts +5 -0
- package/dist/gcloud/artifactsRegistry.js +59 -0
- package/dist/gcloud/artifactsRegistry.js.map +1 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.d.ts +2 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +67 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.d.ts +3 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js +62 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -0
- package/dist/gcloud/enableServices.d.ts +3 -0
- package/dist/gcloud/enableServices.js +63 -0
- package/dist/gcloud/enableServices.js.map +1 -0
- package/dist/gcloud/openDashboard.d.ts +2 -0
- package/dist/{apps/cli/commands/shared/index.js → gcloud/openDashboard.js} +23 -27
- package/dist/gcloud/openDashboard.js.map +1 -0
- package/dist/gcloud/serviceAccounts.d.ts +12 -0
- package/dist/gcloud/serviceAccounts.js +144 -0
- package/dist/gcloud/serviceAccounts.js.map +1 -0
- package/dist/kubernetes/index.d.ts +3 -0
- package/dist/kubernetes/index.js +88 -0
- package/dist/kubernetes/index.js.map +1 -0
- package/dist/kubernetes/openKubernetesDashboards.d.ts +4 -0
- package/dist/kubernetes/openKubernetesDashboards.js +94 -0
- package/dist/kubernetes/openKubernetesDashboards.js.map +1 -0
- package/dist/kubernetes/portForward.d.ts +1 -0
- package/dist/kubernetes/portForward.js +55 -0
- package/dist/kubernetes/portForward.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/cluster.js +3 -8
- package/dist/utils/cluster.js.map +1 -1
- package/dist/utils/gitlab.d.ts +5 -3
- package/dist/utils/gitlab.js +165 -46
- package/dist/utils/gitlab.js.map +1 -1
- package/dist/utils/passwordstore/index.d.ts +0 -1
- package/dist/utils/passwordstore/index.js +1 -64
- package/dist/utils/passwordstore/index.js.map +1 -1
- package/dist/utils/portForwards.d.ts +12 -0
- package/dist/utils/{portForward.js → portForwards.js} +20 -16
- package/dist/utils/portForwards.js.map +1 -0
- package/dist/utils/projects/index.d.ts +0 -3
- package/dist/utils/projects/index.js +3 -53
- package/dist/utils/projects/index.js.map +1 -1
- package/package.json +24 -22
- package/scripts/bundle +4 -0
- package/src/apps/catenv/catenv.ts +15 -8
- package/src/apps/cli/cli.ts +3 -1
- package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +169 -0
- package/src/apps/cli/commands/cloudSQL/index.ts +8 -0
- package/src/apps/cli/commands/general/index.ts +11 -8
- package/src/apps/cli/commands/general/portForward.ts +4 -4
- package/src/apps/cli/commands/mongodb/index.ts +1 -1
- package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +3 -5
- package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +1 -1
- package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +18 -3
- package/src/apps/cli/commands/mongodb/utils/index.ts +19 -11
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +110 -37
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +12 -31
- package/src/apps/cli/commands/project/commandDeletePods.ts +3 -5
- package/src/apps/cli/commands/project/commandDeleteProject.ts +1 -1
- package/src/apps/cli/commands/project/commandEnvVars.ts +1 -1
- package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +2 -2
- package/src/apps/cli/commands/project/commandGetShell.ts +3 -5
- package/src/apps/cli/commands/project/commandGitlabCi.ts +2 -1
- package/src/apps/cli/commands/project/commandInitProject.old.ts +1 -1
- package/src/apps/cli/commands/project/commandListPods.ts +2 -2
- package/src/apps/cli/commands/project/commandMigrateHelm3.ts +4 -3
- package/src/apps/cli/commands/project/commandNamespace.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +3 -3
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +12 -32
- package/src/apps/cli/commands/project/commandOpenEnv.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenGit.ts +3 -3
- package/src/apps/cli/commands/project/commandOpenGrafana.ts +3 -3
- package/src/apps/cli/commands/project/commandOpenGrafanaPod.ts +5 -7
- package/src/apps/cli/commands/project/commandOpenLogs.ts +4 -35
- package/src/apps/cli/commands/project/commandPauseProject.ts +1 -1
- package/src/apps/cli/commands/project/commandPortForward.ts +75 -34
- package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
- package/src/apps/cli/commands/project/commandSetup.ts +1 -1
- package/src/apps/cli/commands/project/commandTriggerCronjob.ts +3 -2
- package/src/apps/cli/commands/project/index.ts +4 -3
- package/src/apps/cli/commands/project/setup/index.ts +3 -1
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +23 -11
- package/src/apps/cli/commands/project/setup/setupCloudRun.ts +84 -0
- package/src/apps/cli/commands/project/setup/setupCloudSQL.ts +22 -0
- package/src/apps/cli/commands/project/setup/setupContext.ts +12 -2
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +34 -27
- package/src/apps/cli/commands/project/setup/setupTopic.ts +22 -0
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +4 -2
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +1 -1
- package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +2 -2
- package/src/apps/cli/config/writeConfig.ts +2 -2
- package/src/apps/cli/verify/index.ts +1 -1
- package/src/apps/cli/verify/migration/fromv2.ts +5 -7
- package/src/apps/cli/verify/migration/migrateSecrets.ts +9 -4
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +2 -2
- package/src/catenv.ts +6 -3
- package/src/cli.ts +1 -7
- package/src/config/constants.ts +0 -2
- package/src/config/getProjectConfig.ts +14 -12
- package/src/config/parseChoice.ts +4 -0
- package/src/gcloud/artifactsRegistry.ts +16 -0
- package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +35 -0
- package/src/gcloud/cloudRun/openCloudRunDashboards.ts +22 -0
- package/src/gcloud/enableServices.ts +14 -0
- package/src/gcloud/openDashboard.ts +19 -0
- package/src/gcloud/serviceAccounts.ts +101 -0
- package/src/kubernetes/index.ts +27 -0
- package/src/kubernetes/openKubernetesDashboards.ts +52 -0
- package/src/kubernetes/portForward.ts +15 -0
- package/src/types/child-process-promise.d.ts +36 -1
- package/src/utils/cluster.ts +3 -3
- package/src/utils/gitlab.ts +137 -26
- package/src/utils/passwordstore/index.ts +2 -30
- package/src/utils/{portForward.ts → portForwards.ts} +27 -22
- package/src/utils/projects/index.ts +3 -24
- package/dist/apps/cli/commands/project/commandCopyDB.js +0 -102
- package/dist/apps/cli/commands/project/commandCopyDB.js.map +0 -1
- package/dist/apps/cli/commands/shared/index.d.ts +0 -3
- package/dist/apps/cli/commands/shared/index.js.map +0 -1
- package/dist/utils/portForward.d.ts +0 -4
- package/dist/utils/portForward.js.map +0 -1
- package/src/apps/cli/commands/project/commandCopyDB.ts +0 -91
- package/src/apps/cli/commands/shared/index.ts +0 -36
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -40,16 +36,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
40
36
|
}
|
|
41
37
|
};
|
|
42
38
|
exports.__esModule = true;
|
|
43
|
-
exports.
|
|
44
|
-
var zx_1 = require("zx");
|
|
39
|
+
exports.getProjectNamespace = exports.hasGitlabCiFile = exports.readRootGitlabCiFile = exports.getRootGitlabCiFile = exports.getGitRoot = void 0;
|
|
45
40
|
var path_1 = require("path");
|
|
46
41
|
var getProjectConfig_1 = require("../../config/getProjectConfig");
|
|
47
|
-
var k8sApi_1 = require("../../k8sApi");
|
|
48
42
|
var files_1 = require("../files");
|
|
43
|
+
var child_process_promise_1 = require("child-process-promise");
|
|
49
44
|
var getGitRoot = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
45
|
return __generator(this, function (_a) {
|
|
51
46
|
switch (_a.label) {
|
|
52
|
-
case 0: return [4 /*yield*/, (0,
|
|
47
|
+
case 0: return [4 /*yield*/, (0, child_process_promise_1.exec)("git rev-parse --show-toplevel")];
|
|
53
48
|
case 1: return [2 /*return*/, (_a.sent()).stdout.trim()];
|
|
54
49
|
}
|
|
55
50
|
});
|
|
@@ -105,49 +100,4 @@ var getProjectNamespace = function (envComponent) { return __awaiter(void 0, voi
|
|
|
105
100
|
});
|
|
106
101
|
}); };
|
|
107
102
|
exports.getProjectNamespace = getProjectNamespace;
|
|
108
|
-
var getProjectPods = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
-
var namespace, k8sApi, res;
|
|
110
|
-
return __generator(this, function (_a) {
|
|
111
|
-
switch (_a.label) {
|
|
112
|
-
case 0: return [4 /*yield*/, (0, exports.getProjectNamespace)(envComponent)];
|
|
113
|
-
case 1:
|
|
114
|
-
namespace = _a.sent();
|
|
115
|
-
k8sApi = (0, k8sApi_1.getk8sApi)();
|
|
116
|
-
return [4 /*yield*/, k8sApi.listNamespacedPod(namespace)];
|
|
117
|
-
case 2:
|
|
118
|
-
res = _a.sent();
|
|
119
|
-
return [2 /*return*/, res.body.items];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}); };
|
|
123
|
-
exports.getProjectPods = getProjectPods;
|
|
124
|
-
var getProjectPvcs = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
-
var namespace, k8sApi, res;
|
|
126
|
-
return __generator(this, function (_a) {
|
|
127
|
-
switch (_a.label) {
|
|
128
|
-
case 0: return [4 /*yield*/, (0, exports.getProjectNamespace)(envComponent)];
|
|
129
|
-
case 1:
|
|
130
|
-
namespace = _a.sent();
|
|
131
|
-
k8sApi = (0, k8sApi_1.getk8sApi)();
|
|
132
|
-
return [4 /*yield*/, k8sApi.listNamespacedPersistentVolumeClaim(namespace)];
|
|
133
|
-
case 2:
|
|
134
|
-
res = _a.sent();
|
|
135
|
-
return [2 /*return*/, res.body.items];
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}); };
|
|
139
|
-
exports.getProjectPvcs = getProjectPvcs;
|
|
140
|
-
var getProjectPodNames = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
|
|
141
|
-
var pods;
|
|
142
|
-
return __generator(this, function (_a) {
|
|
143
|
-
switch (_a.label) {
|
|
144
|
-
case 0: return [4 /*yield*/, (0, exports.getProjectPods)(envComponent)];
|
|
145
|
-
case 1:
|
|
146
|
-
pods = _a.sent();
|
|
147
|
-
return [2 /*return*/, pods.map(function (n) { return n.metadata.name; })];
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}); };
|
|
151
|
-
exports.getProjectPodNames = getProjectPodNames;
|
|
152
|
-
var templateObject_1;
|
|
153
103
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/projects/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/projects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4B;AAC5B,kEAA8E;AAE9E,kCAA2C;AAC3C,+DAA6C;AAEtC,IAAM,UAAU,GAAG;;;oBAChB,qBAAM,IAAA,4BAAI,EAAC,+BAA+B,CAAC,EAAA;oBAAnD,sBAAO,CAAC,SAA2C,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,EAAC;;;KACpE,CAAC;AAFW,QAAA,UAAU,cAErB;AAEK,IAAM,mBAAmB,GAAG;;;;oBACjB,qBAAM,IAAA,kBAAU,GAAE,EAAA;;gBAA5B,OAAO,GAAG,SAAkB;gBAClC,sBAAO,IAAA,WAAI,EAAC,OAAO,EAAE,gBAAgB,CAAC,EAAC;;;KACxC,CAAC;AAHW,QAAA,mBAAmB,uBAG9B;AAEK,IAAM,oBAAoB,GAAG;;;YAClC,KAAA,uBAAe,CAAA;YAAC,qBAAM,IAAA,2BAAmB,GAAE,EAAA;gBAA3C,sBAAA,kBAAgB,SAA2B,EAAC,EAAA;;SAAA,CAAC;AADlC,QAAA,oBAAoB,wBACc;AAExC,IAAM,eAAe,GAAG;;;;oBACP,qBAAM,IAAA,4BAAoB,GAAE,EAAA;;gBAA5C,KAAgB,SAA4B,EAA3C,KAAK,QAAA,EAAE,IAAI,QAAA;gBAClB,IAAI,KAAK,EAAE;oBACT,sBAAO,KAAK,EAAC;iBACd;gBACD,sBAAO,IAAI,EAAC;;;KACb,CAAC;AANW,QAAA,eAAe,mBAM1B;AAEK,IAAM,mBAAmB,GAAG,UAAO,YAAoB;;;;;gBACpD,GAAG,GAAK,IAAA,8BAAW,EAAC,YAAY,CAAC,IAA9B,CAA+B;gBAC3B,qBAAM,IAAA,mCAAgB,GAAE,EAAA;;gBAAjC,MAAM,GAAG,SAAwB;gBACvC,sBAAO,UAAG,MAAM,CAAC,YAAY,cAAI,MAAM,CAAC,OAAO,cAAI,GAAG,CAAE,EAAC;;;KAC1D,CAAC;AAJW,QAAA,mBAAmB,uBAI9B"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"lint": "eslint \"src/**/*.ts\"",
|
|
9
9
|
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
10
10
|
"test": "yarn run lint",
|
|
11
|
-
"build": "yarn
|
|
11
|
+
"build": "yarn build:compile && yarn build:bundle",
|
|
12
|
+
"build:bundle": "./scripts/bundle",
|
|
13
|
+
"build:compile": "yarn tsc",
|
|
12
14
|
"build:watch": "yarn tsc -w"
|
|
13
15
|
},
|
|
14
16
|
"bin": {
|
|
@@ -16,34 +18,19 @@
|
|
|
16
18
|
"catladder": "./bin/catladder"
|
|
17
19
|
},
|
|
18
20
|
"dependencies": {
|
|
19
|
-
"
|
|
20
|
-
"@kubernetes/client-node": "^0.16.2",
|
|
21
|
-
"child-process-promise": "^2.2.1",
|
|
22
|
-
"command-exists-promise": "^2.0.2",
|
|
23
|
-
"common-tags": "^1.8.0",
|
|
24
|
-
"dayjs": "^1.10.4",
|
|
25
|
-
"fs-extra": "^7.0.1",
|
|
26
|
-
"gitlab": "^4.4.1",
|
|
27
|
-
"js-yaml": "^4.1.0",
|
|
28
|
-
"lodash": "^4.17.21",
|
|
29
|
-
"memoizee": "^0.4.14",
|
|
30
|
-
"node-fetch": "^2.3.0",
|
|
31
|
-
"open": "^8.4.0",
|
|
32
|
-
"prettier": "^2.5.1",
|
|
33
|
-
"tmp-promise": "^2.0.2",
|
|
34
|
-
"update-notifier": "^2.5.0",
|
|
35
|
-
"vorpal": "^1.12.0",
|
|
36
|
-
"zx": "^4.3.0"
|
|
21
|
+
"ts-node": "^10.9.1"
|
|
37
22
|
},
|
|
38
23
|
"engines": {
|
|
39
24
|
"node": ">=12.0.0"
|
|
40
25
|
},
|
|
41
26
|
"devDependencies": {
|
|
27
|
+
"@catladder/pipeline": "0.0.0-prettier-cbceeed9",
|
|
28
|
+
"@kubernetes/client-node": "^0.16.2",
|
|
42
29
|
"@tsconfig/node14": "^1.0.1",
|
|
43
30
|
"@types/common-tags": "^1.8.0",
|
|
44
31
|
"@types/fs-extra": "^5.0.4",
|
|
45
32
|
"@types/js-yaml": "^4.0.5",
|
|
46
|
-
"@types/lodash": "^4.14.
|
|
33
|
+
"@types/lodash": "^4.14.185",
|
|
47
34
|
"@types/memoizee": "^0.4.2",
|
|
48
35
|
"@types/node-fetch": "^2.1.4",
|
|
49
36
|
"@types/request": "^2.48.1",
|
|
@@ -52,9 +39,24 @@
|
|
|
52
39
|
"@types/vorpal": "^1.12.0",
|
|
53
40
|
"@types/websocket": "^0.0.40",
|
|
54
41
|
"@types/yargs": "^13.0.0",
|
|
42
|
+
"child-process-promise": "^2.2.1",
|
|
43
|
+
"clipboardy": "^2.0.0",
|
|
44
|
+
"command-exists-promise": "^2.0.2",
|
|
45
|
+
"common-tags": "^1.8.0",
|
|
46
|
+
"dayjs": "^1.10.4",
|
|
55
47
|
"eslint": "^8.7.0",
|
|
56
|
-
"
|
|
48
|
+
"fs-extra": "^7.0.1",
|
|
49
|
+
"gitlab": "^4.4.1",
|
|
50
|
+
"js-yaml": "^4.1.0",
|
|
51
|
+
"lodash": "^4.17.21",
|
|
52
|
+
"memoizee": "^0.4.14",
|
|
53
|
+
"node-fetch": "^2.3.0",
|
|
54
|
+
"open": "^8.4.0",
|
|
55
|
+
"prettier": "^2.5.1",
|
|
56
|
+
"tmp-promise": "^2.0.2",
|
|
57
|
+
"typescript": "^4.5.4",
|
|
58
|
+
"vorpal": "^1.12.0"
|
|
57
59
|
},
|
|
58
|
-
"version": "0.0.0-
|
|
60
|
+
"version": "0.0.0-prettier-cbceeed9",
|
|
59
61
|
"stableVersion": "0.0.0"
|
|
60
62
|
}
|
package/scripts/bundle
ADDED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, ComponentConfig } from "@catladder/pipeline";
|
|
1
|
+
import type { Config, ComponentConfig } from "@catladder/pipeline";
|
|
2
2
|
import { getEnvVars, getProjectConfig } from "../../config/getProjectConfig";
|
|
3
3
|
import { getGitRoot } from "../../utils/projects";
|
|
4
4
|
import { join } from "path";
|
|
@@ -14,21 +14,29 @@ const getCurrentComponentName = async (
|
|
|
14
14
|
|
|
15
15
|
const sanitizeEnvVarName = (name: string) => name.replace(/[\s\-.]+/g, "_");
|
|
16
16
|
|
|
17
|
-
const getAllVariablesToPrint = async (
|
|
17
|
+
const getAllVariablesToPrint = async (
|
|
18
|
+
config: Config,
|
|
19
|
+
choice?: {
|
|
20
|
+
env?: string;
|
|
21
|
+
componentName?: string;
|
|
22
|
+
}
|
|
23
|
+
) => {
|
|
24
|
+
const env = choice?.env ?? "local";
|
|
18
25
|
const { components } = config;
|
|
19
26
|
|
|
20
|
-
const currentComponent =
|
|
27
|
+
const currentComponent =
|
|
28
|
+
choice?.componentName ?? (await getCurrentComponentName(components));
|
|
21
29
|
|
|
22
30
|
let variables = {};
|
|
23
31
|
if (currentComponent) {
|
|
24
|
-
variables = await getEnvVars(null,
|
|
32
|
+
variables = await getEnvVars(null, env, currentComponent);
|
|
25
33
|
} else {
|
|
26
34
|
// when in a monorep and not in a subapp, merge all env vars.
|
|
27
35
|
// this is not 100% correct, but better than not exporting any vars at all
|
|
28
36
|
// so we also add prefixed variants
|
|
29
37
|
variables = await Object.keys(components).reduce(
|
|
30
38
|
async (acc, componentName) => {
|
|
31
|
-
const subappvars = await getEnvVars(null,
|
|
39
|
+
const subappvars = await getEnvVars(null, env, componentName);
|
|
32
40
|
return {
|
|
33
41
|
...(await acc),
|
|
34
42
|
...subappvars,
|
|
@@ -46,13 +54,12 @@ const getAllVariablesToPrint = async (config: Config) => {
|
|
|
46
54
|
}
|
|
47
55
|
return variables;
|
|
48
56
|
};
|
|
49
|
-
export default async () => {
|
|
57
|
+
export default async (choice?: { env?: string; componentName?: string }) => {
|
|
50
58
|
const config = await getProjectConfig();
|
|
51
59
|
if (!config) {
|
|
52
60
|
return;
|
|
53
61
|
}
|
|
54
|
-
|
|
55
|
-
const variables = await getAllVariablesToPrint(config);
|
|
62
|
+
const variables = await getAllVariablesToPrint(config, choice);
|
|
56
63
|
|
|
57
64
|
console.log(
|
|
58
65
|
Object.entries(variables)
|
package/src/apps/cli/cli.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import Vorpal from "vorpal";
|
|
2
2
|
// tslint:disable-next-line:no-var-requires
|
|
3
3
|
import packageInfos from "../../packageInfos";
|
|
4
|
-
import { stopAllPortForwards } from "../../utils/
|
|
4
|
+
import { stopAllPortForwards } from "../../utils/portForwards";
|
|
5
5
|
import general from "./commands/general";
|
|
6
6
|
import mongodb from "./commands/mongodb";
|
|
7
|
+
import cloudSQL from "./commands/cloudSQL";
|
|
7
8
|
import project from "./commands/project";
|
|
8
9
|
import theStuffThatReallyMatters from "./commands/theStuffThatReallyMatters";
|
|
9
10
|
|
|
@@ -29,6 +30,7 @@ export default async () => {
|
|
|
29
30
|
|
|
30
31
|
general(vorpal);
|
|
31
32
|
project(vorpal);
|
|
33
|
+
cloudSQL(vorpal);
|
|
32
34
|
mongodb(vorpal);
|
|
33
35
|
theStuffThatReallyMatters(vorpal);
|
|
34
36
|
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { spawn } from "child-process-promise";
|
|
2
|
+
import type Vorpal from "vorpal";
|
|
3
|
+
|
|
4
|
+
const createProxy = async (instance: string, port: number) => {
|
|
5
|
+
const proxy = spawn(
|
|
6
|
+
`cloud_sql_proxy -instances ${instance}=tcp:${port}`,
|
|
7
|
+
[],
|
|
8
|
+
{ shell: "bash" }
|
|
9
|
+
);
|
|
10
|
+
// wait until it starts
|
|
11
|
+
await spawn(
|
|
12
|
+
`echo -n "Waiting for proxy"
|
|
13
|
+
until echo > /dev/tcp/localhost/${port}; do
|
|
14
|
+
sleep 0.2
|
|
15
|
+
echo -n "."
|
|
16
|
+
done 2>/dev/null`,
|
|
17
|
+
[],
|
|
18
|
+
{ shell: "bash" }
|
|
19
|
+
);
|
|
20
|
+
const stop = () => proxy.childProcess.kill();
|
|
21
|
+
process.on("beforeExit", stop);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
stop,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default async (vorpal: Vorpal) =>
|
|
29
|
+
vorpal
|
|
30
|
+
.command(
|
|
31
|
+
"cloud-sql-restore-db",
|
|
32
|
+
"restore a db from one source to another target"
|
|
33
|
+
)
|
|
34
|
+
.action(async function restoreDb() {
|
|
35
|
+
const { sourceInstance } = await this.prompt({
|
|
36
|
+
type: "input",
|
|
37
|
+
name: "sourceInstance",
|
|
38
|
+
|
|
39
|
+
message: "Source instance (connection string or 'local')? 🤔 ",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
let sourceProxy: { stop: () => void };
|
|
43
|
+
|
|
44
|
+
let targetProxy: { stop: () => void };
|
|
45
|
+
|
|
46
|
+
let sourcePort: number;
|
|
47
|
+
let targetPort: number;
|
|
48
|
+
|
|
49
|
+
if (sourceInstance === "local") {
|
|
50
|
+
const { sourceLocalPort } = await this.prompt({
|
|
51
|
+
type: "number",
|
|
52
|
+
name: "sourceLocalPort",
|
|
53
|
+
default: 5432,
|
|
54
|
+
|
|
55
|
+
message: "Local Port for source? 🤔 ",
|
|
56
|
+
});
|
|
57
|
+
sourcePort = sourceLocalPort;
|
|
58
|
+
} else {
|
|
59
|
+
sourcePort = 54399;
|
|
60
|
+
sourceProxy = await createProxy(sourceInstance, sourcePort);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const { sourceUsername } = await this.prompt({
|
|
64
|
+
type: "input",
|
|
65
|
+
name: "sourceUsername",
|
|
66
|
+
default: "postgres",
|
|
67
|
+
|
|
68
|
+
message: "Source Username? 🤔 ",
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const { sourcePassword } = await this.prompt({
|
|
72
|
+
type: "input",
|
|
73
|
+
name: "sourcePassword",
|
|
74
|
+
|
|
75
|
+
message: "Source Password? 🤔 ",
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const { sourceDbName } = await this.prompt({
|
|
79
|
+
type: "input",
|
|
80
|
+
name: "sourceDbName",
|
|
81
|
+
|
|
82
|
+
message: "Source DB name? 🤔 ",
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const { targetInstance } = await this.prompt({
|
|
86
|
+
type: "input",
|
|
87
|
+
name: "targetInstance",
|
|
88
|
+
|
|
89
|
+
message: "Targe INSTANCE (connection string or 'local')? 🤔 ",
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
if (targetInstance === "local") {
|
|
93
|
+
const { targetLocalPort } = await this.prompt({
|
|
94
|
+
type: "number",
|
|
95
|
+
name: "targetLocalPort",
|
|
96
|
+
default: 5432,
|
|
97
|
+
|
|
98
|
+
message: "Local Port for target? 🤔 ",
|
|
99
|
+
});
|
|
100
|
+
targetPort = targetLocalPort;
|
|
101
|
+
} else {
|
|
102
|
+
targetPort = 54499;
|
|
103
|
+
targetProxy = await createProxy(targetInstance, targetPort);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const { targetUsername } = await this.prompt({
|
|
107
|
+
type: "input",
|
|
108
|
+
name: "targetUsername",
|
|
109
|
+
default: "postgres",
|
|
110
|
+
|
|
111
|
+
message: "Target Username? 🤔 ",
|
|
112
|
+
});
|
|
113
|
+
const { targetPassword } = await this.prompt({
|
|
114
|
+
type: "input",
|
|
115
|
+
name: "targetPassword",
|
|
116
|
+
|
|
117
|
+
message: "Target Password? 🤔 ",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const { targetDbName } = await this.prompt({
|
|
121
|
+
type: "input",
|
|
122
|
+
name: "targetDbName",
|
|
123
|
+
|
|
124
|
+
message: "Target DB name? 🤔 ",
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const { shouldContinue } = await this.prompt({
|
|
128
|
+
type: "confirm",
|
|
129
|
+
name: "shouldContinue",
|
|
130
|
+
message: `This will drop ${targetInstance}/${targetDbName} and replace it with ${sourceInstance}/${sourceDbName}. Continue? 🤔 `,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (!shouldContinue) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const targetPSQL = (command: string) =>
|
|
138
|
+
`PGPASSWORD=${targetPassword} psql -p ${targetPort} --host=localhost --user=${targetUsername} -q ${command}`;
|
|
139
|
+
|
|
140
|
+
const copyDBScript = `
|
|
141
|
+
set -e
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
dumptmp=$(mktemp /tmp/dump.XXXXXX)
|
|
146
|
+
|
|
147
|
+
echo "Dumping file to $dumptmp"
|
|
148
|
+
pg_dump --dbname=postgres://${sourceUsername}:${sourcePassword}@localhost:${sourcePort}/${sourceDbName} --no-owner --no-privileges > $dumptmp
|
|
149
|
+
echo "dump done"
|
|
150
|
+
${targetPSQL(
|
|
151
|
+
`-c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`
|
|
152
|
+
)}
|
|
153
|
+
${targetPSQL(`-c 'create database "${targetDbName}"' 1> /dev/null`)}
|
|
154
|
+
echo "Restoring dump..."
|
|
155
|
+
${targetPSQL(`"${targetDbName}" < $dumptmp 1> /dev/null`)}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
echo "Clean up..."
|
|
159
|
+
set +e
|
|
160
|
+
rm $dumptmp
|
|
161
|
+
echo "\n🐱 Done!"
|
|
162
|
+
`;
|
|
163
|
+
try {
|
|
164
|
+
await spawn(copyDBScript, [], { shell: "bash", stdio: "inherit" });
|
|
165
|
+
} finally {
|
|
166
|
+
sourceProxy?.stop();
|
|
167
|
+
targetProxy?.stop();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import memoizee from "memoizee";
|
|
2
|
-
import Vorpal from "vorpal";
|
|
2
|
+
import type Vorpal from "vorpal";
|
|
3
3
|
import { getk8sApi } from "../../../../k8sApi";
|
|
4
4
|
import { getCurrentContext } from "../../../../utils/cluster";
|
|
5
5
|
import { logError } from "../../../../utils/log";
|
|
@@ -7,7 +7,7 @@ import { syncBitwarden } from "../../../../utils/passwordstore";
|
|
|
7
7
|
import {
|
|
8
8
|
getAllRunningPortForwards,
|
|
9
9
|
stopPortForward,
|
|
10
|
-
} from "../../../../utils/
|
|
10
|
+
} from "../../../../utils/portForwards";
|
|
11
11
|
import { getShell } from "../../../../utils/shell";
|
|
12
12
|
import { namespaceAutoCompletion } from "./namespaceAutoCompletion";
|
|
13
13
|
import portForward from "./portForward";
|
|
@@ -26,19 +26,19 @@ export const getAllNamespacesNames = async () => {
|
|
|
26
26
|
return namespaces.map((n) => n.metadata.name);
|
|
27
27
|
};
|
|
28
28
|
export default async (vorpal: Vorpal) => {
|
|
29
|
-
vorpal.command("current-context").action(async function () {
|
|
29
|
+
vorpal.command("kube-current-context").action(async function () {
|
|
30
30
|
this.log(await getCurrentContext());
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
vorpal
|
|
34
|
-
.command("list-namespaces", "list all namespaces")
|
|
34
|
+
.command("kube-list-namespaces", "list all namespaces")
|
|
35
35
|
.action(async function () {
|
|
36
36
|
const namespaces = await getAllNamespacesNames();
|
|
37
37
|
this.log(namespaces.join("\n"));
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
vorpal
|
|
41
|
-
.command("list-secrets <namespace>", "show secrets")
|
|
41
|
+
.command("kube-list-secrets <namespace>", "show secrets")
|
|
42
42
|
.autocomplete(namespaceAutoCompletion)
|
|
43
43
|
.action(async function ({ namespace }) {
|
|
44
44
|
const k8sApi = getk8sApi();
|
|
@@ -53,7 +53,7 @@ export default async (vorpal: Vorpal) => {
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
vorpal
|
|
56
|
-
.command("list-pods <namespace>", "list all pods of namespace")
|
|
56
|
+
.command("kube-list-pods <namespace>", "list all pods of namespace")
|
|
57
57
|
.autocomplete(namespaceAutoCompletion)
|
|
58
58
|
.action(async function ({ namespace }) {
|
|
59
59
|
const k8sApi = getk8sApi();
|
|
@@ -62,14 +62,17 @@ export default async (vorpal: Vorpal) => {
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
vorpal
|
|
65
|
-
.command("stop-portforward <name>", "stop a running port forward")
|
|
65
|
+
.command("kube-stop-portforward <name>", "stop a running port forward")
|
|
66
66
|
.autocomplete({ data: async () => getAllRunningPortForwards() })
|
|
67
67
|
.action(async function ({ name }) {
|
|
68
68
|
stopPortForward(name.trim());
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
vorpal
|
|
72
|
-
.command(
|
|
72
|
+
.command(
|
|
73
|
+
"kube-get-shell <namespace>",
|
|
74
|
+
"get a shell to a pod in the environment"
|
|
75
|
+
)
|
|
73
76
|
.autocomplete(namespaceAutoCompletion)
|
|
74
77
|
.action(async function ({ namespace }) {
|
|
75
78
|
const k8sApi = getk8sApi();
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import Vorpal from "vorpal";
|
|
1
|
+
import type Vorpal from "vorpal";
|
|
2
2
|
import { logError } from "../../../../utils/log";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { startKubePortForward } from "../../../../kubernetes/portForward";
|
|
5
5
|
|
|
6
6
|
import { getk8sApi } from "../../../../k8sApi";
|
|
7
7
|
import { namespaceAutoCompletion } from "./namespaceAutoCompletion";
|
|
8
8
|
|
|
9
9
|
export default async (vorpal: Vorpal) =>
|
|
10
10
|
vorpal
|
|
11
|
-
.command("port-forward <namespace>", "start port-forwarding")
|
|
11
|
+
.command("kube-port-forward <namespace>", "start port-forwarding")
|
|
12
12
|
.autocomplete(namespaceAutoCompletion)
|
|
13
13
|
.action(async function ({ namespace }) {
|
|
14
14
|
const k8sApi = getk8sApi();
|
|
@@ -44,5 +44,5 @@ export default async (vorpal: Vorpal) =>
|
|
|
44
44
|
message: "Remote port: ",
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
return
|
|
47
|
+
return startKubePortForward(podName, localPort, remotePort, namespace);
|
|
48
48
|
});
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { exec } from "child-process-promise";
|
|
2
|
-
import Vorpal from "vorpal";
|
|
2
|
+
import type Vorpal from "vorpal";
|
|
3
|
+
import { getProjectPvcs } from "../../../../kubernetes";
|
|
3
4
|
import { logError } from "../../../../utils/log";
|
|
4
|
-
import {
|
|
5
|
-
getProjectNamespace,
|
|
6
|
-
getProjectPvcs,
|
|
7
|
-
} from "../../../../utils/projects";
|
|
5
|
+
import { getProjectNamespace } from "../../../../utils/projects";
|
|
8
6
|
import { envAndComponents } from "../project/utils/autocompletions";
|
|
9
7
|
import ensureCluster from "../project/utils/ensureCluster";
|
|
10
8
|
import { getMongoDbPodsWithReplInfo } from "./utils";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import Vorpal from "vorpal";
|
|
1
|
+
import type Vorpal from "vorpal";
|
|
2
|
+
import { getEnvVars, parseChoice } from "../../../../config/getProjectConfig";
|
|
2
3
|
import { logError } from "../../../../utils/log";
|
|
3
|
-
import {
|
|
4
|
+
import { startKubePortForward } from "../../../../kubernetes/portForward";
|
|
4
5
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
5
6
|
import { envAndComponents } from "../project/utils/autocompletions";
|
|
6
7
|
import ensureCluster from "../project/utils/ensureCluster";
|
|
7
8
|
import { getProjectMongodbAllPodsSortedWithLabel } from "./utils";
|
|
9
|
+
import clipboard from "clipboardy";
|
|
8
10
|
|
|
9
11
|
export default async (vorpal: Vorpal) =>
|
|
10
12
|
vorpal
|
|
@@ -43,5 +45,18 @@ export default async (vorpal: Vorpal) =>
|
|
|
43
45
|
default: "30000",
|
|
44
46
|
message: "Local port: ",
|
|
45
47
|
});
|
|
46
|
-
|
|
48
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
49
|
+
const envVars = await getEnvVars(this, env, componentName);
|
|
50
|
+
const MONGODB_ROOT_PASSWORD = envVars?.MONGODB_ROOT_PASSWORD;
|
|
51
|
+
const connectionUrl = `mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:${localPort}`;
|
|
52
|
+
clipboard.writeSync(connectionUrl);
|
|
53
|
+
this.log("");
|
|
54
|
+
this.log("username: root");
|
|
55
|
+
this.log(`password: ${MONGODB_ROOT_PASSWORD}`);
|
|
56
|
+
this.log(`connection string: ${connectionUrl}`);
|
|
57
|
+
this.log("");
|
|
58
|
+
this.log("👆 connection string has been copied to your clipboard!");
|
|
59
|
+
this.log("");
|
|
60
|
+
|
|
61
|
+
return startKubePortForward(podName, localPort, 27017, namespace);
|
|
47
62
|
});
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { exec, spawn } from "child-process-promise";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
getProjectPodNames,
|
|
5
|
-
} from "../../../../../utils/projects";
|
|
2
|
+
import { getProjectPodNames } from "../../../../../kubernetes";
|
|
3
|
+
import { getProjectNamespace } from "../../../../../utils/projects";
|
|
6
4
|
|
|
7
5
|
const filterMongoDbs = (podNames: string[]) =>
|
|
8
|
-
podNames.filter(
|
|
6
|
+
podNames.filter(
|
|
7
|
+
(name) =>
|
|
8
|
+
name.includes("mongodb") &&
|
|
9
|
+
!name.includes("mongodb-backup") &&
|
|
10
|
+
!name.includes("arbiter")
|
|
11
|
+
);
|
|
9
12
|
|
|
10
13
|
export const getProjectMongodbAllPods = async (envComponent: string) =>
|
|
11
14
|
filterMongoDbs(await getProjectPodNames(envComponent));
|
|
@@ -43,13 +46,18 @@ export const executeMongodbCommand = async (
|
|
|
43
46
|
};
|
|
44
47
|
|
|
45
48
|
export const podIsMaster = async (namespace: string, podName: string) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
try {
|
|
50
|
+
const result = await executeMongodbCommand(
|
|
51
|
+
namespace,
|
|
52
|
+
podName,
|
|
53
|
+
"db.isMaster()"
|
|
54
|
+
);
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
return result.ismaster;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
// maybe shutting down ?
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
53
61
|
};
|
|
54
62
|
|
|
55
63
|
const spaces = (n: number) => " ".repeat(n);
|