@catladder/cli 0.0.0-test4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -1
- 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 +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/dashboardToken.d.ts +2 -0
- package/dist/utils/dashboardToken.js +89 -0
- package/dist/utils/dashboardToken.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 +10 -11
- package/src/apps/catenv/catenv.ts +48 -27
- package/src/apps/{shell/shell.ts → cli/cli.ts} +12 -2
- package/src/apps/{shell → cli}/commands/general/index.ts +1 -1
- 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 +23 -17
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +204 -0
- package/src/apps/{shell → cli}/commands/project/commandCopyDB.ts +22 -23
- 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 +203 -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 +45 -0
- package/src/apps/cli/commands/project/commandOpenEnv.ts +22 -0
- package/src/apps/{shell → cli}/commands/project/commandOpenGit.ts +1 -1
- 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/{shell → cli}/commands/project/commandOpenLogs.ts +7 -7
- 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 +37 -0
- package/src/apps/{shell → cli}/commands/project/utils/ensureNamespace.ts +2 -3
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +11 -0
- package/src/apps/{shell → cli}/commands/shared/index.ts +0 -0
- package/src/apps/{shell → cli}/commands/theStuffThatReallyMatters/index.ts +11 -11
- package/src/apps/cli/config/writeConfig.ts +69 -0
- package/src/apps/{shell → cli}/utils/getGoogleAuthUserNumber.ts +0 -0
- package/src/apps/cli/verify/index.ts +34 -0
- package/src/apps/cli/verify/migration/fromv2.ts +242 -0
- package/src/apps/cli/verify/migration/migrateSecrets.ts +37 -0
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +43 -0
- package/src/catenv.ts +3 -0
- package/src/cli.ts +8 -0
- package/src/config/getProjectConfig.ts +118 -0
- package/src/types/types.ts +0 -2
- package/src/utils/cluster.ts +15 -2
- package/src/utils/editAsFile.ts +31 -0
- package/src/utils/files.ts +6 -2
- package/src/utils/gitlab.ts +126 -32
- package/src/utils/passwordstore/index.ts +19 -21
- package/src/utils/preferences/index.ts +6 -3
- package/src/utils/projects/index.ts +14 -134
- 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/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/monorepo.ts +0 -45
- package/src/index.ts +0 -17
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
2
|
+
import open from "open";
|
|
3
|
+
import Vorpal from "vorpal";
|
|
4
|
+
import { getAllPipelineContexts } from "../../../../config/getProjectConfig";
|
|
5
|
+
import {
|
|
6
|
+
getClusterByFullName,
|
|
7
|
+
getClusterByName,
|
|
8
|
+
} from "../../../../utils/cluster";
|
|
9
|
+
import { doGitlabRequest, getProjectInfo } from "../../../../utils/gitlab";
|
|
10
|
+
import { readPass } from "../../../../utils/passwordstore";
|
|
11
|
+
import { getProjectNamespace } from "../../../../utils/projects";
|
|
12
|
+
|
|
13
|
+
export default async (vorpal: Vorpal) =>
|
|
14
|
+
vorpal
|
|
15
|
+
.command(
|
|
16
|
+
"project-init-gitlab",
|
|
17
|
+
"Initializes the gitlab repo, e.g. connects the cluster to it"
|
|
18
|
+
)
|
|
19
|
+
.action(async function () {
|
|
20
|
+
const { id: projectId, web_url: projectWebUrl } = await getProjectInfo(
|
|
21
|
+
this
|
|
22
|
+
);
|
|
23
|
+
const existingGitlabClusters = await doGitlabRequest<{ name: string }[]>(
|
|
24
|
+
this,
|
|
25
|
+
`projects/${projectId}/clusters`
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const existingClusters = existingGitlabClusters.map(
|
|
29
|
+
(c: { name: string }) => {
|
|
30
|
+
const found = getClusterByFullName(c.name);
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
name: found ? found.name : null,
|
|
34
|
+
fullName: c.name,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (existingClusters.length === 0) {
|
|
40
|
+
this.log("");
|
|
41
|
+
this.log("there is no cluster on the current project?");
|
|
42
|
+
} else {
|
|
43
|
+
this.log("there are already these clusters on the gitlab: ");
|
|
44
|
+
this.log("");
|
|
45
|
+
existingClusters.forEach((cluster) =>
|
|
46
|
+
this.log(` - ${cluster.name || "unknown"} (${cluster.fullName})`)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
this.log("");
|
|
51
|
+
this.log("your project specifies the following clusters:");
|
|
52
|
+
this.log("");
|
|
53
|
+
const allContext = await getAllPipelineContexts();
|
|
54
|
+
const allDeployments = allContext.map((c) => c.componentConfig.deploy);
|
|
55
|
+
|
|
56
|
+
const configuredClusterNames = allDeployments.reduce<string[]>(
|
|
57
|
+
(acc, c) => {
|
|
58
|
+
if (
|
|
59
|
+
isOfDeployType(c, "kubernetes") &&
|
|
60
|
+
!acc.includes(c.cluster || "production")
|
|
61
|
+
) {
|
|
62
|
+
return [...acc, c.cluster || "production"];
|
|
63
|
+
}
|
|
64
|
+
return acc;
|
|
65
|
+
},
|
|
66
|
+
[]
|
|
67
|
+
);
|
|
68
|
+
const configuredClusters = configuredClusterNames.map((c) => ({
|
|
69
|
+
name: c,
|
|
70
|
+
config: getClusterByName(c),
|
|
71
|
+
}));
|
|
72
|
+
configuredClusters.forEach((cluster) =>
|
|
73
|
+
this.log(` - ${cluster.name || "unknown"} (${cluster.config.fullName})`)
|
|
74
|
+
);
|
|
75
|
+
this.log("");
|
|
76
|
+
|
|
77
|
+
const missingClusters = configuredClusters.filter(
|
|
78
|
+
(c) => !existingClusters.some((exist) => exist.name === c.name)
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
this.log("");
|
|
82
|
+
this.log("These clusters are not configured yet on gitlab:");
|
|
83
|
+
this.log("");
|
|
84
|
+
|
|
85
|
+
missingClusters.forEach((cluster) =>
|
|
86
|
+
this.log(` - ${cluster.name || "unknown"} (${cluster.config.fullName})`)
|
|
87
|
+
);
|
|
88
|
+
this.log("");
|
|
89
|
+
|
|
90
|
+
for (const cluster of missingClusters) {
|
|
91
|
+
this.log(`${cluster} (${cluster.config.fullName})`);
|
|
92
|
+
this.log("");
|
|
93
|
+
const { shouldContinue } = await this.prompt({
|
|
94
|
+
type: "confirm",
|
|
95
|
+
name: "shouldContinue",
|
|
96
|
+
message: "Should I add the this cluster ? 🤔 ",
|
|
97
|
+
});
|
|
98
|
+
this.log("");
|
|
99
|
+
if (shouldContinue) {
|
|
100
|
+
const { api_url, passCredentials } = cluster.config;
|
|
101
|
+
if (!api_url) {
|
|
102
|
+
throw new Error("no api_url on this cluster!");
|
|
103
|
+
}
|
|
104
|
+
if (!passCredentials) {
|
|
105
|
+
throw new Error("no passCredentials on this cluster!");
|
|
106
|
+
}
|
|
107
|
+
const token = await readPass(passCredentials.token);
|
|
108
|
+
const ca_cert = await readPass(passCredentials.ca_cert);
|
|
109
|
+
|
|
110
|
+
const postResult = await doGitlabRequest(
|
|
111
|
+
this,
|
|
112
|
+
`projects/${projectId}/clusters/user`,
|
|
113
|
+
{
|
|
114
|
+
name: cluster.config.fullName,
|
|
115
|
+
managed: false,
|
|
116
|
+
platform_kubernetes_attributes: {
|
|
117
|
+
api_url,
|
|
118
|
+
ca_cert,
|
|
119
|
+
token,
|
|
120
|
+
namespace: await getProjectNamespace("prod"),
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
const { message } = postResult;
|
|
125
|
+
if (message) {
|
|
126
|
+
this.log(`Message from gitlab: ${message}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const variables = await doGitlabRequest(
|
|
132
|
+
this,
|
|
133
|
+
`projects/${projectId}/variables`
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
if (!variables.find((v: any) => v.key === "GL_TOKEN")) {
|
|
137
|
+
this.log(
|
|
138
|
+
"I need add a GL_TOKEN to the project, so that semantic release will work\n"
|
|
139
|
+
);
|
|
140
|
+
this.log(
|
|
141
|
+
"👉 Please please create a project access token in gitlab and copy its value into clipboard\n\n - name: something like 'semantic-release'\n - expires: leave empty\n - scopes: api, read_repository"
|
|
142
|
+
);
|
|
143
|
+
this.log("\n");
|
|
144
|
+
|
|
145
|
+
const { understood } = await this.prompt({
|
|
146
|
+
default: true,
|
|
147
|
+
message: "Understood and open gitlab now? 🤔",
|
|
148
|
+
name: "understood",
|
|
149
|
+
type: "confirm",
|
|
150
|
+
});
|
|
151
|
+
if (!understood) {
|
|
152
|
+
this.log("continuing anyway...");
|
|
153
|
+
}
|
|
154
|
+
open(`${projectWebUrl}/-/settings/access_tokens`);
|
|
155
|
+
|
|
156
|
+
this.log("\n");
|
|
157
|
+
|
|
158
|
+
this.log("Enter your copied token now: ");
|
|
159
|
+
|
|
160
|
+
this.log("\n");
|
|
161
|
+
const { GL_TOKEN } = await this.prompt({
|
|
162
|
+
type: "password",
|
|
163
|
+
name: "GL_TOKEN",
|
|
164
|
+
message: "Access Token: ",
|
|
165
|
+
});
|
|
166
|
+
await doGitlabRequest(this, `projects/${projectId}/variables`, {
|
|
167
|
+
key: "GL_TOKEN",
|
|
168
|
+
value: GL_TOKEN,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const deploy_tokens = await doGitlabRequest(
|
|
173
|
+
this,
|
|
174
|
+
`projects/${projectId}/deploy_tokens`
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
if (
|
|
178
|
+
!deploy_tokens.find(
|
|
179
|
+
(v: { name: string }) => v.name === "gitlab-deploy-token"
|
|
180
|
+
)
|
|
181
|
+
) {
|
|
182
|
+
this.log(
|
|
183
|
+
"I will setup the 'GitLab Deploy Token', so Kubernetes can pull images from this project."
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
await doGitlabRequest(this, `projects/${projectId}/deploy_tokens`, {
|
|
187
|
+
id: projectId,
|
|
188
|
+
name: "gitlab-deploy-token",
|
|
189
|
+
scopes: ["read_registry"],
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
this.log("gitlab is ready! 🥂");
|
|
193
|
+
this.log("\n");
|
|
194
|
+
this.log("do not forget to make sure that:");
|
|
195
|
+
[
|
|
196
|
+
"you have __health route in place",
|
|
197
|
+
"lint and test are defined",
|
|
198
|
+
"eat your vegetables",
|
|
199
|
+
"be awesome 🤩",
|
|
200
|
+
].forEach((tip) => this.log(` - ${tip}`));
|
|
201
|
+
this.log("\n");
|
|
202
|
+
this.log("\n");
|
|
203
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile, writeFile } from "fs-extra";
|
|
2
|
-
import {
|
|
2
|
+
import { dump } from "js-yaml";
|
|
3
3
|
import { mapKeys, snakeCase, toUpper } from "lodash";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import Vorpal from "vorpal";
|
|
@@ -29,7 +29,7 @@ const DEFAULT_VARIABLES = {
|
|
|
29
29
|
clusterName: "production",
|
|
30
30
|
};
|
|
31
31
|
// TODO: we should find a way how to fetch the variables of the inclues directly from gitlab
|
|
32
|
-
const
|
|
32
|
+
const DEFAULT_NODE_asdfAPPLICATION = {};
|
|
33
33
|
|
|
34
34
|
const DEFAULT_FILES_TO_CREATE: FileToCreate[] = [
|
|
35
35
|
{
|
|
@@ -38,6 +38,9 @@ const DEFAULT_FILES_TO_CREATE: FileToCreate[] = [
|
|
|
38
38
|
readFile(path.resolve(__dirname, "../includes/envrc"), "utf8"),
|
|
39
39
|
},
|
|
40
40
|
];
|
|
41
|
+
/*
|
|
42
|
+
|
|
43
|
+
TODO: reimplement as PRESETS ?
|
|
41
44
|
const PLATFORMS: { [platformName: string]: PlatformDefinition } = {
|
|
42
45
|
nextJS: {
|
|
43
46
|
variables: {},
|
|
@@ -154,7 +157,7 @@ const PLATFORMS: { [platformName: string]: PlatformDefinition } = {
|
|
|
154
157
|
{
|
|
155
158
|
filename: "values-review.yml",
|
|
156
159
|
content: async () =>
|
|
157
|
-
|
|
160
|
+
dump({
|
|
158
161
|
jobs: {
|
|
159
162
|
"db-prepare-seed": {
|
|
160
163
|
hook: "post-install",
|
|
@@ -180,10 +183,15 @@ const PLATFORMS: { [platformName: string]: PlatformDefinition } = {
|
|
|
180
183
|
values: {},
|
|
181
184
|
},
|
|
182
185
|
};
|
|
183
|
-
|
|
186
|
+
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
const PLATFORMS: any = {};
|
|
190
|
+
export default async (vorpal: Vorpal) =>
|
|
184
191
|
vorpal
|
|
185
192
|
.command("project-init", "Inits a new project")
|
|
186
193
|
.action(async function () {
|
|
194
|
+
throw new Error("needs reimplementation");
|
|
187
195
|
const hasGitlabFile = await hasGitlabCiFile();
|
|
188
196
|
if (hasGitlabFile) {
|
|
189
197
|
this.log("there is already a gitlab-ci.yml file. Skipping");
|
|
@@ -251,7 +259,7 @@ export default (vorpal: Vorpal) =>
|
|
|
251
259
|
variables: transformedVariables,
|
|
252
260
|
};
|
|
253
261
|
|
|
254
|
-
const gitlabCiContent =
|
|
262
|
+
const gitlabCiContent = dump(gitlabCiContentObj);
|
|
255
263
|
await writeFile(".gitlab-ci.yml", gitlabCiContent);
|
|
256
264
|
|
|
257
265
|
allFilesToCreate.forEach(async ({ filename, content }) => {
|
|
@@ -260,7 +268,7 @@ export default (vorpal: Vorpal) =>
|
|
|
260
268
|
await writeFile(filename, theContent);
|
|
261
269
|
});
|
|
262
270
|
|
|
263
|
-
await writeFile("values.yml",
|
|
271
|
+
await writeFile("values.yml", dump(values));
|
|
264
272
|
|
|
265
273
|
this.log("");
|
|
266
274
|
this.log("gitlab-ci created! 💪😻");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { dump } from "js-yaml";
|
|
2
|
+
import { pick } from "lodash";
|
|
3
|
+
import Vorpal from "vorpal";
|
|
4
|
+
import { getProjectPods } from "../../../../utils/projects";
|
|
5
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
6
|
+
import ensureCluster from "./utils/ensureCluster";
|
|
7
|
+
|
|
8
|
+
export default async (vorpal: Vorpal) =>
|
|
9
|
+
vorpal
|
|
10
|
+
.command("project-list-pods <envComponent>", "list pods of local project")
|
|
11
|
+
.autocomplete(await envAndComponents())
|
|
12
|
+
.action(async function ({ envComponent }) {
|
|
13
|
+
await ensureCluster.call(this, envComponent);
|
|
14
|
+
const pods = await getProjectPods(envComponent);
|
|
15
|
+
this.log(
|
|
16
|
+
dump(pods.map((p) => pick(p, ["metadata.name", "status.startTime"])))
|
|
17
|
+
);
|
|
18
|
+
});
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import { exec } from "child-process-promise";
|
|
2
2
|
import Vorpal from "vorpal";
|
|
3
|
+
import {
|
|
4
|
+
getEnvironment,
|
|
5
|
+
parseChoice,
|
|
6
|
+
} from "../../../../config/getProjectConfig";
|
|
3
7
|
import { logError } from "../../../../utils/log";
|
|
4
|
-
|
|
5
|
-
import {
|
|
8
|
+
|
|
9
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Error: rendered manifests contain a resource that already exists.
|
|
9
13
|
* Unable to continue with install: ConfigMap "web-app-env" in namespace "pvl-bike2school-dev" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "pvl-bike2school-dev-web"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "pvl-bike2school-dev"
|
|
10
14
|
*/
|
|
11
|
-
export default (vorpal: Vorpal) =>
|
|
15
|
+
export default async (vorpal: Vorpal) =>
|
|
12
16
|
vorpal
|
|
13
17
|
.command(
|
|
14
|
-
"project-migrate-helm3 <
|
|
18
|
+
"project-migrate-helm3 <envComponent>",
|
|
15
19
|
"Do manual step for helm2 to helm3 migration"
|
|
16
20
|
)
|
|
17
21
|
.autocomplete(
|
|
18
|
-
|
|
22
|
+
(await envAndComponents()).filter(
|
|
23
|
+
(e) => !e.startsWith("local") && !e.startsWith("review")
|
|
24
|
+
)
|
|
19
25
|
)
|
|
20
|
-
.action(async function ({
|
|
26
|
+
.action(async function ({ envComponent }) {
|
|
21
27
|
try {
|
|
28
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
22
29
|
const result = await exec("helm version --short");
|
|
23
30
|
const version = result.stdout as string;
|
|
24
31
|
this.log(`your helm version: ${version}`);
|
|
@@ -35,7 +42,9 @@ export default (vorpal: Vorpal) =>
|
|
|
35
42
|
} catch (e) {
|
|
36
43
|
// ignore
|
|
37
44
|
}
|
|
38
|
-
|
|
45
|
+
|
|
46
|
+
const releaseName = (await getEnvironment(env, componentName)).envVars
|
|
47
|
+
.RELEASE_NAME; // TODO: maybe its own function would be better
|
|
39
48
|
this.log(`helm release name: ${releaseName}`);
|
|
40
49
|
this.log("");
|
|
41
50
|
this.log("migrating now... 😼. This may take a moment");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Vorpal from "vorpal";
|
|
2
|
+
import { getProjectNamespace } from "../../../../utils/projects";
|
|
3
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
4
|
+
|
|
5
|
+
export default async (vorpal: Vorpal) =>
|
|
6
|
+
vorpal
|
|
7
|
+
.command(
|
|
8
|
+
"project-namespace <envComponent>",
|
|
9
|
+
"show namespace of local project"
|
|
10
|
+
)
|
|
11
|
+
.autocomplete(await envAndComponents())
|
|
12
|
+
.action(async function ({ envComponent }) {
|
|
13
|
+
this.log(await getProjectNamespace(envComponent));
|
|
14
|
+
});
|
|
@@ -9,15 +9,18 @@ import { startPortForward } from "../../../../utils/portForward";
|
|
|
9
9
|
|
|
10
10
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
13
13
|
import ensureCluster from "./utils/ensureCluster";
|
|
14
|
-
export default (vorpal: Vorpal) =>
|
|
14
|
+
export default async (vorpal: Vorpal) =>
|
|
15
15
|
vorpal
|
|
16
|
-
.command(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
.command(
|
|
17
|
+
"project-check-costs <envComponent>",
|
|
18
|
+
"Shows you how much you're spending"
|
|
19
|
+
)
|
|
20
|
+
.autocomplete(await envAndComponents())
|
|
21
|
+
.action(async function ({ envComponent }) {
|
|
22
|
+
await ensureCluster.call(this, envComponent);
|
|
23
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
21
24
|
const url = `http://localhost:${GRAFANA_PROXY_LOCAL_PORT}/namespace.html?name=${namespace}`;
|
|
22
25
|
await startPortForward(
|
|
23
26
|
"deployment/kubecost-cost-analyzer",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Vorpal from "vorpal";
|
|
2
|
+
import {
|
|
3
|
+
getPipelineContextByChoice,
|
|
4
|
+
parseChoice,
|
|
5
|
+
} from "../../../../config/getProjectConfig";
|
|
6
|
+
import { getCurrentConnectedClusterName } from "../../../../utils/cluster";
|
|
7
|
+
import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
|
|
8
|
+
import { openGoogleCloudKubernetesDashboard } from "../shared";
|
|
9
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
10
|
+
import ensureCluster from "./utils/ensureCluster";
|
|
11
|
+
export default async (vorpal: Vorpal) =>
|
|
12
|
+
vorpal
|
|
13
|
+
.command(
|
|
14
|
+
"project-open-dashboard <envComponent>",
|
|
15
|
+
"open kubernetes dashboard on google"
|
|
16
|
+
)
|
|
17
|
+
.autocomplete(await envAndComponents())
|
|
18
|
+
.action(async function ({ envComponent }) {
|
|
19
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
20
|
+
const { componentConfig, environment } = await getPipelineContextByChoice(
|
|
21
|
+
env,
|
|
22
|
+
componentName
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (
|
|
26
|
+
!componentConfig.deploy ||
|
|
27
|
+
componentConfig.deploy.type !== "kubernetes"
|
|
28
|
+
) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"only kubernetes deployments are supported at the moment"
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
// currently only supports kubernetes
|
|
34
|
+
const namespace = environment.envVars.KUBE_NAMESPACE;
|
|
35
|
+
await ensureCluster.call(this, envComponent); // TODO: implement
|
|
36
|
+
const clustername = await getCurrentConnectedClusterName();
|
|
37
|
+
|
|
38
|
+
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
39
|
+
|
|
40
|
+
openGoogleCloudKubernetesDashboard(
|
|
41
|
+
authGoogleNumber,
|
|
42
|
+
clustername,
|
|
43
|
+
namespace
|
|
44
|
+
);
|
|
45
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import open from "open";
|
|
2
|
+
import Vorpal from "vorpal";
|
|
3
|
+
import {
|
|
4
|
+
getEnvironment,
|
|
5
|
+
parseChoice,
|
|
6
|
+
} from "../../../../config/getProjectConfig";
|
|
7
|
+
|
|
8
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
9
|
+
import ensureCluster from "./utils/ensureCluster";
|
|
10
|
+
|
|
11
|
+
export default async (vorpal: Vorpal) =>
|
|
12
|
+
vorpal
|
|
13
|
+
.command("project-open-env <envComponent>", "open the live environment")
|
|
14
|
+
.autocomplete(await envAndComponents())
|
|
15
|
+
.action(async function ({ envComponent }) {
|
|
16
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
17
|
+
await ensureCluster.call(this, envComponent);
|
|
18
|
+
const environment = await getEnvironment(env, componentName);
|
|
19
|
+
const url = environment.url;
|
|
20
|
+
|
|
21
|
+
open(url);
|
|
22
|
+
});
|
|
@@ -8,18 +8,18 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
12
12
|
import ensureCluster from "./utils/ensureCluster";
|
|
13
|
-
export default (vorpal: Vorpal) =>
|
|
13
|
+
export default async (vorpal: Vorpal) =>
|
|
14
14
|
vorpal
|
|
15
15
|
.command(
|
|
16
|
-
"project-open-grafana <
|
|
16
|
+
"project-open-grafana <envComponent>",
|
|
17
17
|
"open Grafana dashboard for your namespace"
|
|
18
18
|
)
|
|
19
|
-
.autocomplete(
|
|
20
|
-
.action(async function ({
|
|
21
|
-
await ensureCluster.call(this);
|
|
22
|
-
const namespace = await getProjectNamespace(
|
|
19
|
+
.autocomplete(await envAndComponents())
|
|
20
|
+
.action(async function ({ envComponent }) {
|
|
21
|
+
await ensureCluster.call(this, envComponent);
|
|
22
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
23
23
|
const url = `http://localhost:${GRAFANA_PROXY_LOCAL_PORT}/grafana/d/at-cost-analysis-namespace2/namespace-utilization-metrics?var-namespace=${namespace}`;
|
|
24
24
|
await startPortForward(
|
|
25
25
|
"deployment/kubecost-cost-analyzer",
|
|
@@ -6,24 +6,23 @@ import {
|
|
|
6
6
|
} from "../../../../config/constants";
|
|
7
7
|
import { logError } from "../../../../utils/log";
|
|
8
8
|
import { startPortForward } from "../../../../utils/portForward";
|
|
9
|
-
|
|
10
9
|
import {
|
|
11
10
|
getProjectNamespace,
|
|
12
11
|
getProjectPodNames,
|
|
13
12
|
} from "../../../../utils/projects";
|
|
14
|
-
|
|
15
|
-
import { envAutocompletion } from "./utils/autocompletions";
|
|
13
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
16
14
|
import ensureCluster from "./utils/ensureCluster";
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
export default async (vorpal: Vorpal) =>
|
|
18
17
|
vorpal
|
|
19
18
|
.command(
|
|
20
|
-
"project-open-grafana-pod <
|
|
19
|
+
"project-open-grafana-pod <envComponent>",
|
|
21
20
|
"open Grafana dashboard for a specific pod"
|
|
22
21
|
)
|
|
23
|
-
.autocomplete(
|
|
24
|
-
.action(async function ({
|
|
25
|
-
await ensureCluster.call(this);
|
|
26
|
-
const podNames = await getProjectPodNames(
|
|
22
|
+
.autocomplete(await envAndComponents())
|
|
23
|
+
.action(async function ({ envComponent }) {
|
|
24
|
+
await ensureCluster.call(this, envComponent);
|
|
25
|
+
const podNames = await getProjectPodNames(envComponent);
|
|
27
26
|
if (podNames.length === 0) {
|
|
28
27
|
logError(this, "sorry, no pods found");
|
|
29
28
|
return;
|
|
@@ -34,7 +33,7 @@ export default (vorpal: Vorpal) =>
|
|
|
34
33
|
choices: podNames,
|
|
35
34
|
message: "Which pod? 🤔",
|
|
36
35
|
});
|
|
37
|
-
const namespace = await getProjectNamespace(
|
|
36
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
38
37
|
const url = `http://localhost:${GRAFANA_PROXY_LOCAL_PORT}/grafana/d/at-cost-analysis-pod/pod-cost-and-utilization-metrics?var-namespace=${namespace}&var-pod=${podName}`;
|
|
39
38
|
await startPortForward(
|
|
40
39
|
"deployment/kubecost-cost-analyzer",
|
|
@@ -3,20 +3,20 @@ import { getCurrentConnectedClusterName } from "../../../../utils/cluster";
|
|
|
3
3
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
4
4
|
import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
|
|
5
5
|
import { openGoogleCloudLogs } from "../shared";
|
|
6
|
-
import {
|
|
6
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
7
7
|
import ensureCluster from "./utils/ensureCluster";
|
|
8
8
|
|
|
9
|
-
export default (vorpal: Vorpal) =>
|
|
9
|
+
export default async (vorpal: Vorpal) =>
|
|
10
10
|
vorpal
|
|
11
11
|
.command(
|
|
12
|
-
"project-open-logs <
|
|
12
|
+
"project-open-logs <envComponent>",
|
|
13
13
|
"open google cloud logs (stackdriver logs)"
|
|
14
14
|
)
|
|
15
|
-
.autocomplete(
|
|
16
|
-
.action(async function ({
|
|
17
|
-
await ensureCluster.call(this);
|
|
15
|
+
.autocomplete(await envAndComponents())
|
|
16
|
+
.action(async function ({ envComponent }) {
|
|
17
|
+
await ensureCluster.call(this, envComponent);
|
|
18
18
|
const clustername = await getCurrentConnectedClusterName();
|
|
19
|
-
const namespace = await getProjectNamespace(
|
|
19
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
20
20
|
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
21
21
|
|
|
22
22
|
await openGoogleCloudLogs(authGoogleNumber, clustername, namespace);
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import Vorpal from "vorpal";
|
|
2
2
|
import { exec } from "child-process-promise";
|
|
3
|
-
import { Env } from "../../../../types/types";
|
|
4
3
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
5
|
-
import {
|
|
4
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
6
5
|
|
|
7
|
-
export default (vorpal: Vorpal) =>
|
|
6
|
+
export default async (vorpal: Vorpal) =>
|
|
8
7
|
vorpal
|
|
9
|
-
.command(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
.command(
|
|
9
|
+
"project-pause <envComponent>",
|
|
10
|
+
"halts all running pods (scales to 0)"
|
|
11
|
+
)
|
|
12
|
+
.autocomplete(await envAndComponents())
|
|
13
|
+
.action(async function ({ envComponent }) {
|
|
14
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
13
15
|
const { shouldContinue } = await this.prompt({
|
|
14
16
|
type: "confirm",
|
|
15
17
|
name: "shouldContinue",
|
|
@@ -5,17 +5,17 @@ import {
|
|
|
5
5
|
getProjectNamespace,
|
|
6
6
|
getProjectPodNames,
|
|
7
7
|
} from "../../../../utils/projects";
|
|
8
|
-
import {
|
|
8
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
9
9
|
import ensureCluster from "./utils/ensureCluster";
|
|
10
10
|
|
|
11
|
-
export default (vorpal: Vorpal) =>
|
|
11
|
+
export default async (vorpal: Vorpal) =>
|
|
12
12
|
vorpal
|
|
13
|
-
.command("project-port-forward <
|
|
14
|
-
.autocomplete(
|
|
15
|
-
.action(async function ({
|
|
16
|
-
await ensureCluster.call(this);
|
|
17
|
-
const namespace = await getProjectNamespace(
|
|
18
|
-
const podNames = await getProjectPodNames(
|
|
13
|
+
.command("project-port-forward <envComponent>", "start port-forwarding")
|
|
14
|
+
.autocomplete(await envAndComponents())
|
|
15
|
+
.action(async function ({ envComponent }) {
|
|
16
|
+
await ensureCluster.call(this, envComponent);
|
|
17
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
18
|
+
const podNames = await getProjectPodNames(envComponent);
|
|
19
19
|
if (podNames.length === 0) {
|
|
20
20
|
logError(this, "sorry, no pods found");
|
|
21
21
|
return;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Vorpal from "vorpal";
|
|
2
|
+
import { reloadConfig } from "../../../../config/getProjectConfig";
|
|
3
|
+
import { showProjectBanner } from "./utils/showProjectBanner";
|
|
4
|
+
|
|
5
|
+
export default async (vorpal: Vorpal) =>
|
|
6
|
+
vorpal
|
|
7
|
+
.command("project-reload-config", "reloads the config")
|
|
8
|
+
|
|
9
|
+
.action(async function () {
|
|
10
|
+
await reloadConfig();
|
|
11
|
+
await showProjectBanner(vorpal);
|
|
12
|
+
});
|
|
@@ -6,7 +6,7 @@ import { logError } from "../../../../utils/log";
|
|
|
6
6
|
import { namespaceAutoCompletion } from "../general/namespaceAutoCompletion";
|
|
7
7
|
|
|
8
8
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
9
|
-
import {
|
|
9
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
10
10
|
import ensureCluster from "./utils/ensureCluster";
|
|
11
11
|
|
|
12
12
|
async function triggerCronjob(namespace: string) {
|
|
@@ -43,7 +43,7 @@ async function triggerCronjob(namespace: string) {
|
|
|
43
43
|
logError(this, "command failed", e.body);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
export default (vorpal: Vorpal) => {
|
|
46
|
+
export default async (vorpal: Vorpal) => {
|
|
47
47
|
vorpal
|
|
48
48
|
.command("trigger-cronjob <namespace>", "trigger cronjob")
|
|
49
49
|
.autocomplete(namespaceAutoCompletion)
|
|
@@ -51,11 +51,11 @@ export default (vorpal: Vorpal) => {
|
|
|
51
51
|
await triggerCronjob.call(this, namespace);
|
|
52
52
|
});
|
|
53
53
|
vorpal
|
|
54
|
-
.command("project-trigger-cronjob <
|
|
55
|
-
.autocomplete(
|
|
56
|
-
.action(async function ({
|
|
57
|
-
await ensureCluster.call(this);
|
|
58
|
-
const namespace = await getProjectNamespace(
|
|
54
|
+
.command("project-trigger-cronjob <envComponent>", "trigger cronjob")
|
|
55
|
+
.autocomplete(await envAndComponents())
|
|
56
|
+
.action(async function ({ envComponent }) {
|
|
57
|
+
await ensureCluster.call(this, envComponent);
|
|
58
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
59
59
|
await triggerCronjob.call(this, namespace);
|
|
60
60
|
});
|
|
61
61
|
};
|