@catladder/cli 0.0.0-test7 → 0.0.0-waitfor-deploy-e64a33ba
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 +6 -3
- package/bin/catenv +3 -0
- package/bin/catladder +1 -1
- package/dist/apps/catenv/catenv.d.ts +5 -0
- package/dist/apps/catenv/catenv.js +143 -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 +216 -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 +97 -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 +137 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +4 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +320 -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 +120 -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/commandInitProject.old.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandInitProject.old.js +345 -0
- package/dist/apps/cli/commands/project/commandInitProject.old.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/commandSetup.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandSetup.js +58 -0
- package/dist/apps/cli/commands/project/commandSetup.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 +94 -0
- package/dist/apps/cli/commands/project/index.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/index.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/index.js +103 -0
- package/dist/apps/cli/commands/project/setup/index.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +115 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupContext.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupContext.js +74 -0
- package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js +132 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.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 +104 -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 +347 -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 +15 -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 +259 -0
- package/dist/config/getProjectConfig.js.map +1 -0
- package/dist/k8sApi/index.d.ts +8 -0
- package/dist/k8sApi/index.js +29 -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 +73 -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/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 +22 -0
- package/dist/utils/gitlab.js +278 -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 +153 -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 +55 -27
- package/src/apps/{shell/shell.ts → cli/cli.ts} +10 -2
- package/src/apps/{shell → cli}/commands/general/index.ts +7 -46
- package/src/apps/{shell → cli}/commands/general/namespaceAutoCompletion.ts +0 -0
- package/src/apps/{shell → cli}/commands/general/portForward.ts +3 -2
- 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/cli/commands/project/commandCloudSqlProxy.ts +88 -0
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +220 -0
- package/src/apps/{shell → cli}/commands/project/commandCopyDB.ts +24 -26
- package/src/apps/{shell → cli}/commands/project/commandDeletePods.ts +10 -10
- 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/{shell/commands/project/commandInitProject.ts → cli/commands/project/commandInitProject.old.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/commandSetup.ts +12 -0
- package/src/apps/{shell → cli}/commands/project/commandTriggerCronjob.ts +10 -10
- package/src/apps/{shell → cli}/commands/project/index.ts +6 -7
- package/src/apps/cli/commands/project/setup/index.ts +42 -0
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +72 -0
- package/src/apps/cli/commands/project/setup/setupContext.ts +37 -0
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +112 -0
- 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 +56 -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 +264 -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 +11 -0
- package/src/cli.ts +9 -0
- package/src/config/constants.ts +0 -1
- package/src/config/getProjectConfig.ts +160 -0
- package/src/k8sApi/index.ts +22 -6
- package/src/types/types.ts +0 -2
- package/src/utils/cluster.ts +6 -15
- package/src/utils/editAsFile.ts +31 -0
- package/src/utils/files.ts +6 -2
- package/src/utils/gitlab.ts +144 -34
- package/src/utils/passwordstore/index.ts +19 -21
- package/src/utils/preferences/index.ts +6 -3
- package/src/utils/projects/index.ts +18 -137
- package/tsconfig.json +3 -7
- package/bin/catenv.sh +0 -1
- package/src/apps/shell/commands/project/commandCloudSqlProxy.ts +0 -65
- 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
- package/src/utils/formatEnvVars.ts +0 -7
|
@@ -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 { setupProject } from "./setup";
|
|
3
|
+
|
|
4
|
+
export default async (vorpal: Vorpal) =>
|
|
5
|
+
vorpal
|
|
6
|
+
.command(
|
|
7
|
+
"project-setup",
|
|
8
|
+
"Initializes all environments and creates requires resources, service accounts, etc."
|
|
9
|
+
)
|
|
10
|
+
.action(async function () {
|
|
11
|
+
await setupProject(this);
|
|
12
|
+
});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { V1Job, V1ObjectMeta } from "@kubernetes/client-node";
|
|
2
2
|
|
|
3
3
|
import Vorpal from "vorpal";
|
|
4
|
-
import {
|
|
4
|
+
import { getk8sApiBatch, getk8sApiBatchBeta } from "../../../../k8sApi";
|
|
5
5
|
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) {
|
|
13
13
|
const {
|
|
14
14
|
body: { items: jobs },
|
|
15
|
-
} = await
|
|
15
|
+
} = await getk8sApiBatchBeta().listNamespacedCronJob(namespace);
|
|
16
16
|
|
|
17
17
|
const jobNames = jobs.map((j) => j.metadata.name);
|
|
18
18
|
|
|
@@ -34,7 +34,7 @@ async function triggerCronjob(namespace: string) {
|
|
|
34
34
|
job.metadata = metadata as V1ObjectMeta;
|
|
35
35
|
job.spec = jobSpec;
|
|
36
36
|
try {
|
|
37
|
-
const result = await
|
|
37
|
+
const result = await getk8sApiBatch().createNamespacedJob(namespace, job);
|
|
38
38
|
|
|
39
39
|
this.log("");
|
|
40
40
|
this.log(`yeah, you got a job, man. 😺 ${result.body.metadata.name}`);
|
|
@@ -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
|
};
|
|
@@ -8,8 +8,8 @@ import commandEnvVars from "./commandEnvVars";
|
|
|
8
8
|
import commandGetMyTotalWorktime from "./commandGetMyTotalWorktime";
|
|
9
9
|
import commandGetShell from "./commandGetShell";
|
|
10
10
|
import commandGitlabCi from "./commandGitlabCi";
|
|
11
|
-
import
|
|
12
|
-
import commandInitProject from "./commandInitProject";
|
|
11
|
+
import commandSetup from "./commandSetup";
|
|
12
|
+
//import commandInitProject from "./commandInitProject.old";
|
|
13
13
|
import commandListPods from "./commandListPods";
|
|
14
14
|
import commandMigrateHelm3 from "./commandMigrateHelm3";
|
|
15
15
|
import commandNamespace from "./commandNamespace";
|
|
@@ -22,15 +22,14 @@ import commandPauseProject from "./commandPauseProject";
|
|
|
22
22
|
import commandOpenGrafana from "./commandOpenGrafana";
|
|
23
23
|
import commandPortForward from "./commandPortForward";
|
|
24
24
|
import commandTriggerCronjob from "./commandTriggerCronjob";
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
import commandOpenGrafanaPod from "./commandOpenGrafanaPod";
|
|
27
27
|
|
|
28
|
-
export default (vorpal: Vorpal) => {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
export default async (vorpal: Vorpal) => {
|
|
29
|
+
commandSetup(vorpal);
|
|
30
|
+
|
|
31
31
|
commandEnvVars(vorpal);
|
|
32
32
|
|
|
33
|
-
commandVariables(vorpal);
|
|
34
33
|
commandNamespace(vorpal);
|
|
35
34
|
commandListPods(vorpal);
|
|
36
35
|
commandPauseProject(vorpal);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CommandInstance } from "vorpal";
|
|
2
|
+
import { getAllPipelineContexts } from "../../../../../config/getProjectConfig";
|
|
3
|
+
import { projectConfigSecrets } from "../commandConfigSecrets";
|
|
4
|
+
import { setupAccessTokens } from "./setupAccessTokens";
|
|
5
|
+
import { setupContext } from "./setupContext";
|
|
6
|
+
|
|
7
|
+
export const setupProject = async (instance: CommandInstance) => {
|
|
8
|
+
const allContext = await getAllPipelineContexts();
|
|
9
|
+
|
|
10
|
+
for (const context of allContext) {
|
|
11
|
+
await setupContext(instance, context);
|
|
12
|
+
}
|
|
13
|
+
await setupAccessTokens(instance);
|
|
14
|
+
instance.log("");
|
|
15
|
+
const { configSecrets } = await instance.prompt({
|
|
16
|
+
default: true,
|
|
17
|
+
message: "Before deployments work, you need to config secrets. Do it now?",
|
|
18
|
+
name: "configSecrets",
|
|
19
|
+
type: "confirm",
|
|
20
|
+
});
|
|
21
|
+
instance.log("");
|
|
22
|
+
if (configSecrets) {
|
|
23
|
+
await projectConfigSecrets(instance);
|
|
24
|
+
} else {
|
|
25
|
+
instance.log(
|
|
26
|
+
"👆 don't forget to config secret using `project-config-secrets`"
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
instance.log("");
|
|
30
|
+
instance.log("gitlab is ready! 🥂");
|
|
31
|
+
instance.log("\n");
|
|
32
|
+
instance.log("do not forget to make sure that:");
|
|
33
|
+
[
|
|
34
|
+
"you have __health route in place",
|
|
35
|
+
"lint and test are defined",
|
|
36
|
+
"secrets are configured (call project-config-secret)",
|
|
37
|
+
"eat your vegetables",
|
|
38
|
+
"be awesome 🤩",
|
|
39
|
+
].forEach((tip) => instance.log(` - ${tip}`));
|
|
40
|
+
instance.log("\n");
|
|
41
|
+
instance.log("\n");
|
|
42
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import open from "open";
|
|
2
|
+
import { CommandInstance } from "vorpal";
|
|
3
|
+
import { doGitlabRequest, getProjectInfo } from "../../../../../utils/gitlab";
|
|
4
|
+
|
|
5
|
+
export const setupAccessTokens = async (instance: CommandInstance) => {
|
|
6
|
+
const { id: projectId, web_url: projectWebUrl } = await getProjectInfo(
|
|
7
|
+
instance
|
|
8
|
+
);
|
|
9
|
+
try {
|
|
10
|
+
await doGitlabRequest(instance, `projects/${projectId}/variables/GL_TOKEN`);
|
|
11
|
+
} catch (e) {
|
|
12
|
+
if (e.message !== "not found") {
|
|
13
|
+
throw e;
|
|
14
|
+
}
|
|
15
|
+
// not found
|
|
16
|
+
|
|
17
|
+
instance.log(
|
|
18
|
+
"I need add a GL_TOKEN to the project, so that semantic release will work\n"
|
|
19
|
+
);
|
|
20
|
+
instance.log(
|
|
21
|
+
"👉 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"
|
|
22
|
+
);
|
|
23
|
+
instance.log("\n");
|
|
24
|
+
|
|
25
|
+
const { understood } = await instance.prompt({
|
|
26
|
+
default: true,
|
|
27
|
+
message: "Understood and open gitlab now? 🤔",
|
|
28
|
+
name: "understood",
|
|
29
|
+
type: "confirm",
|
|
30
|
+
});
|
|
31
|
+
if (!understood) {
|
|
32
|
+
instance.log("continuing anyway...");
|
|
33
|
+
}
|
|
34
|
+
open(`${projectWebUrl}/-/settings/access_tokens`);
|
|
35
|
+
|
|
36
|
+
instance.log("\n");
|
|
37
|
+
|
|
38
|
+
instance.log("Enter your copied token now: ");
|
|
39
|
+
|
|
40
|
+
instance.log("\n");
|
|
41
|
+
const { GL_TOKEN } = await instance.prompt({
|
|
42
|
+
type: "password",
|
|
43
|
+
name: "GL_TOKEN",
|
|
44
|
+
message: "Access Token: ",
|
|
45
|
+
});
|
|
46
|
+
await doGitlabRequest(instance, `projects/${projectId}/variables`, {
|
|
47
|
+
key: "GL_TOKEN",
|
|
48
|
+
value: GL_TOKEN,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const deploy_tokens = await doGitlabRequest(
|
|
53
|
+
instance,
|
|
54
|
+
`projects/${projectId}/deploy_tokens`
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (
|
|
58
|
+
!deploy_tokens.find(
|
|
59
|
+
(v: { name: string }) => v.name === "gitlab-deploy-token"
|
|
60
|
+
)
|
|
61
|
+
) {
|
|
62
|
+
instance.log(
|
|
63
|
+
"I will setup the 'GitLab Deploy Token', so Kubernetes can pull images from this project."
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
await doGitlabRequest(instance, `projects/${projectId}/deploy_tokens`, {
|
|
67
|
+
id: projectId,
|
|
68
|
+
name: "gitlab-deploy-token",
|
|
69
|
+
scopes: ["read_registry"],
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Context, isOfDeployType } from "@catladder/pipeline";
|
|
2
|
+
import { CommandInstance } from "vorpal";
|
|
3
|
+
import { setupKubernetes } from "./setupKubernetes";
|
|
4
|
+
|
|
5
|
+
export const setupContext = async (
|
|
6
|
+
instance: CommandInstance,
|
|
7
|
+
context: Context
|
|
8
|
+
) => {
|
|
9
|
+
instance.log("");
|
|
10
|
+
instance.log(
|
|
11
|
+
"=================================================================================="
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
instance.log(
|
|
15
|
+
"🐱 🔧 setting up " +
|
|
16
|
+
context.environment.shortName +
|
|
17
|
+
":" +
|
|
18
|
+
context.componentName +
|
|
19
|
+
"..."
|
|
20
|
+
);
|
|
21
|
+
instance.log("");
|
|
22
|
+
const deployConfig = context.componentConfig.deploy;
|
|
23
|
+
if (isOfDeployType(deployConfig, "kubernetes")) {
|
|
24
|
+
await setupKubernetes(instance, context);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
instance.log("");
|
|
28
|
+
instance.log(
|
|
29
|
+
"✅ " +
|
|
30
|
+
context.environment.shortName +
|
|
31
|
+
":" +
|
|
32
|
+
context.componentName +
|
|
33
|
+
" done!"
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
instance.log("");
|
|
37
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Context,
|
|
3
|
+
getFullKubernetesClusterName,
|
|
4
|
+
isOfDeployType,
|
|
5
|
+
} from "@catladder/pipeline";
|
|
6
|
+
import { CommandInstance } from "vorpal";
|
|
7
|
+
import { $ } from "zx";
|
|
8
|
+
import { connectToCluster } from "../../../../../utils/cluster";
|
|
9
|
+
import { upsertAllVariables } from "../../../../../utils/gitlab";
|
|
10
|
+
import ensureNamespace from "../utils/ensureNamespace";
|
|
11
|
+
|
|
12
|
+
export const setupKubernetes = async (
|
|
13
|
+
instance: CommandInstance,
|
|
14
|
+
context: Context
|
|
15
|
+
) => {
|
|
16
|
+
const deployConfig = context.componentConfig.deploy;
|
|
17
|
+
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
18
|
+
throw new Error("cannot run setupKubernetes on non-kubernetes deployments");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const fullName = getFullKubernetesClusterName(deployConfig.cluster);
|
|
22
|
+
instance.log(`cluster: ${fullName}`);
|
|
23
|
+
|
|
24
|
+
await connectToCluster(fullName);
|
|
25
|
+
instance.log("");
|
|
26
|
+
instance.log("ensuring namespace ...");
|
|
27
|
+
const namespace = await ensureNamespace(context);
|
|
28
|
+
instance.log("Namespace " + namespace + " created / updated!");
|
|
29
|
+
instance.log("");
|
|
30
|
+
//$.verbose = true;
|
|
31
|
+
|
|
32
|
+
// we name the service account and the role and the role binding with the same name
|
|
33
|
+
// we currently create one per component to better separate them
|
|
34
|
+
instance.log("ensuring service accounts...");
|
|
35
|
+
const serviceAccountName = `cl-${context.componentName}-deploy`;
|
|
36
|
+
const KUBE_URL =
|
|
37
|
+
await $`TERM=dumb kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'`.then(
|
|
38
|
+
(s) => s.stdout.trim()
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// first upsert service acount in the ns
|
|
42
|
+
try {
|
|
43
|
+
await $`kubectl delete serviceaccount --namespace ${namespace} ${serviceAccountName}`;
|
|
44
|
+
await $`kubectl delete rolebinding --namespace ${namespace} ${serviceAccountName}`;
|
|
45
|
+
await $`kubectl delete role --namespace ${namespace} ${serviceAccountName}`;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
// ignore
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await $`kubectl create serviceaccount --namespace ${namespace} ${serviceAccountName}`;
|
|
51
|
+
|
|
52
|
+
// upsert role in the ns
|
|
53
|
+
|
|
54
|
+
await $`cat <<EOF | kubectl apply -f -
|
|
55
|
+
kind: Role
|
|
56
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
57
|
+
metadata:
|
|
58
|
+
namespace: ${namespace}
|
|
59
|
+
name: ${serviceAccountName}
|
|
60
|
+
rules:
|
|
61
|
+
- apiGroups: ["", "extensions", "apps", "networking.k8s.io", "batch", "autoscaling"]
|
|
62
|
+
resources: ["deployments", "replicasets", "statefulsets", "pods", "secrets", "configmaps", "services", "ingresses", "serviceaccounts", "jobs", "cronjobs", "horizontalpodautoscalers"]
|
|
63
|
+
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] # You can also use ["*"]
|
|
64
|
+
---
|
|
65
|
+
kind: RoleBinding
|
|
66
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
67
|
+
metadata:
|
|
68
|
+
name: ${serviceAccountName}
|
|
69
|
+
namespace: ${namespace}
|
|
70
|
+
subjects:
|
|
71
|
+
- kind: ServiceAccount
|
|
72
|
+
name: ${serviceAccountName}
|
|
73
|
+
namespace: ${namespace}
|
|
74
|
+
roleRef:
|
|
75
|
+
kind: Role
|
|
76
|
+
name: ${serviceAccountName}
|
|
77
|
+
apiGroup: rbac.authorization.k8s.io
|
|
78
|
+
EOF
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
// get token name
|
|
82
|
+
const tokenName =
|
|
83
|
+
await $`kubectl get serviceaccount --namespace ${namespace} ${serviceAccountName} -o jsonpath='{.secrets[0].name}'`;
|
|
84
|
+
|
|
85
|
+
const KUBE_CA_PEM =
|
|
86
|
+
await $`kubectl get secret ${tokenName} --namespace ${namespace} -o jsonpath="{['data']['ca\\.crt']}"`.then(
|
|
87
|
+
(c) => c.stdout.trim()
|
|
88
|
+
);
|
|
89
|
+
const KUBE_TOKEN =
|
|
90
|
+
await $`kubectl get secret ${tokenName} --namespace ${namespace} -o jsonpath="{['data']['token']}" | base64 --decode`.then(
|
|
91
|
+
(c) => c.stdout.trim()
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const vars = {
|
|
95
|
+
KUBE_TOKEN,
|
|
96
|
+
KUBE_CA_PEM,
|
|
97
|
+
KUBE_URL,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
instance.log("service accounts created / updated!");
|
|
101
|
+
|
|
102
|
+
instance.log("");
|
|
103
|
+
instance.log("pusing secrets to gitlab...");
|
|
104
|
+
|
|
105
|
+
await upsertAllVariables(
|
|
106
|
+
instance,
|
|
107
|
+
vars,
|
|
108
|
+
context.environment.shortName,
|
|
109
|
+
context.componentName
|
|
110
|
+
);
|
|
111
|
+
instance.log("done!");
|
|
112
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getAllEnvs, getAllEnvsInAllComponents } from "@catladder/pipeline";
|
|
2
|
+
import {
|
|
3
|
+
getAllComponentsWithAllEnvsFlat,
|
|
4
|
+
getProjectConfig,
|
|
5
|
+
} from "../../../../../config/getProjectConfig";
|
|
6
|
+
|
|
7
|
+
export const allEnvs = async () => {
|
|
8
|
+
const config = await getProjectConfig();
|
|
9
|
+
if (!config) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return getAllEnvsInAllComponents(config);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const envAndComponents = async () => {
|
|
16
|
+
const allEnvAndcomponents = await getAllComponentsWithAllEnvsFlat();
|
|
17
|
+
|
|
18
|
+
return allEnvAndcomponents.reduce<string[]>(
|
|
19
|
+
(acc, { env, componentName }) => [...acc, env + ":" + componentName],
|
|
20
|
+
[]
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const allEnvsAndAllComponents = async () => {
|
|
25
|
+
return [...(await allEnvs()), ...(await envAndComponents())];
|
|
26
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isOfDeployType,
|
|
3
|
+
getFullKubernetesClusterName,
|
|
4
|
+
} from "@catladder/pipeline";
|
|
5
|
+
import {
|
|
6
|
+
getPipelineContextByChoice,
|
|
7
|
+
parseChoice,
|
|
8
|
+
} from "../../../../../config/getProjectConfig";
|
|
9
|
+
import {
|
|
10
|
+
connectToCluster,
|
|
11
|
+
getCurrentConnectedClusterName,
|
|
12
|
+
} from "../../../../../utils/cluster";
|
|
13
|
+
export default async function (envComponent: string) {
|
|
14
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
15
|
+
const context = await getPipelineContextByChoice(env, componentName);
|
|
16
|
+
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
17
|
+
throw new Error("can't ensure cluster for non-kubernetes deployments");
|
|
18
|
+
}
|
|
19
|
+
const cluster = getFullKubernetesClusterName(
|
|
20
|
+
context.componentConfig.deploy.cluster
|
|
21
|
+
);
|
|
22
|
+
const connectedClusterName = await getCurrentConnectedClusterName();
|
|
23
|
+
|
|
24
|
+
if (cluster !== connectedClusterName) {
|
|
25
|
+
this.log(
|
|
26
|
+
`you are currently connected to cluster '${connectedClusterName}'`
|
|
27
|
+
);
|
|
28
|
+
this.log(`but the project requires cluster '${cluster}'`);
|
|
29
|
+
const { shouldContinue } = await this.prompt({
|
|
30
|
+
type: "confirm",
|
|
31
|
+
name: "shouldContinue",
|
|
32
|
+
default: true,
|
|
33
|
+
message: `Do you want to connect to '${cluster}'?`,
|
|
34
|
+
});
|
|
35
|
+
if (!shouldContinue) {
|
|
36
|
+
this.log("abort");
|
|
37
|
+
} else {
|
|
38
|
+
await connectToCluster(cluster);
|
|
39
|
+
this.log(`connected to cluster '${cluster}'`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Context, getKubernetesNamespace } from "@catladder/pipeline";
|
|
2
|
+
import { V1Namespace, V1ObjectMeta } from "@kubernetes/client-node";
|
|
3
|
+
import { getk8sApi } from "../../../../../k8sApi";
|
|
4
|
+
|
|
5
|
+
export default async function (context: Context) {
|
|
6
|
+
const namespace = getKubernetesNamespace(
|
|
7
|
+
context.fullConfig,
|
|
8
|
+
context.environment.shortName
|
|
9
|
+
);
|
|
10
|
+
const namespaceBody = new V1Namespace();
|
|
11
|
+
const metadata: V1ObjectMeta = {
|
|
12
|
+
name: namespace,
|
|
13
|
+
labels: {
|
|
14
|
+
customerName: context.fullConfig.customerName,
|
|
15
|
+
appName: context.fullConfig.appName,
|
|
16
|
+
environment: context.environment.shortName,
|
|
17
|
+
components: Object.keys(context.fullConfig.components).join("_"), // limited chars available...
|
|
18
|
+
buildTypes: Object.values(context.fullConfig.components)
|
|
19
|
+
.map((config) => config.build.type)
|
|
20
|
+
.join("_"), // limited chars available...
|
|
21
|
+
...Object.fromEntries(
|
|
22
|
+
Object.entries(context.fullConfig.components).map(
|
|
23
|
+
([componentName, config]) => [
|
|
24
|
+
"buildType_" + componentName,
|
|
25
|
+
config.build.type,
|
|
26
|
+
]
|
|
27
|
+
)
|
|
28
|
+
),
|
|
29
|
+
...(context.fullConfig.meta?.labels ?? {}),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
namespaceBody.metadata = metadata;
|
|
34
|
+
const k8sApi = getk8sApi();
|
|
35
|
+
try {
|
|
36
|
+
await k8sApi.readNamespace(namespace);
|
|
37
|
+
|
|
38
|
+
await k8sApi.patchNamespace(
|
|
39
|
+
namespace,
|
|
40
|
+
namespaceBody,
|
|
41
|
+
undefined,
|
|
42
|
+
undefined,
|
|
43
|
+
undefined,
|
|
44
|
+
undefined,
|
|
45
|
+
{ headers: { "content-type": "application/merge-patch+json" } } // see https://github.com/kubernetes-client/javascript/issues/443
|
|
46
|
+
); // update meta data
|
|
47
|
+
} catch (e) {
|
|
48
|
+
if (e.response?.body?.reason === "NotFound") {
|
|
49
|
+
await k8sApi.createNamespace(namespaceBody);
|
|
50
|
+
} else {
|
|
51
|
+
console.error(e.response?.body);
|
|
52
|
+
throw e;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return namespace;
|
|
56
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Vorpal from "vorpal";
|
|
2
|
+
import { getProjectConfig } from "../../../../../config/getProjectConfig";
|
|
3
|
+
|
|
4
|
+
export const showProjectBanner = async (vorpal: Vorpal) => {
|
|
5
|
+
const projectConfig = await getProjectConfig();
|
|
6
|
+
if (projectConfig) {
|
|
7
|
+
vorpal.log("project: " + projectConfig.appName);
|
|
8
|
+
vorpal.log("customer: " + projectConfig.customerName);
|
|
9
|
+
vorpal.log("");
|
|
10
|
+
}
|
|
11
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DeployConfigKubernetesCluster } from "@catladder/pipeline";
|
|
2
|
+
import open from "open";
|
|
3
|
+
|
|
4
|
+
export const openGoogleCloudLogs = async (
|
|
5
|
+
cluster?: DeployConfigKubernetesCluster,
|
|
6
|
+
namespace?: string,
|
|
7
|
+
googleAuthUserNumber = 0
|
|
8
|
+
) => {
|
|
9
|
+
const resource = `k8s_container/cluster_name/${cluster.name}${
|
|
10
|
+
namespace ? `/namespace_name/${namespace}` : ""
|
|
11
|
+
}`;
|
|
12
|
+
|
|
13
|
+
const url = `https://console.cloud.google.com/logs/viewer?project=${
|
|
14
|
+
cluster.projectId
|
|
15
|
+
}${
|
|
16
|
+
resource ? `&resource=${encodeURIComponent(resource)}` : ""
|
|
17
|
+
}&authuser=${googleAuthUserNumber}`;
|
|
18
|
+
open(url);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const openGoogleCloudKubernetesDashboard = async (
|
|
22
|
+
cluster: DeployConfigKubernetesCluster,
|
|
23
|
+
namespace: string,
|
|
24
|
+
googleAuthUserNumber = 0
|
|
25
|
+
) => {
|
|
26
|
+
//gke_skynet-164509_europe-west1-d_production
|
|
27
|
+
// ?authuser=1&project=skynet-swiss&pageState=pageState%3D(%22savedViews%22:(%22c%22:%5B%22gke%2Feurope-west6-a%2Fch-production%22%5D,%22n%22:%5B%22pvl-bike2school-review%22%5D,%22i%22:%224e42e0b9cd6147f8a4fba7516752ec48%22))
|
|
28
|
+
// ?authuser=1&project=skynet-swiss&pageState=(%22savedViews%22:(%22i%22:%2279802e2b154d46d480dff4e086e87875%22,%22c%22:%5B%22gke%2Feurope-west6-a%2Fch-production%22%5D,%22n%22:%5B%22pvl-bike2school-review%22%5D))
|
|
29
|
+
|
|
30
|
+
const pageState = `("savedViews":("c":["gke/${cluster.region}/${cluster.name}"],"n":["${namespace}"],"i":"4e42e0b9cd6147f8a4fba7516752ec48"))`;
|
|
31
|
+
const url = `https://console.cloud.google.com/kubernetes/workload?authuser=${googleAuthUserNumber}&project=${
|
|
32
|
+
cluster.projectId
|
|
33
|
+
}&pageState=${encodeURIComponent(pageState)}`;
|
|
34
|
+
|
|
35
|
+
open(url);
|
|
36
|
+
};
|
|
@@ -2,50 +2,31 @@ import { spawn } from "child-process-promise";
|
|
|
2
2
|
import fetch from "node-fetch";
|
|
3
3
|
import Vorpal from "vorpal";
|
|
4
4
|
|
|
5
|
-
export default (vorpal: Vorpal) => {
|
|
6
|
-
vorpal.command("dadjoke", "something for jonas.").action(async function() {
|
|
5
|
+
export default async (vorpal: Vorpal) => {
|
|
6
|
+
vorpal.command("dadjoke", "something for jonas.").action(async function () {
|
|
7
7
|
const result = await fetch("https://icanhazdadjoke.com/", {
|
|
8
8
|
headers: {
|
|
9
|
-
Accept: "text/plain"
|
|
10
|
-
}
|
|
9
|
+
Accept: "text/plain",
|
|
10
|
+
},
|
|
11
11
|
});
|
|
12
12
|
const text = await result.text();
|
|
13
13
|
this.log("");
|
|
14
14
|
this.log(text);
|
|
15
15
|
this.log("");
|
|
16
16
|
});
|
|
17
|
-
vorpal.command("pantobot", "the allknowing oracle").action(async function() {
|
|
18
|
-
const { message } = await this.prompt({
|
|
19
|
-
type: "string",
|
|
20
|
-
name: "message",
|
|
21
17
|
|
|
22
|
-
message: "Your question, unworthy?: "
|
|
23
|
-
});
|
|
24
|
-
const result = await fetch(
|
|
25
|
-
`https://paas.panter.cloud/api/pantobot/${message}`,
|
|
26
|
-
{
|
|
27
|
-
headers: {
|
|
28
|
-
Accept: "text/plain"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
const text = await result.text();
|
|
33
|
-
this.log("");
|
|
34
|
-
this.log(text);
|
|
35
|
-
this.log("");
|
|
36
|
-
});
|
|
37
18
|
let starwarsPromise: any;
|
|
38
19
|
vorpal
|
|
39
20
|
.command("starwars", "Long time ago... in a galaxy far far away...")
|
|
40
|
-
.action(async function() {
|
|
21
|
+
.action(async function () {
|
|
41
22
|
starwarsPromise = spawn("telnet", ["towel.blinkenlights.nl"], {
|
|
42
|
-
stdio: ["pipe", "inherit", "pipe"]
|
|
23
|
+
stdio: ["pipe", "inherit", "pipe"],
|
|
43
24
|
});
|
|
44
25
|
await starwarsPromise;
|
|
45
26
|
})
|
|
46
27
|
// we need to close it properly, because telnet towel.blinkenlights.nl has no way to cancel and stop itself
|
|
47
28
|
// this is also why we need to only inherit the stdout and not the stdin
|
|
48
|
-
.cancel(async function() {
|
|
29
|
+
.cancel(async function () {
|
|
49
30
|
starwarsPromise.childProcess.kill();
|
|
50
31
|
});
|
|
51
32
|
};
|