@catladder/cli 0.0.0-test3 → 0.0.0-yarnrc-support-bdbef31f
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/.nvmrc +1 -1
- package/README.md +4 -2
- package/bin/catenv +3 -0
- package/bin/catladder +1 -1
- 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 +208 -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 +129 -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 +294 -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 +136 -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 +85 -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 +61 -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 +2 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js +106 -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 +3 -0
- package/dist/apps/cli/commands/shared/index.js +70 -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 +101 -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 +106 -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 +94 -0
- package/dist/apps/cli/verify/index.js.map +1 -0
- package/dist/apps/cli/verify/migration/fromv2.d.ts +4 -0
- package/dist/apps/cli/verify/migration/fromv2.js +345 -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 +18 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.js +30 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -0
- package/dist/catenv.d.ts +1 -0
- package/dist/catenv.js +10 -0
- package/dist/catenv.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +15 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/constants.d.ts +3 -0
- package/dist/config/constants.js +7 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/getProjectConfig.d.ts +24 -0
- package/dist/config/getProjectConfig.js +232 -0
- package/dist/config/getProjectConfig.js.map +1 -0
- package/dist/k8sApi/index.d.ts +6 -0
- package/dist/k8sApi/index.js +15 -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 +3 -0
- package/dist/utils/cluster.js +75 -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 +262 -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 +154 -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 +16 -21
- package/src/apps/catenv/catenv.ts +48 -27
- package/src/apps/{shell/shell.ts → cli/cli.ts} +10 -2
- package/src/apps/{shell → cli}/commands/general/index.ts +2 -40
- package/src/apps/{shell → cli}/commands/general/namespaceAutoCompletion.ts +0 -0
- package/src/apps/{shell → cli}/commands/general/portForward.ts +1 -1
- package/src/apps/{shell → cli}/commands/mongodb/index.ts +1 -1
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoDestroyMember.ts +18 -18
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoGetShell.ts +12 -10
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoPortForward.ts +13 -8
- package/src/apps/{shell → cli}/commands/mongodb/utils/index.ts +9 -8
- package/src/apps/{shell → cli}/commands/project/commandCloudSqlProxy.ts +26 -21
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +205 -0
- package/src/apps/{shell → cli}/commands/project/commandCopyDB.ts +24 -26
- package/src/apps/{shell → cli}/commands/project/commandDeletePods.ts +8 -9
- package/src/apps/{shell → cli}/commands/project/commandDeleteProject.ts +7 -8
- package/src/apps/cli/commands/project/commandEnvVars.ts +15 -0
- package/src/apps/{shell → cli}/commands/project/commandGetMyTotalWorktime.ts +2 -2
- package/src/apps/{shell → cli}/commands/project/commandGetShell.ts +10 -10
- package/src/apps/{shell → cli}/commands/project/commandGitlabCi.ts +1 -1
- package/src/apps/cli/commands/project/commandInitGitlab.ts +248 -0
- package/src/apps/{shell → cli}/commands/project/commandInitProject.ts +14 -6
- package/src/apps/cli/commands/project/commandListPods.ts +18 -0
- package/src/apps/{shell → cli}/commands/project/commandMigrateHelm3.ts +16 -7
- package/src/apps/cli/commands/project/commandNamespace.ts +14 -0
- package/src/apps/{shell → cli}/commands/project/commandOpenCostDashboard.ts +10 -7
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +48 -0
- package/src/apps/cli/commands/project/commandOpenEnv.ts +22 -0
- package/src/apps/{shell → cli}/commands/project/commandOpenGit.ts +3 -3
- package/src/apps/{shell → cli}/commands/project/commandOpenGrafana.ts +7 -7
- package/src/apps/{shell → cli}/commands/project/commandOpenGrafanaPod.ts +9 -10
- package/src/apps/cli/commands/project/commandOpenLogs.ts +52 -0
- package/src/apps/{shell → cli}/commands/project/commandPauseProject.ts +9 -7
- package/src/apps/{shell → cli}/commands/project/commandPortForward.ts +8 -8
- package/src/apps/cli/commands/project/commandReloadConfig.ts +12 -0
- package/src/apps/{shell → cli}/commands/project/commandTriggerCronjob.ts +7 -7
- package/src/apps/{shell → cli}/commands/project/index.ts +4 -3
- package/src/apps/cli/commands/project/utils/autocompletions.ts +26 -0
- package/src/apps/cli/commands/project/utils/ensureCluster.ts +42 -0
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +55 -0
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +11 -0
- package/src/apps/cli/commands/shared/index.ts +36 -0
- package/src/apps/{shell → cli}/commands/theStuffThatReallyMatters/index.ts +7 -26
- package/src/apps/cli/config/writeConfig.ts +71 -0
- package/src/apps/{shell → cli}/utils/getGoogleAuthUserNumber.ts +0 -0
- package/src/apps/cli/verify/index.ts +30 -0
- package/src/apps/cli/verify/migration/fromv2.ts +262 -0
- package/src/apps/cli/verify/migration/migrateSecrets.ts +37 -0
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +48 -0
- package/src/catenv.ts +4 -0
- package/src/cli.ts +9 -0
- package/src/config/constants.ts +0 -1
- package/src/config/getProjectConfig.ts +136 -0
- package/src/k8sApi/index.ts +5 -1
- package/src/types/types.ts +0 -2
- package/src/utils/cluster.ts +8 -15
- package/src/utils/editAsFile.ts +31 -0
- package/src/utils/files.ts +6 -2
- package/src/utils/gitlab.ts +133 -34
- package/src/utils/passwordstore/index.ts +19 -21
- package/src/utils/preferences/index.ts +6 -3
- package/src/utils/projects/index.ts +15 -136
- package/tsconfig.json +3 -7
- package/bin/catenv.sh +0 -1
- package/src/apps/shell/commands/project/commandConfigSecrets.ts +0 -245
- package/src/apps/shell/commands/project/commandEnvVars.ts +0 -17
- package/src/apps/shell/commands/project/commandInitGitlab.ts +0 -157
- package/src/apps/shell/commands/project/commandListPods.ts +0 -21
- package/src/apps/shell/commands/project/commandNamespace.ts +0 -12
- package/src/apps/shell/commands/project/commandOpenDashboard.ts +0 -27
- package/src/apps/shell/commands/project/commandOpenEnv.ts +0 -18
- package/src/apps/shell/commands/project/commandOpenLogs.ts +0 -23
- package/src/apps/shell/commands/project/commandVariables.ts +0 -13
- package/src/apps/shell/commands/project/utils/autocompletions.ts +0 -7
- package/src/apps/shell/commands/project/utils/ensureCluster.ts +0 -31
- package/src/apps/shell/commands/project/utils/ensureNamespace.ts +0 -32
- package/src/apps/shell/commands/project/utils/monorepo.ts +0 -45
- package/src/apps/shell/commands/shared/index.ts +0 -31
- package/src/config/clusters.ts +0 -45
- package/src/index.ts +0 -17
- package/src/types/git-repo-name.d.ts +0 -1
- package/src/types/yawn-yaml.d.ts +0 -1
- package/src/utils/dashboardToken.ts +0 -20
|
@@ -2,8 +2,6 @@ import memoizee from "memoizee";
|
|
|
2
2
|
import Vorpal from "vorpal";
|
|
3
3
|
import k8sApi from "../../../../k8sApi";
|
|
4
4
|
import {
|
|
5
|
-
connectToCluster,
|
|
6
|
-
getAllClusterNames,
|
|
7
5
|
getCurrentConnectedClusterName,
|
|
8
6
|
getCurrentContext,
|
|
9
7
|
} from "../../../../utils/cluster";
|
|
@@ -15,10 +13,7 @@ import {
|
|
|
15
13
|
} from "../../../../utils/portForward";
|
|
16
14
|
import { getShell } from "../../../../utils/shell";
|
|
17
15
|
import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
|
|
18
|
-
import {
|
|
19
|
-
openGoogleCloudKubernetesDashboard,
|
|
20
|
-
openGoogleCloudLogs,
|
|
21
|
-
} from "../shared";
|
|
16
|
+
import { openGoogleCloudLogs } from "../shared";
|
|
22
17
|
import { namespaceAutoCompletion } from "./namespaceAutoCompletion";
|
|
23
18
|
import portForward from "./portForward";
|
|
24
19
|
|
|
@@ -34,14 +29,7 @@ export const getAllNamespacesNames = async () => {
|
|
|
34
29
|
const namespaces = await getAllNamespaces();
|
|
35
30
|
return namespaces.map((n) => n.metadata.name);
|
|
36
31
|
};
|
|
37
|
-
export default (vorpal: Vorpal) => {
|
|
38
|
-
vorpal
|
|
39
|
-
.command("connect-cluster <clustername>")
|
|
40
|
-
.autocomplete(getAllClusterNames())
|
|
41
|
-
.action(async function ({ clustername }) {
|
|
42
|
-
this.log(`connecting to ${clustername}`);
|
|
43
|
-
await connectToCluster(clustername);
|
|
44
|
-
});
|
|
32
|
+
export default async (vorpal: Vorpal) => {
|
|
45
33
|
vorpal.command("current-context").action(async function () {
|
|
46
34
|
this.log(await getCurrentContext());
|
|
47
35
|
});
|
|
@@ -82,32 +70,6 @@ export default (vorpal: Vorpal) => {
|
|
|
82
70
|
stopPortForward(name.trim());
|
|
83
71
|
});
|
|
84
72
|
|
|
85
|
-
vorpal
|
|
86
|
-
.command("open-dashboard <namespace>", "open kubernetes dashboard")
|
|
87
|
-
.autocomplete(namespaceAutoCompletion)
|
|
88
|
-
.action(async function ({ namespace }) {
|
|
89
|
-
const clustername = await getCurrentConnectedClusterName();
|
|
90
|
-
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
91
|
-
|
|
92
|
-
await openGoogleCloudKubernetesDashboard(
|
|
93
|
-
authGoogleNumber,
|
|
94
|
-
clustername,
|
|
95
|
-
namespace
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
vorpal
|
|
99
|
-
.command(
|
|
100
|
-
"open-logs <namespace>",
|
|
101
|
-
"open google cloud logs (stackdriver stuff)"
|
|
102
|
-
)
|
|
103
|
-
.autocomplete(namespaceAutoCompletion)
|
|
104
|
-
.action(async function ({ namespace }) {
|
|
105
|
-
const clustername = await getCurrentConnectedClusterName();
|
|
106
|
-
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
107
|
-
|
|
108
|
-
await openGoogleCloudLogs(authGoogleNumber, clustername, namespace);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
73
|
vorpal
|
|
112
74
|
.command("get-shell <namespace>", "get a shell to a pod in the environment")
|
|
113
75
|
.autocomplete(namespaceAutoCompletion)
|
|
File without changes
|
|
@@ -6,7 +6,7 @@ import { startPortForward } from "../../../../utils/portForward";
|
|
|
6
6
|
import k8sApi from "../../../../k8sApi";
|
|
7
7
|
import { namespaceAutoCompletion } from "./namespaceAutoCompletion";
|
|
8
8
|
|
|
9
|
-
export default (vorpal: Vorpal) =>
|
|
9
|
+
export default async (vorpal: Vorpal) =>
|
|
10
10
|
vorpal
|
|
11
11
|
.command("port-forward <namespace>", "start port-forwarding")
|
|
12
12
|
.autocomplete(namespaceAutoCompletion)
|
|
@@ -3,7 +3,7 @@ import projectMongoDestroyMember from "./projectMongoDestroyMember";
|
|
|
3
3
|
import projectMongoGetShell from "./projectMongoGetShell";
|
|
4
4
|
import projectMongoPortForward from "./projectMongoPortForward";
|
|
5
5
|
|
|
6
|
-
export default (vorpal: Vorpal) => {
|
|
6
|
+
export default async (vorpal: Vorpal) => {
|
|
7
7
|
projectMongoGetShell(vorpal);
|
|
8
8
|
projectMongoPortForward(vorpal);
|
|
9
9
|
projectMongoDestroyMember(vorpal);
|
|
@@ -3,9 +3,9 @@ import Vorpal from "vorpal";
|
|
|
3
3
|
import { logError } from "../../../../utils/log";
|
|
4
4
|
import {
|
|
5
5
|
getProjectNamespace,
|
|
6
|
-
getProjectPvcs
|
|
6
|
+
getProjectPvcs,
|
|
7
7
|
} from "../../../../utils/projects";
|
|
8
|
-
import {
|
|
8
|
+
import { envAndComponents } from "../project/utils/autocompletions";
|
|
9
9
|
import ensureCluster from "../project/utils/ensureCluster";
|
|
10
10
|
import { getMongoDbPodsWithReplInfo } from "./utils";
|
|
11
11
|
|
|
@@ -31,18 +31,18 @@ const removeFinalizerAndDelete = async (
|
|
|
31
31
|
) => {
|
|
32
32
|
return Promise.all([
|
|
33
33
|
removeFinalizer(namespace, type, name),
|
|
34
|
-
await deleteResource(namespace, type, name)
|
|
34
|
+
await deleteResource(namespace, type, name),
|
|
35
35
|
]);
|
|
36
36
|
};
|
|
37
|
-
export default (vorpal: Vorpal) =>
|
|
37
|
+
export default async (vorpal: Vorpal) =>
|
|
38
38
|
vorpal
|
|
39
39
|
.command(
|
|
40
|
-
"project-mongo-destroy-member <
|
|
40
|
+
"project-mongo-destroy-member <envComponent>",
|
|
41
41
|
"DESTROY a member of a replicaset in order to reinitialize it"
|
|
42
42
|
)
|
|
43
|
-
.autocomplete(
|
|
44
|
-
.action(async function({
|
|
45
|
-
await ensureCluster.call(this);
|
|
43
|
+
.autocomplete(await envAndComponents())
|
|
44
|
+
.action(async function ({ envComponent }) {
|
|
45
|
+
await ensureCluster.call(this, envComponent);
|
|
46
46
|
this.log(
|
|
47
47
|
"this command tries to delete a (secondary) member of the replicaset, it's persistent volume claim (pvc) and the volume"
|
|
48
48
|
);
|
|
@@ -67,18 +67,18 @@ export default (vorpal: Vorpal) =>
|
|
|
67
67
|
default: true,
|
|
68
68
|
message: "DO YOU UNDERSTAND?",
|
|
69
69
|
name: "understood",
|
|
70
|
-
type: "confirm"
|
|
70
|
+
type: "confirm",
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
if (!understood) {
|
|
74
74
|
throw new Error("abort");
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const namespace = await getProjectNamespace(
|
|
78
|
-
const mongodbPods = await getMongoDbPodsWithReplInfo(
|
|
77
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
78
|
+
const mongodbPods = await getMongoDbPodsWithReplInfo(envComponent);
|
|
79
79
|
|
|
80
|
-
const pvcs = await getProjectPvcs(
|
|
81
|
-
const secondaries = mongodbPods.filter(pod => !pod.isMaster);
|
|
80
|
+
const pvcs = await getProjectPvcs(envComponent);
|
|
81
|
+
const secondaries = mongodbPods.filter((pod) => !pod.isMaster);
|
|
82
82
|
|
|
83
83
|
if (secondaries.length === 0) {
|
|
84
84
|
logError(this, "sorry, no pods found");
|
|
@@ -89,16 +89,16 @@ export default (vorpal: Vorpal) =>
|
|
|
89
89
|
await this.prompt({
|
|
90
90
|
type: "list",
|
|
91
91
|
name: "podName",
|
|
92
|
-
choices: secondaries.map(p => ({
|
|
92
|
+
choices: secondaries.map((p) => ({
|
|
93
93
|
name: `[ secondary ] ${p.podName}`,
|
|
94
|
-
value: p.podName
|
|
94
|
+
value: p.podName,
|
|
95
95
|
})),
|
|
96
|
-
message: "Which pod? 🤔"
|
|
96
|
+
message: "Which pod? 🤔",
|
|
97
97
|
})
|
|
98
98
|
).podName;
|
|
99
99
|
|
|
100
100
|
const thePvc = pvcs.find(
|
|
101
|
-
pvc => pvc.metadata.name === `datadir-${podName}`
|
|
101
|
+
(pvc) => pvc.metadata.name === `datadir-${podName}`
|
|
102
102
|
);
|
|
103
103
|
if (!thePvc) {
|
|
104
104
|
logError(this, `sorry, no pvc found for ${podName}`);
|
|
@@ -109,7 +109,7 @@ export default (vorpal: Vorpal) =>
|
|
|
109
109
|
message:
|
|
110
110
|
"THIS WILL DESTROY THE POD, ITS VOLUME AND ALL ITS DATA 🙀🙀🙀!!! continue? 🤔",
|
|
111
111
|
name: "shouldContinue",
|
|
112
|
-
type: "confirm"
|
|
112
|
+
type: "confirm",
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
if (!shouldContinue) {
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import Vorpal from "vorpal";
|
|
2
2
|
import { logError } from "../../../../utils/log";
|
|
3
3
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
4
|
-
import {
|
|
4
|
+
import { envAndComponents } from "../project/utils/autocompletions";
|
|
5
5
|
import ensureCluster from "../project/utils/ensureCluster";
|
|
6
6
|
import {
|
|
7
7
|
getMongodbShell,
|
|
8
|
-
getProjectMongodbAllPodsSortedWithLabel
|
|
8
|
+
getProjectMongodbAllPodsSortedWithLabel,
|
|
9
9
|
} from "./utils";
|
|
10
10
|
|
|
11
|
-
export default (vorpal: Vorpal) =>
|
|
11
|
+
export default async (vorpal: Vorpal) =>
|
|
12
12
|
vorpal
|
|
13
13
|
.command(
|
|
14
|
-
"project-mongo-get-shell <
|
|
14
|
+
"project-mongo-get-shell <envComponent>",
|
|
15
15
|
"get a shell to a mongodb in the environment"
|
|
16
16
|
)
|
|
17
|
-
.autocomplete(
|
|
18
|
-
.action(async function({
|
|
19
|
-
await ensureCluster.call(this);
|
|
20
|
-
const namespace = await getProjectNamespace(
|
|
21
|
-
const podNames = await getProjectMongodbAllPodsSortedWithLabel(
|
|
17
|
+
.autocomplete(await envAndComponents())
|
|
18
|
+
.action(async function ({ envComponent }) {
|
|
19
|
+
await ensureCluster.call(this, envComponent);
|
|
20
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
21
|
+
const podNames = await getProjectMongodbAllPodsSortedWithLabel(
|
|
22
|
+
envComponent
|
|
23
|
+
);
|
|
22
24
|
if (podNames.length === 0) {
|
|
23
25
|
logError(this, "sorry, no pods found");
|
|
24
26
|
return;
|
|
@@ -32,7 +34,7 @@ export default (vorpal: Vorpal) =>
|
|
|
32
34
|
type: "list",
|
|
33
35
|
name: "podName",
|
|
34
36
|
choices: podNames,
|
|
35
|
-
message: "Which pod? 🤔"
|
|
37
|
+
message: "Which pod? 🤔",
|
|
36
38
|
})
|
|
37
39
|
).podName;
|
|
38
40
|
}
|
|
@@ -2,18 +2,23 @@ import Vorpal from "vorpal";
|
|
|
2
2
|
import { logError } from "../../../../utils/log";
|
|
3
3
|
import { startPortForward } from "../../../../utils/portForward";
|
|
4
4
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
5
|
-
import {
|
|
5
|
+
import { envAndComponents } from "../project/utils/autocompletions";
|
|
6
6
|
import ensureCluster from "../project/utils/ensureCluster";
|
|
7
7
|
import { getProjectMongodbAllPodsSortedWithLabel } from "./utils";
|
|
8
8
|
|
|
9
|
-
export default (vorpal: Vorpal) =>
|
|
9
|
+
export default async (vorpal: Vorpal) =>
|
|
10
10
|
vorpal
|
|
11
|
-
.command(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
.command(
|
|
12
|
+
"project-mongo-port-forward <envComponent>",
|
|
13
|
+
"port foward to a mongodb"
|
|
14
|
+
)
|
|
15
|
+
.autocomplete(await envAndComponents())
|
|
16
|
+
.action(async function ({ envComponent }) {
|
|
17
|
+
await ensureCluster.call(this, envComponent);
|
|
18
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
19
|
+
const podNames = await getProjectMongodbAllPodsSortedWithLabel(
|
|
20
|
+
envComponent
|
|
21
|
+
);
|
|
17
22
|
if (podNames.length === 0) {
|
|
18
23
|
logError(this, "sorry, no pods found");
|
|
19
24
|
return;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { exec, spawn } from "child-process-promise";
|
|
2
|
-
import { Env } from "../../../../../types/types";
|
|
3
2
|
import {
|
|
4
3
|
getProjectNamespace,
|
|
5
4
|
getProjectPodNames,
|
|
@@ -8,8 +7,8 @@ import {
|
|
|
8
7
|
const filterMongoDbs = (podNames: string[]) =>
|
|
9
8
|
podNames.filter((name) => name.includes("mongodb-replicaset"));
|
|
10
9
|
|
|
11
|
-
export const getProjectMongodbAllPods = async (
|
|
12
|
-
filterMongoDbs(await getProjectPodNames(
|
|
10
|
+
export const getProjectMongodbAllPods = async (envComponent: string) =>
|
|
11
|
+
filterMongoDbs(await getProjectPodNames(envComponent));
|
|
13
12
|
|
|
14
13
|
export const getMongodbShell = async (namespace: string, podName: string) => {
|
|
15
14
|
const command = `kubectl exec -it ${podName} --namespace ${namespace} mongo`;
|
|
@@ -55,12 +54,12 @@ export const podIsMaster = async (namespace: string, podName: string) => {
|
|
|
55
54
|
|
|
56
55
|
const spaces = (n: number) => " ".repeat(n);
|
|
57
56
|
|
|
58
|
-
export const getMongoDbPodsWithReplInfo = async (
|
|
59
|
-
const namespace = await getProjectNamespace(
|
|
57
|
+
export const getMongoDbPodsWithReplInfo = async (envComponent: string) => {
|
|
58
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
60
59
|
return (
|
|
61
60
|
await Promise.all(
|
|
62
61
|
(
|
|
63
|
-
await getProjectMongodbAllPods(
|
|
62
|
+
await getProjectMongodbAllPods(envComponent)
|
|
64
63
|
).map(async (podName) => ({
|
|
65
64
|
podName,
|
|
66
65
|
componentName: podName.replace(/-mongodb-replicaset-[0-9]+/, ""),
|
|
@@ -70,8 +69,10 @@ export const getMongoDbPodsWithReplInfo = async (env: Env) => {
|
|
|
70
69
|
).sort((podA, podB) => (podA.isMaster ? (podB.isMaster ? 0 : -1) : 1));
|
|
71
70
|
};
|
|
72
71
|
|
|
73
|
-
export const getProjectMongodbAllPodsSortedWithLabel = async (
|
|
74
|
-
|
|
72
|
+
export const getProjectMongodbAllPodsSortedWithLabel = async (
|
|
73
|
+
envComponent: string
|
|
74
|
+
) => {
|
|
75
|
+
const pods = await getMongoDbPodsWithReplInfo(envComponent);
|
|
75
76
|
const maxComponentNameLength = Math.max(
|
|
76
77
|
...pods.map((c) => c.componentName.length)
|
|
77
78
|
);
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
1
2
|
import { spawn } from "child-process-promise";
|
|
2
3
|
import { writeFile } from "fs-extra";
|
|
3
4
|
import { withFile } from "tmp-promise";
|
|
4
5
|
import Vorpal from "vorpal";
|
|
6
|
+
import { GOOGLE_CLOUD_SQL_PASS_PATH } from "../../../../config/constants";
|
|
5
7
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
getEnvVars,
|
|
9
|
+
getPipelineContextByChoice,
|
|
10
|
+
getProjectConfig,
|
|
11
|
+
parseChoice,
|
|
12
|
+
} from "../../../../config/getProjectConfig";
|
|
9
13
|
import { readPass } from "../../../../utils/passwordstore";
|
|
10
|
-
import {
|
|
11
|
-
getAllEnvVars,
|
|
12
|
-
getLocalProjectVariables,
|
|
13
|
-
getProjectValues,
|
|
14
|
-
} from "../../../../utils/projects";
|
|
15
|
-
import { envAutocompletion } from "./utils/autocompletions";
|
|
16
|
-
import { promptForSubAppIfAny } from "./utils/monorepo";
|
|
14
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
17
15
|
|
|
18
|
-
export default (vorpal: Vorpal) =>
|
|
16
|
+
export default async (vorpal: Vorpal) =>
|
|
19
17
|
vorpal
|
|
20
|
-
.command("project-cloud-sql-proxy <
|
|
21
|
-
.autocomplete(
|
|
22
|
-
.action(async function ({
|
|
23
|
-
const {
|
|
18
|
+
.command("project-cloud-sql-proxy <envComponent>", "proxy to cloud sql db")
|
|
19
|
+
.autocomplete(await envAndComponents())
|
|
20
|
+
.action(async function ({ envComponent }) {
|
|
21
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
22
|
+
|
|
23
|
+
const config = await getProjectConfig();
|
|
24
24
|
// skynet-164509:europe-west6:pvl-cyclomania-review=tcp:5432
|
|
25
25
|
|
|
26
26
|
const { localPort } = await this.prompt({
|
|
@@ -30,18 +30,23 @@ export default (vorpal: Vorpal) =>
|
|
|
30
30
|
message: "Local port: ",
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
const POSTGRESQL_PASSWORD = (await getAllEnvVars(env, subapp))
|
|
33
|
+
const POSTGRESQL_PASSWORD = (await getEnvVars(this, env, componentName))
|
|
35
34
|
?.POSTGRESQL_PASSWORD;
|
|
36
35
|
|
|
37
|
-
const
|
|
38
|
-
|
|
36
|
+
const context = await getPipelineContextByChoice(env, componentName);
|
|
37
|
+
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
38
|
+
throw new Error("currently only supported for kubernetes deployment");
|
|
39
|
+
}
|
|
39
40
|
this.log(`postgres-PW: ${POSTGRESQL_PASSWORD}`);
|
|
40
41
|
this.log("");
|
|
41
42
|
|
|
42
|
-
const
|
|
43
|
+
const values = context.componentConfig.deploy.values;
|
|
44
|
+
|
|
45
|
+
const projectId =
|
|
46
|
+
values?.cloudsql?.projectId ||
|
|
47
|
+
context.componentConfig.deploy.cluster?.projectId;
|
|
43
48
|
|
|
44
|
-
const defaultInstanceId = `${
|
|
49
|
+
const defaultInstanceId = `${config.customerName}-${config.appName}-${env}`;
|
|
45
50
|
const instanceId = values?.cloudsql?.instanceId || defaultInstanceId;
|
|
46
51
|
|
|
47
52
|
const defaultRegion = "europe-west6"; // currently hardcoded
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/* eslint-disable no-constant-condition */
|
|
2
|
+
import { stripIndents } from "common-tags";
|
|
3
|
+
import { difference } from "lodash";
|
|
4
|
+
import Vorpal, { CommandInstance } from "vorpal";
|
|
5
|
+
import { GOOGLE_CLOUD_SQL_PASS_PATH } from "../../../../config/constants";
|
|
6
|
+
import {
|
|
7
|
+
getAllComponentsWithAllEnvsHierarchical,
|
|
8
|
+
getEnvironment,
|
|
9
|
+
getEnvVars,
|
|
10
|
+
getPipelineContextByChoice,
|
|
11
|
+
getProjectComponents,
|
|
12
|
+
parseChoice,
|
|
13
|
+
} from "../../../../config/getProjectConfig";
|
|
14
|
+
import { editAsFile } from "../../../../utils/editAsFile";
|
|
15
|
+
import { upsertAllVariables } from "../../../../utils/gitlab";
|
|
16
|
+
import { hasBitwarden, readPass } from "../../../../utils/passwordstore";
|
|
17
|
+
import { delay } from "../../../../utils/promise";
|
|
18
|
+
import { allEnvsAndAllComponents } from "./utils/autocompletions";
|
|
19
|
+
|
|
20
|
+
type Vars = {
|
|
21
|
+
[env: string]: {
|
|
22
|
+
[componentName: string]: Record<string, string>;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/* for convenience, parse json objects. that makes it easier to edit secrets that are object */
|
|
26
|
+
const resolveJson = (v: Vars) =>
|
|
27
|
+
Object.fromEntries(
|
|
28
|
+
Object.entries(v).map(([componentName, envs]) => {
|
|
29
|
+
return [
|
|
30
|
+
componentName,
|
|
31
|
+
Object.fromEntries(
|
|
32
|
+
Object.entries(envs).map(([env, secrets]) => [
|
|
33
|
+
env,
|
|
34
|
+
Object.fromEntries(
|
|
35
|
+
Object.entries(secrets).map(([key, value]) => {
|
|
36
|
+
try {
|
|
37
|
+
return [key, JSON.parse(value)];
|
|
38
|
+
} catch (e) {
|
|
39
|
+
return [key, value];
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
),
|
|
43
|
+
])
|
|
44
|
+
),
|
|
45
|
+
];
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
const getEnvVarsToEdit = async (
|
|
49
|
+
instance: CommandInstance,
|
|
50
|
+
env: string,
|
|
51
|
+
componentName: string
|
|
52
|
+
) => {
|
|
53
|
+
const { secretEnvVarKeys } = await getEnvironment(env, componentName);
|
|
54
|
+
|
|
55
|
+
const allEnvVars = await getEnvVars(instance, env, componentName);
|
|
56
|
+
return Object.fromEntries(
|
|
57
|
+
secretEnvVarKeys.map((key) => [key, allEnvVars[key]])
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
const doItFor = async (
|
|
61
|
+
instance: CommandInstance,
|
|
62
|
+
envAndComponents: {
|
|
63
|
+
[componentName: string]: string[];
|
|
64
|
+
}
|
|
65
|
+
) => {
|
|
66
|
+
let valuesToEdit: Vars = Object.fromEntries(
|
|
67
|
+
await Promise.all(
|
|
68
|
+
Object.entries(envAndComponents).map(async ([componentName, envs]) => [
|
|
69
|
+
componentName,
|
|
70
|
+
Object.fromEntries(
|
|
71
|
+
await Promise.all(
|
|
72
|
+
envs.map(async (env) => [
|
|
73
|
+
env,
|
|
74
|
+
await getEnvVarsToEdit(instance, env, componentName),
|
|
75
|
+
])
|
|
76
|
+
)
|
|
77
|
+
),
|
|
78
|
+
])
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
let hasErrors = true;
|
|
82
|
+
while (hasErrors) {
|
|
83
|
+
valuesToEdit = await editAsFile(
|
|
84
|
+
resolveJson(valuesToEdit),
|
|
85
|
+
stripIndents`
|
|
86
|
+
Please fill in all secrets for:
|
|
87
|
+
|
|
88
|
+
${Object.entries(envAndComponents)
|
|
89
|
+
.map(
|
|
90
|
+
([componentName, envs]) => `- ${componentName}: ${envs.join(", ")}`
|
|
91
|
+
)
|
|
92
|
+
.join("\n")}
|
|
93
|
+
|
|
94
|
+
`
|
|
95
|
+
);
|
|
96
|
+
// check for errors
|
|
97
|
+
hasErrors = false;
|
|
98
|
+
for (const [componentName, envs] of Object.entries(envAndComponents)) {
|
|
99
|
+
for (const env of envs) {
|
|
100
|
+
const usedKeys = valuesToEdit[componentName][env]
|
|
101
|
+
? Object.keys(valuesToEdit[componentName][env])
|
|
102
|
+
: [];
|
|
103
|
+
// check whether newValues have the exact number of keys
|
|
104
|
+
const { secretEnvVarKeys } = await getEnvironment(env, componentName);
|
|
105
|
+
const extranous = difference(usedKeys, secretEnvVarKeys);
|
|
106
|
+
const missing = difference(secretEnvVarKeys, usedKeys);
|
|
107
|
+
|
|
108
|
+
if (extranous.length > 0 || missing.length > 0) {
|
|
109
|
+
instance.log("");
|
|
110
|
+
instance.log(
|
|
111
|
+
`😿 Oh no! There is something wrong with "${componentName}"`
|
|
112
|
+
);
|
|
113
|
+
instance.log("");
|
|
114
|
+
if (extranous.length > 0) {
|
|
115
|
+
instance.log("these secrets are not declared in the config");
|
|
116
|
+
extranous.forEach((key) => instance.log(key));
|
|
117
|
+
instance.log("");
|
|
118
|
+
}
|
|
119
|
+
if (missing.length > 0) {
|
|
120
|
+
instance.log("these secrets have not been provided:");
|
|
121
|
+
missing.forEach((key) => instance.log(key));
|
|
122
|
+
instance.log("");
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
await delay(1000);
|
|
126
|
+
const { shouldContinue } = await instance.prompt({
|
|
127
|
+
default: true,
|
|
128
|
+
message: "Try again? 🤔",
|
|
129
|
+
name: "shouldContinue",
|
|
130
|
+
type: "confirm",
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (!shouldContinue) {
|
|
134
|
+
throw new Error("abort");
|
|
135
|
+
}
|
|
136
|
+
hasErrors = true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
for (const [componentName, envs] of Object.entries(envAndComponents)) {
|
|
142
|
+
for (const env of envs) {
|
|
143
|
+
await upsertAllVariables(
|
|
144
|
+
instance,
|
|
145
|
+
valuesToEdit[componentName][env],
|
|
146
|
+
env,
|
|
147
|
+
componentName
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
if (hasBitwarden()) {
|
|
151
|
+
// add cloud sql secret if needed.
|
|
152
|
+
// TODO: this is legacy, in the future we want to have one service account per app
|
|
153
|
+
|
|
154
|
+
const context = await getPipelineContextByChoice(env, componentName);
|
|
155
|
+
if (
|
|
156
|
+
context.componentConfig.deploy &&
|
|
157
|
+
context.componentConfig.deploy.values?.cloudsql?.enabled
|
|
158
|
+
) {
|
|
159
|
+
await upsertAllVariables(
|
|
160
|
+
instance,
|
|
161
|
+
{
|
|
162
|
+
cloudsqlProxyCredentials: await readPass(
|
|
163
|
+
GOOGLE_CLOUD_SQL_PASS_PATH
|
|
164
|
+
),
|
|
165
|
+
},
|
|
166
|
+
env,
|
|
167
|
+
componentName
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export default async (vorpal: Vorpal) => {
|
|
176
|
+
vorpal
|
|
177
|
+
.command(
|
|
178
|
+
"project-config-secrets [envComponent]",
|
|
179
|
+
"setup/update secrets stored in pass"
|
|
180
|
+
)
|
|
181
|
+
.autocomplete(await allEnvsAndAllComponents())
|
|
182
|
+
.action(async function ({ envComponent }) {
|
|
183
|
+
if (!envComponent) {
|
|
184
|
+
const allEnvAndcomponents =
|
|
185
|
+
await getAllComponentsWithAllEnvsHierarchical();
|
|
186
|
+
await doItFor(this, allEnvAndcomponents);
|
|
187
|
+
} else {
|
|
188
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
189
|
+
|
|
190
|
+
// componentName can be null. in this case, iterate over all components
|
|
191
|
+
if (!componentName) {
|
|
192
|
+
const components = await getProjectComponents();
|
|
193
|
+
await doItFor(
|
|
194
|
+
this,
|
|
195
|
+
Object.fromEntries(components.map((c) => [c, [env]]))
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
if (componentName) {
|
|
199
|
+
await doItFor(this, {
|
|
200
|
+
[componentName]: [env],
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
};
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import { spawn } from "child-process-promise";
|
|
2
2
|
import Vorpal from "vorpal";
|
|
3
|
+
import { GOOGLE_CLOUD_SQL_PASS_PATH } from "../../../../config/constants";
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
getEnvVars,
|
|
6
|
+
getProjectConfig,
|
|
7
|
+
parseChoice,
|
|
8
|
+
} from "../../../../config/getProjectConfig";
|
|
7
9
|
import { readPass } from "../../../../utils/passwordstore";
|
|
8
|
-
import {
|
|
9
|
-
getAllEnvVars,
|
|
10
|
-
getLocalProjectVariables,
|
|
11
|
-
} from "../../../../utils/projects";
|
|
12
|
-
import { envAutocompletion } from "./utils/autocompletions";
|
|
13
|
-
import { promptForSubAppIfAny } from "./utils/monorepo";
|
|
10
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
14
11
|
|
|
15
|
-
export default (vorpal: Vorpal) =>
|
|
12
|
+
export default async (vorpal: Vorpal) =>
|
|
16
13
|
vorpal
|
|
17
|
-
.command(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = await
|
|
14
|
+
.command(
|
|
15
|
+
"copy-db <envComponent>",
|
|
16
|
+
"replace local db with the one from an env"
|
|
17
|
+
)
|
|
18
|
+
.autocomplete(await envAndComponents())
|
|
19
|
+
.action(async function copyDB({ envComponent }) {
|
|
20
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
21
|
+
const { customerName, appName } = await getProjectConfig();
|
|
25
22
|
|
|
26
23
|
const { shouldContinue } = await this.prompt({
|
|
27
24
|
type: "confirm",
|
|
@@ -34,15 +31,18 @@ export default (vorpal: Vorpal) =>
|
|
|
34
31
|
return;
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
// TODO: reimpleent with new config
|
|
35
|
+
throw new Error("needs reimplementation with new config");
|
|
39
36
|
const GOOGLE_CLOUD_SQL_REGION = "europe-west6"; // currently hardcoded
|
|
40
|
-
const POSTGRESQL_PASSWORD =
|
|
41
|
-
|
|
37
|
+
const { POSTGRESQL_PASSWORD } = await getEnvVars(
|
|
38
|
+
this,
|
|
39
|
+
env,
|
|
40
|
+
componentName
|
|
41
|
+
);
|
|
42
42
|
|
|
43
43
|
const LOCAL_PORT = 54321;
|
|
44
44
|
|
|
45
|
-
const instanceName = `${
|
|
45
|
+
const instanceName = `${"xxxxxx reimplement shoulld be project id"}:${GOOGLE_CLOUD_SQL_REGION}:${customerName}-${appName}-${env}=tcp:${LOCAL_PORT}`;
|
|
46
46
|
const cloudsqlCredentials = await readPass(GOOGLE_CLOUD_SQL_PASS_PATH);
|
|
47
47
|
|
|
48
48
|
const { POSTGRESQL_URL } = process.env;
|
|
@@ -72,9 +72,7 @@ export default (vorpal: Vorpal) =>
|
|
|
72
72
|
dumptmp=$(mktemp /tmp/dump.XXXXXX)
|
|
73
73
|
|
|
74
74
|
echo "Dumping file to $dumptmp"
|
|
75
|
-
pg_dump --dbname=postgres://postgres:${POSTGRESQL_PASSWORD}@localhost:${LOCAL_PORT}/${
|
|
76
|
-
subapp ?? COMPONENT_NAME
|
|
77
|
-
} --no-owner --no-privileges > $dumptmp
|
|
75
|
+
pg_dump --dbname=postgres://postgres:${POSTGRESQL_PASSWORD}@localhost:${LOCAL_PORT}/${componentName} --no-owner --no-privileges > $dumptmp
|
|
78
76
|
psql -q -c "drop database ${localDBName}" 1> /dev/null
|
|
79
77
|
psql -q -c "create database ${localDBName}" 1> /dev/null
|
|
80
78
|
echo "Restoring dump..."
|