@catladder/cli 0.0.0-node16-ddfae617 → 0.0.0-pipeline-variables-a7b0b5d2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/catenv +1 -1
- package/bin/catenv-dev +3 -0
- package/bin/catladder +1 -1
- package/bin/catladder-dev +3 -0
- package/dist/apps/catenv/catenv.d.ts +2 -1
- package/dist/apps/catenv/catenv.js +13 -82
- package/dist/apps/catenv/catenv.js.map +1 -1
- package/dist/apps/catenv/printVariables.d.ts +3 -0
- package/dist/apps/catenv/printVariables.js +112 -0
- package/dist/apps/catenv/printVariables.js.map +1 -0
- package/dist/apps/catenv/types.d.ts +5 -0
- package/dist/apps/catenv/types.js +3 -0
- package/dist/apps/catenv/types.js.map +1 -0
- package/dist/apps/catenv/utils.d.ts +12 -0
- package/dist/apps/catenv/utils.js +108 -0
- package/dist/apps/catenv/utils.js.map +1 -0
- package/dist/apps/catenv/writeDotEnvFiles.d.ts +3 -0
- package/dist/apps/catenv/writeDotEnvFiles.js +94 -0
- package/dist/apps/catenv/writeDotEnvFiles.js.map +1 -0
- package/dist/apps/catenv/writeEnvDTs.d.ts +3 -0
- package/dist/apps/catenv/writeEnvDTs.js +114 -0
- package/dist/apps/catenv/writeEnvDTs.js.map +1 -0
- package/dist/apps/cli/cli.js +4 -2
- package/dist/apps/cli/cli.js.map +1 -1
- package/dist/apps/cli/commands/{project/commandCopyDB.d.ts → cloudSQL/commandRestoreDb.d.ts} +1 -1
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js +180 -0
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +1 -0
- package/dist/apps/cli/commands/cloudSQL/index.d.ts +3 -0
- package/dist/apps/cli/commands/cloudSQL/index.js +50 -0
- package/dist/apps/cli/commands/cloudSQL/index.js.map +1 -0
- package/dist/apps/cli/commands/general/index.d.ts +1 -1
- package/dist/apps/cli/commands/general/index.js +11 -11
- package/dist/apps/cli/commands/general/index.js.map +1 -1
- package/dist/apps/cli/commands/general/portForward.d.ts +1 -1
- package/dist/apps/cli/commands/general/portForward.js +3 -3
- package/dist/apps/cli/commands/general/portForward.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/index.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +2 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +27 -11
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/utils/index.js +16 -4
- package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -1
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +89 -62
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +71 -57
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/apps/cli/commands/project/commandDeletePods.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandDeletePods.js +2 -1
- package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -1
- package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandEnvVars.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandEnvVars.js +1 -1
- package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -1
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +1 -1
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -1
- package/dist/apps/cli/commands/project/commandGetShell.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetShell.js +10 -6
- package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -1
- package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
- package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandListPods.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandListPods.js +2 -2
- package/dist/apps/cli/commands/project/commandListPods.js.map +1 -1
- package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js +1 -2
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -1
- package/dist/apps/cli/commands/project/commandNamespace.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +2 -2
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenDashboard.js +19 -20
- package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGit.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGit.js +2 -7
- package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafana.js +2 -2
- package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +4 -3
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenLogs.js +7 -20
- package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -1
- package/dist/apps/cli/commands/project/commandPauseProject.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandPortForward.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandPortForward.js +98 -36
- package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -1
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
- package/dist/apps/cli/commands/project/commandSetup.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -1
- package/dist/apps/cli/commands/project/index.d.ts +1 -1
- package/dist/apps/cli/commands/project/index.js +2 -2
- package/dist/apps/cli/commands/project/index.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/index.d.ts +1 -1
- package/dist/apps/cli/commands/project/setup/index.js +11 -7
- package/dist/apps/cli/commands/project/setup/index.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -1
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +5 -4
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupCloudRun.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.js +118 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
- package/dist/apps/cli/commands/project/setup/setupContext.js +10 -3
- package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js +25 -18
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupTopic.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.js +69 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -1
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
- package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -1
- package/dist/apps/cli/config/writeConfig.d.ts +2 -2
- package/dist/apps/cli/verify/index.d.ts +1 -1
- package/dist/apps/cli/verify/migration/fromv2.d.ts +1 -1
- package/dist/apps/cli/verify/migration/fromv2.js +2 -0
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
- package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +3 -3
- package/dist/apps/cli/verify/migration/migrateSecrets.js +6 -3
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +1 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.js +1 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -1
- package/dist/bundles/catenv/index.js +46001 -0
- package/dist/bundles/catenv/xdg-open +1066 -0
- package/dist/bundles/cli/clipboard_i686.exe +0 -0
- package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
- package/dist/bundles/cli/exec-child.js +39 -0
- package/dist/bundles/cli/index.js +359572 -0
- package/dist/bundles/cli/xdg-open +1066 -0
- package/dist/bundles/cli/xsel +0 -0
- package/dist/catenv.js +3 -3
- package/dist/catenv.js.map +1 -1
- package/dist/cli.js +0 -7
- package/dist/cli.js.map +1 -1
- package/dist/config/constants.d.ts +0 -1
- package/dist/config/constants.js +1 -2
- package/dist/config/constants.js.map +1 -1
- package/dist/config/getProjectConfig.d.ts +10 -10
- package/dist/config/getProjectConfig.js +77 -23
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/config/parseChoice.d.ts +4 -0
- package/dist/config/parseChoice.js +9 -0
- package/dist/config/parseChoice.js.map +1 -0
- package/dist/gcloud/artifactsRegistry.d.ts +5 -0
- package/dist/gcloud/artifactsRegistry.js +59 -0
- package/dist/gcloud/artifactsRegistry.js.map +1 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.d.ts +2 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +67 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.d.ts +3 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js +62 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -0
- package/dist/gcloud/cloudSql/startProxy.d.ts +10 -0
- package/dist/gcloud/cloudSql/startProxy.js +121 -0
- package/dist/gcloud/cloudSql/startProxy.js.map +1 -0
- package/dist/gcloud/enableServices.d.ts +3 -0
- package/dist/gcloud/enableServices.js +63 -0
- package/dist/gcloud/enableServices.js.map +1 -0
- package/dist/gcloud/openDashboard.d.ts +2 -0
- package/dist/{apps/cli/commands/shared/index.js → gcloud/openDashboard.js} +23 -27
- package/dist/gcloud/openDashboard.js.map +1 -0
- package/dist/gcloud/serviceAccounts.d.ts +12 -0
- package/dist/gcloud/serviceAccounts.js +144 -0
- package/dist/gcloud/serviceAccounts.js.map +1 -0
- package/dist/kubernetes/index.d.ts +3 -0
- package/dist/kubernetes/index.js +88 -0
- package/dist/kubernetes/index.js.map +1 -0
- package/dist/kubernetes/openKubernetesDashboards.d.ts +4 -0
- package/dist/kubernetes/openKubernetesDashboards.js +94 -0
- package/dist/kubernetes/openKubernetesDashboards.js.map +1 -0
- package/dist/kubernetes/portForward.d.ts +1 -0
- package/dist/kubernetes/portForward.js +55 -0
- package/dist/kubernetes/portForward.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/cluster.js +3 -8
- package/dist/utils/cluster.js.map +1 -1
- package/dist/utils/gitlab.d.ts +8 -6
- package/dist/utils/gitlab.js +165 -46
- package/dist/utils/gitlab.js.map +1 -1
- package/dist/utils/passwordstore/index.d.ts +0 -1
- package/dist/utils/passwordstore/index.js +1 -64
- package/dist/utils/passwordstore/index.js.map +1 -1
- package/dist/utils/portForwards.d.ts +12 -0
- package/dist/utils/{portForward.js → portForwards.js} +20 -16
- package/dist/utils/portForwards.js.map +1 -0
- package/dist/utils/projects/index.d.ts +0 -3
- package/dist/utils/projects/index.js +3 -53
- package/dist/utils/projects/index.js.map +1 -1
- package/package.json +24 -22
- package/scripts/bundle +4 -0
- package/src/apps/catenv/catenv.ts +10 -54
- package/src/apps/catenv/printVariables.ts +53 -0
- package/src/apps/catenv/types.ts +6 -0
- package/src/apps/catenv/utils.ts +49 -0
- package/src/apps/catenv/writeDotEnvFiles.ts +46 -0
- package/src/apps/catenv/writeEnvDTs.ts +71 -0
- package/src/apps/cli/cli.ts +3 -1
- package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +154 -0
- package/src/apps/cli/commands/cloudSQL/index.ts +8 -0
- package/src/apps/cli/commands/general/index.ts +11 -8
- package/src/apps/cli/commands/general/portForward.ts +4 -4
- package/src/apps/cli/commands/mongodb/index.ts +1 -1
- package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +3 -5
- package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +1 -1
- package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +21 -3
- package/src/apps/cli/commands/mongodb/utils/index.ts +19 -11
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +106 -55
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +49 -35
- package/src/apps/cli/commands/project/commandDeletePods.ts +3 -5
- package/src/apps/cli/commands/project/commandDeleteProject.ts +1 -1
- package/src/apps/cli/commands/project/commandEnvVars.ts +6 -3
- package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +2 -2
- package/src/apps/cli/commands/project/commandGetShell.ts +10 -9
- package/src/apps/cli/commands/project/commandGitlabCi.ts +2 -1
- package/src/apps/cli/commands/project/commandInitProject.old.ts +1 -1
- package/src/apps/cli/commands/project/commandListPods.ts +2 -2
- package/src/apps/cli/commands/project/commandMigrateHelm3.ts +4 -3
- package/src/apps/cli/commands/project/commandNamespace.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +3 -3
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +12 -32
- package/src/apps/cli/commands/project/commandOpenEnv.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenGit.ts +3 -3
- package/src/apps/cli/commands/project/commandOpenGrafana.ts +3 -3
- package/src/apps/cli/commands/project/commandOpenGrafanaPod.ts +5 -7
- package/src/apps/cli/commands/project/commandOpenLogs.ts +4 -35
- package/src/apps/cli/commands/project/commandPauseProject.ts +1 -1
- package/src/apps/cli/commands/project/commandPortForward.ts +75 -34
- package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
- package/src/apps/cli/commands/project/commandSetup.ts +1 -1
- package/src/apps/cli/commands/project/commandTriggerCronjob.ts +3 -2
- package/src/apps/cli/commands/project/index.ts +4 -3
- package/src/apps/cli/commands/project/setup/index.ts +3 -1
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +23 -11
- package/src/apps/cli/commands/project/setup/setupCloudRun.ts +84 -0
- package/src/apps/cli/commands/project/setup/setupContext.ts +9 -2
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +56 -28
- package/src/apps/cli/commands/project/setup/setupTopic.ts +22 -0
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +4 -2
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +1 -1
- package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +2 -2
- package/src/apps/cli/config/writeConfig.ts +2 -2
- package/src/apps/cli/verify/index.ts +1 -1
- package/src/apps/cli/verify/migration/fromv2.ts +5 -7
- package/src/apps/cli/verify/migration/migrateSecrets.ts +15 -5
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +2 -2
- package/src/catenv.ts +6 -3
- package/src/cli.ts +1 -7
- package/src/config/constants.ts +0 -2
- package/src/config/getProjectConfig.ts +70 -30
- package/src/config/parseChoice.ts +4 -0
- package/src/gcloud/artifactsRegistry.ts +16 -0
- package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +35 -0
- package/src/gcloud/cloudRun/openCloudRunDashboards.ts +22 -0
- package/src/gcloud/cloudSql/startProxy.ts +74 -0
- package/src/gcloud/enableServices.ts +14 -0
- package/src/gcloud/openDashboard.ts +19 -0
- package/src/gcloud/serviceAccounts.ts +101 -0
- package/src/kubernetes/index.ts +27 -0
- package/src/kubernetes/openKubernetesDashboards.ts +52 -0
- package/src/kubernetes/portForward.ts +15 -0
- package/src/types/child-process-promise.d.ts +37 -1
- package/src/utils/cluster.ts +3 -3
- package/src/utils/gitlab.ts +141 -30
- package/src/utils/passwordstore/index.ts +2 -30
- package/src/utils/{portForward.ts → portForwards.ts} +27 -22
- package/src/utils/projects/index.ts +3 -24
- package/tsconfig.json +1 -1
- package/dist/apps/cli/commands/project/commandCopyDB.js +0 -102
- package/dist/apps/cli/commands/project/commandCopyDB.js.map +0 -1
- package/dist/apps/cli/commands/shared/index.d.ts +0 -3
- package/dist/apps/cli/commands/shared/index.js.map +0 -1
- package/dist/utils/portForward.d.ts +0 -4
- package/dist/utils/portForward.js.map +0 -1
- package/src/apps/cli/commands/project/commandCopyDB.ts +0 -91
- package/src/apps/cli/commands/shared/index.ts +0 -36
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { exec } from "child-process-promise";
|
|
2
|
-
import Vorpal from "vorpal";
|
|
2
|
+
import type Vorpal from "vorpal";
|
|
3
3
|
import {
|
|
4
4
|
getEnvironment,
|
|
5
5
|
parseChoice,
|
|
@@ -43,8 +43,9 @@ export default async (vorpal: Vorpal) =>
|
|
|
43
43
|
// ignore
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
// we use the app full name as the release name
|
|
47
|
+
const releaseName = (await getEnvironment(env, componentName)).fullName;
|
|
48
|
+
|
|
48
49
|
this.log(`helm release name: ${releaseName}`);
|
|
49
50
|
this.log("");
|
|
50
51
|
this.log("migrating now... 😼. This may take a moment");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import open from "open";
|
|
2
|
-
import Vorpal from "vorpal";
|
|
2
|
+
import type Vorpal from "vorpal";
|
|
3
3
|
import {
|
|
4
4
|
GRAFANA_PROXY_LOCAL_PORT,
|
|
5
5
|
GRAFANA_PROXY_TARGET_PORT,
|
|
6
6
|
} from "../../../../config/constants";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { startKubePortForward } from "../../../../kubernetes/portForward";
|
|
9
9
|
|
|
10
10
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
11
11
|
|
|
@@ -22,7 +22,7 @@ export default async (vorpal: Vorpal) =>
|
|
|
22
22
|
await ensureCluster.call(this, envComponent);
|
|
23
23
|
const namespace = await getProjectNamespace(envComponent);
|
|
24
24
|
const url = `http://localhost:${GRAFANA_PROXY_LOCAL_PORT}/namespace.html?name=${namespace}`;
|
|
25
|
-
await
|
|
25
|
+
await startKubePortForward(
|
|
26
26
|
"deployment/kubecost-cost-analyzer",
|
|
27
27
|
GRAFANA_PROXY_LOCAL_PORT,
|
|
28
28
|
GRAFANA_PROXY_TARGET_PORT,
|
|
@@ -1,48 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
2
|
+
import type Vorpal from "vorpal";
|
|
2
3
|
import {
|
|
3
4
|
getPipelineContextByChoice,
|
|
4
5
|
parseChoice,
|
|
5
6
|
} from "../../../../config/getProjectConfig";
|
|
6
|
-
import {
|
|
7
|
-
import { openGoogleCloudKubernetesDashboard } from "
|
|
7
|
+
import { openGoogleCloudRunDashboard } from "../../../../gcloud/cloudRun/openCloudRunDashboards";
|
|
8
|
+
import { openGoogleCloudKubernetesDashboard } from "../../../../kubernetes/openKubernetesDashboards";
|
|
9
|
+
|
|
8
10
|
import { envAndComponents } from "./utils/autocompletions";
|
|
11
|
+
|
|
9
12
|
export default async (vorpal: Vorpal) =>
|
|
10
13
|
vorpal
|
|
11
14
|
.command(
|
|
12
15
|
"project-open-dashboard <envComponent>",
|
|
13
|
-
"open
|
|
16
|
+
"open an apps dashboard (kubernetes or cloudrun)"
|
|
14
17
|
)
|
|
15
18
|
.autocomplete(await envAndComponents())
|
|
16
19
|
.action(async function ({ envComponent }) {
|
|
17
20
|
const { env, componentName } = parseChoice(envComponent);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
!componentConfig.deploy ||
|
|
25
|
-
componentConfig.deploy.type !== "kubernetes"
|
|
26
|
-
) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
"only kubernetes deployments are supported at the moment"
|
|
29
|
-
);
|
|
21
|
+
const context = await getPipelineContextByChoice(env, componentName);
|
|
22
|
+
if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
23
|
+
await openGoogleCloudKubernetesDashboard(this, context);
|
|
30
24
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
!componentConfig.deploy.cluster ||
|
|
34
|
-
componentConfig.deploy.cluster.type !== "gcloud"
|
|
35
|
-
) {
|
|
36
|
-
throw new Error("no gcloud custer configured");
|
|
25
|
+
if (isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
26
|
+
await openGoogleCloudRunDashboard(this, context);
|
|
37
27
|
}
|
|
38
|
-
// currently only supports kubernetes
|
|
39
|
-
const namespace = environment.envVars.KUBE_NAMESPACE;
|
|
40
|
-
|
|
41
|
-
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
42
|
-
|
|
43
|
-
openGoogleCloudKubernetesDashboard(
|
|
44
|
-
componentConfig.deploy.cluster,
|
|
45
|
-
namespace,
|
|
46
|
-
authGoogleNumber
|
|
47
|
-
);
|
|
48
28
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Vorpal from "vorpal";
|
|
2
|
-
import {
|
|
1
|
+
import type Vorpal from "vorpal";
|
|
2
|
+
import { exec } from "child-process-promise";
|
|
3
3
|
|
|
4
4
|
export default async (vorpal: Vorpal) =>
|
|
5
5
|
vorpal
|
|
@@ -8,5 +8,5 @@ export default async (vorpal: Vorpal) =>
|
|
|
8
8
|
"open the repo on gitlab / github in your browser"
|
|
9
9
|
)
|
|
10
10
|
.action(async () => {
|
|
11
|
-
await
|
|
11
|
+
await exec("npx git-open");
|
|
12
12
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import open from "open";
|
|
2
|
-
import {
|
|
3
|
-
import Vorpal from "vorpal";
|
|
2
|
+
import { startKubePortForward } from "../../../../kubernetes/portForward";
|
|
3
|
+
import type Vorpal from "vorpal";
|
|
4
4
|
import {
|
|
5
5
|
GRAFANA_PROXY_LOCAL_PORT,
|
|
6
6
|
GRAFANA_PROXY_TARGET_PORT,
|
|
@@ -21,7 +21,7 @@ export default async (vorpal: Vorpal) =>
|
|
|
21
21
|
await ensureCluster.call(this, envComponent);
|
|
22
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
|
-
await
|
|
24
|
+
await startKubePortForward(
|
|
25
25
|
"deployment/kubecost-cost-analyzer",
|
|
26
26
|
GRAFANA_PROXY_LOCAL_PORT,
|
|
27
27
|
GRAFANA_PROXY_TARGET_PORT,
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import open from "open";
|
|
2
|
-
import Vorpal from "vorpal";
|
|
2
|
+
import type Vorpal from "vorpal";
|
|
3
3
|
import {
|
|
4
4
|
GRAFANA_PROXY_LOCAL_PORT,
|
|
5
5
|
GRAFANA_PROXY_TARGET_PORT,
|
|
6
6
|
} from "../../../../config/constants";
|
|
7
|
+
import { getProjectPodNames } from "../../../../kubernetes";
|
|
7
8
|
import { logError } from "../../../../utils/log";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
getProjectNamespace,
|
|
11
|
-
getProjectPodNames,
|
|
12
|
-
} from "../../../../utils/projects";
|
|
9
|
+
import { startKubePortForward } from "../../../../kubernetes/portForward";
|
|
10
|
+
import { getProjectNamespace } from "../../../../utils/projects";
|
|
13
11
|
import { envAndComponents } from "./utils/autocompletions";
|
|
14
12
|
import ensureCluster from "./utils/ensureCluster";
|
|
15
13
|
|
|
@@ -35,7 +33,7 @@ export default async (vorpal: Vorpal) =>
|
|
|
35
33
|
});
|
|
36
34
|
const namespace = await getProjectNamespace(envComponent);
|
|
37
35
|
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}`;
|
|
38
|
-
await
|
|
36
|
+
await startKubePortForward(
|
|
39
37
|
"deployment/kubecost-cost-analyzer",
|
|
40
38
|
GRAFANA_PROXY_LOCAL_PORT,
|
|
41
39
|
GRAFANA_PROXY_TARGET_PORT,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import Vorpal from "vorpal";
|
|
1
|
+
import type Vorpal from "vorpal";
|
|
2
2
|
import {
|
|
3
3
|
getPipelineContextByChoice,
|
|
4
4
|
parseChoice,
|
|
5
5
|
} from "../../../../config/getProjectConfig";
|
|
6
|
-
import {
|
|
7
|
-
import { getProjectNamespace } from "../../../../utils/projects";
|
|
8
|
-
import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
|
|
9
|
-
import { openGoogleCloudLogs } from "../shared";
|
|
6
|
+
import { openGoogleCloudLogs } from "../../../../kubernetes/openKubernetesDashboards";
|
|
10
7
|
import { envAndComponents } from "./utils/autocompletions";
|
|
11
|
-
import ensureCluster from "./utils/ensureCluster";
|
|
12
8
|
|
|
13
9
|
export default async (vorpal: Vorpal) =>
|
|
14
10
|
vorpal
|
|
@@ -19,34 +15,7 @@ export default async (vorpal: Vorpal) =>
|
|
|
19
15
|
.autocomplete(await envAndComponents())
|
|
20
16
|
.action(async function ({ envComponent }) {
|
|
21
17
|
const { env, componentName } = parseChoice(envComponent);
|
|
22
|
-
const
|
|
23
|
-
env,
|
|
24
|
-
componentName
|
|
25
|
-
);
|
|
18
|
+
const context = await getPipelineContextByChoice(env, componentName);
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
!componentConfig.deploy ||
|
|
29
|
-
componentConfig.deploy.type !== "kubernetes"
|
|
30
|
-
) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
"only kubernetes deployments are supported at the moment"
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
!componentConfig.deploy.cluster ||
|
|
38
|
-
componentConfig.deploy.cluster.type !== "gcloud"
|
|
39
|
-
) {
|
|
40
|
-
throw new Error("no gcloud custer configured");
|
|
41
|
-
}
|
|
42
|
-
// currently only supports kubernetes
|
|
43
|
-
const namespace = environment.envVars.KUBE_NAMESPACE;
|
|
44
|
-
|
|
45
|
-
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
46
|
-
|
|
47
|
-
await openGoogleCloudLogs(
|
|
48
|
-
componentConfig.deploy.cluster,
|
|
49
|
-
namespace,
|
|
50
|
-
authGoogleNumber
|
|
51
|
-
);
|
|
20
|
+
await openGoogleCloudLogs(this, context);
|
|
52
21
|
});
|
|
@@ -1,45 +1,86 @@
|
|
|
1
|
-
import Vorpal from "vorpal";
|
|
1
|
+
import type Vorpal from "vorpal";
|
|
2
|
+
import { getProjectPodNames } from "../../../../kubernetes";
|
|
2
3
|
import { logError } from "../../../../utils/log";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
getProjectNamespace,
|
|
6
|
-
getProjectPodNames,
|
|
7
|
-
} from "../../../../utils/projects";
|
|
4
|
+
import { startKubePortForward } from "../../../../kubernetes/portForward";
|
|
5
|
+
import { getProjectNamespace } from "../../../../utils/projects";
|
|
8
6
|
import { envAndComponents } from "./utils/autocompletions";
|
|
9
7
|
import ensureCluster from "./utils/ensureCluster";
|
|
8
|
+
import type { CommandInstance } from "vorpal";
|
|
9
|
+
import { parseChoice } from "../../../../config/parseChoice";
|
|
10
|
+
import { getPipelineContextByChoice } from "../../../../config/getProjectConfig";
|
|
11
|
+
import type { Context } from "@catladder/pipeline";
|
|
12
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
13
|
+
import { startPortForwardCommand } from "../../../../utils/portForwards";
|
|
14
|
+
import open from "open";
|
|
15
|
+
const kubePortForward = async (cmd: CommandInstance, envComponent: string) => {
|
|
16
|
+
await ensureCluster.call(cmd, envComponent);
|
|
17
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
18
|
+
const podNames = await getProjectPodNames(envComponent);
|
|
19
|
+
if (podNames.length === 0) {
|
|
20
|
+
logError(cmd, "sorry, no pods found");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const { podName } = await cmd.prompt({
|
|
24
|
+
type: "list",
|
|
25
|
+
name: "podName",
|
|
26
|
+
choices: podNames,
|
|
27
|
+
message: "Which pod? 🤔",
|
|
28
|
+
});
|
|
10
29
|
|
|
30
|
+
const { localPort } = await cmd.prompt({
|
|
31
|
+
type: "number",
|
|
32
|
+
name: "localPort",
|
|
33
|
+
|
|
34
|
+
message: "Local port: ",
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const { remotePort } = await cmd.prompt({
|
|
38
|
+
type: "number",
|
|
39
|
+
name: "remotePort",
|
|
40
|
+
|
|
41
|
+
message: "Remote port: ",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return startKubePortForward(podName, localPort, remotePort, namespace);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const cloudRunPortForward = async (cmd: CommandInstance, context: Context) => {
|
|
48
|
+
if (!isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
49
|
+
throw new Error("not cloud run");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { fullName } = context.environment;
|
|
53
|
+
let serviceName = fullName;
|
|
54
|
+
if (context.environment.envType === "review") {
|
|
55
|
+
const { mr } = await cmd.prompt({
|
|
56
|
+
type: "number",
|
|
57
|
+
name: "mr",
|
|
58
|
+
|
|
59
|
+
message: "Which mr 🤔 ",
|
|
60
|
+
});
|
|
61
|
+
// poor mans solution
|
|
62
|
+
serviceName = serviceName.replace("-review-", "-review-mr" + mr + "-");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const { projectId, region } = context.componentConfig.deploy;
|
|
66
|
+
|
|
67
|
+
const command = `gcloud beta run services proxy ${serviceName} --project ${projectId} --region ${region}`;
|
|
68
|
+
|
|
69
|
+
await startPortForwardCommand(`cloudRun/${serviceName}`, command);
|
|
70
|
+
open("http://localhost:8080");
|
|
71
|
+
};
|
|
11
72
|
export default async (vorpal: Vorpal) =>
|
|
12
73
|
vorpal
|
|
13
74
|
.command("project-port-forward <envComponent>", "start port-forwarding")
|
|
14
75
|
.autocomplete(await envAndComponents())
|
|
15
76
|
.action(async function ({ envComponent }) {
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const podNames = await getProjectPodNames(envComponent);
|
|
19
|
-
if (podNames.length === 0) {
|
|
20
|
-
logError(this, "sorry, no pods found");
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const { podName } = await this.prompt({
|
|
24
|
-
type: "list",
|
|
25
|
-
name: "podName",
|
|
26
|
-
choices: podNames,
|
|
27
|
-
message: "Which pod? 🤔",
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const { localPort } = await this.prompt({
|
|
31
|
-
type: "number",
|
|
32
|
-
name: "localPort",
|
|
33
|
-
|
|
34
|
-
message: "Local port: ",
|
|
35
|
-
});
|
|
77
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
78
|
+
const context = await getPipelineContextByChoice(env, componentName);
|
|
36
79
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return startPortForward(podName, localPort, remotePort, namespace);
|
|
80
|
+
if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
81
|
+
await kubePortForward(this, envComponent);
|
|
82
|
+
}
|
|
83
|
+
if (isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
84
|
+
await cloudRunPortForward(this, context);
|
|
85
|
+
}
|
|
45
86
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-disable no-constant-condition */
|
|
2
|
+
import type Vorpal from "vorpal";
|
|
3
|
+
import type { CommandInstance } from "vorpal";
|
|
4
|
+
import { clearBackups } from "../../../../utils/gitlab";
|
|
5
|
+
import { allEnvsAndAllComponents } from "./utils/autocompletions";
|
|
6
|
+
|
|
7
|
+
export const projectSecretsClearBackups = async (
|
|
8
|
+
vorpal: CommandInstance,
|
|
9
|
+
keep = 3
|
|
10
|
+
) => {
|
|
11
|
+
await clearBackups(vorpal, keep);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default async (vorpal: Vorpal) => {
|
|
15
|
+
vorpal
|
|
16
|
+
.command("project-secrets-clear-backups", "clears all backups")
|
|
17
|
+
.autocomplete(await allEnvsAndAllComponents())
|
|
18
|
+
.action(async function () {
|
|
19
|
+
const { keep } = await this.prompt({
|
|
20
|
+
type: "number",
|
|
21
|
+
name: "keep",
|
|
22
|
+
default: 1,
|
|
23
|
+
message: "How many backups should we keep? 🤔",
|
|
24
|
+
});
|
|
25
|
+
return await projectSecretsClearBackups(this, keep);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { V1ObjectMeta } from "@kubernetes/client-node";
|
|
2
|
+
import { V1Job } from "@kubernetes/client-node";
|
|
2
3
|
|
|
3
|
-
import Vorpal from "vorpal";
|
|
4
|
+
import type Vorpal from "vorpal";
|
|
4
5
|
import { getk8sApiBatch, getk8sApiBatchBeta } from "../../../../k8sApi";
|
|
5
6
|
import { logError } from "../../../../utils/log";
|
|
6
7
|
import { namespaceAutoCompletion } from "../general/namespaceAutoCompletion";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Vorpal from "vorpal";
|
|
1
|
+
import type Vorpal from "vorpal";
|
|
2
2
|
import commandCloudSqlProxy from "./commandCloudSqlProxy";
|
|
3
3
|
import commandConfigSecrets from "./commandConfigSecrets";
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import commandDeletePods from "./commandDeletePods";
|
|
6
6
|
import commandDeleteProject from "./commandDeleteProject";
|
|
7
7
|
import commandEnvVars from "./commandEnvVars";
|
|
@@ -24,6 +24,7 @@ import commandPortForward from "./commandPortForward";
|
|
|
24
24
|
import commandTriggerCronjob from "./commandTriggerCronjob";
|
|
25
25
|
|
|
26
26
|
import commandOpenGrafanaPod from "./commandOpenGrafanaPod";
|
|
27
|
+
import commandSecretsClearBackups from "./commandSecretsClearBackups";
|
|
27
28
|
|
|
28
29
|
export default async (vorpal: Vorpal) => {
|
|
29
30
|
commandSetup(vorpal);
|
|
@@ -48,8 +49,8 @@ export default async (vorpal: Vorpal) => {
|
|
|
48
49
|
commandOpenEnv(vorpal);
|
|
49
50
|
commandTriggerCronjob(vorpal);
|
|
50
51
|
commandConfigSecrets(vorpal);
|
|
52
|
+
commandSecretsClearBackups(vorpal);
|
|
51
53
|
commandDeletePods(vorpal);
|
|
52
|
-
commandCopyDB(vorpal);
|
|
53
54
|
|
|
54
55
|
commandGetShell(vorpal);
|
|
55
56
|
commandPortForward(vorpal);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { CommandInstance } from "vorpal";
|
|
1
|
+
import type { CommandInstance } from "vorpal";
|
|
2
2
|
import { getAllPipelineContexts } from "../../../../../config/getProjectConfig";
|
|
3
3
|
import { projectConfigSecrets } from "../commandConfigSecrets";
|
|
4
4
|
import { setupAccessTokens } from "./setupAccessTokens";
|
|
5
5
|
import { setupContext } from "./setupContext";
|
|
6
|
+
import { setupTopic } from "./setupTopic";
|
|
6
7
|
|
|
7
8
|
export const setupProject = async (instance: CommandInstance) => {
|
|
8
9
|
const allContext = await getAllPipelineContexts();
|
|
@@ -11,6 +12,7 @@ export const setupProject = async (instance: CommandInstance) => {
|
|
|
11
12
|
await setupContext(instance, context);
|
|
12
13
|
}
|
|
13
14
|
await setupAccessTokens(instance);
|
|
15
|
+
await setupTopic(instance);
|
|
14
16
|
instance.log("");
|
|
15
17
|
const { configSecrets } = await instance.prompt({
|
|
16
18
|
default: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import open from "open";
|
|
2
|
-
import { CommandInstance } from "vorpal";
|
|
2
|
+
import type { CommandInstance } from "vorpal";
|
|
3
3
|
import { doGitlabRequest, getProjectInfo } from "../../../../../utils/gitlab";
|
|
4
4
|
|
|
5
5
|
export const setupAccessTokens = async (instance: CommandInstance) => {
|
|
@@ -18,7 +18,7 @@ export const setupAccessTokens = async (instance: CommandInstance) => {
|
|
|
18
18
|
"I need add a GL_TOKEN to the project, so that semantic release will work\n"
|
|
19
19
|
);
|
|
20
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"
|
|
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 - role: maintainer - scopes: api, read_repository"
|
|
22
22
|
);
|
|
23
23
|
instance.log("\n");
|
|
24
24
|
|
|
@@ -43,10 +43,17 @@ export const setupAccessTokens = async (instance: CommandInstance) => {
|
|
|
43
43
|
name: "GL_TOKEN",
|
|
44
44
|
message: "Access Token: ",
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
|
|
47
|
+
await doGitlabRequest(
|
|
48
|
+
instance,
|
|
49
|
+
`projects/${projectId}/variables`,
|
|
50
|
+
{
|
|
51
|
+
key: "GL_TOKEN",
|
|
52
|
+
value: GL_TOKEN,
|
|
53
|
+
masked: true,
|
|
54
|
+
},
|
|
55
|
+
"POST"
|
|
56
|
+
);
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
const deploy_tokens = await doGitlabRequest(
|
|
@@ -63,10 +70,15 @@ export const setupAccessTokens = async (instance: CommandInstance) => {
|
|
|
63
70
|
"I will setup the 'GitLab Deploy Token', so Kubernetes can pull images from this project."
|
|
64
71
|
);
|
|
65
72
|
|
|
66
|
-
await doGitlabRequest(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
await doGitlabRequest(
|
|
74
|
+
instance,
|
|
75
|
+
`projects/${projectId}/deploy_tokens`,
|
|
76
|
+
{
|
|
77
|
+
id: projectId,
|
|
78
|
+
name: "gitlab-deploy-token",
|
|
79
|
+
scopes: ["read_registry"],
|
|
80
|
+
},
|
|
81
|
+
"POST"
|
|
82
|
+
);
|
|
71
83
|
}
|
|
72
84
|
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
import {
|
|
3
|
+
GCLOUD_DEPLOY_CREDENTIALS_KEY,
|
|
4
|
+
GCLOUD_RUN_CANONICAL_HOST_SUFFIX,
|
|
5
|
+
isOfDeployType,
|
|
6
|
+
} from "@catladder/pipeline";
|
|
7
|
+
|
|
8
|
+
import type { CommandInstance } from "vorpal";
|
|
9
|
+
import { upsertGcloudArtifactsRegistry } from "../../../../../gcloud/artifactsRegistry";
|
|
10
|
+
import { getCloudRunDomainSuffix } from "../../../../../gcloud/cloudRun/getCloudRunDomainSuffix";
|
|
11
|
+
import { enableGCloudServices } from "../../../../../gcloud/enableServices";
|
|
12
|
+
import { upsertGcloudServiceAccountAndSaveSecret } from "../../../../../gcloud/serviceAccounts";
|
|
13
|
+
import { upsertAllVariables } from "../../../../../utils/gitlab";
|
|
14
|
+
|
|
15
|
+
export const setupCloudRun = async (
|
|
16
|
+
instance: CommandInstance,
|
|
17
|
+
context: Context
|
|
18
|
+
) => {
|
|
19
|
+
if (!isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
20
|
+
throw new Error("deploy config is not of type 'google-cloudrun'");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const config = context.componentConfig.deploy;
|
|
24
|
+
|
|
25
|
+
// enable services
|
|
26
|
+
|
|
27
|
+
instance.log("enable required servies...");
|
|
28
|
+
await enableGCloudServices(
|
|
29
|
+
[
|
|
30
|
+
"run.googleapis.com",
|
|
31
|
+
"artifactregistry.googleapis.com",
|
|
32
|
+
"cloudscheduler.googleapis.com", // for scheduling jobs
|
|
33
|
+
"cloudresourcemanager.googleapis.com", // only required to get google cloud project number
|
|
34
|
+
...(config.cloudSql
|
|
35
|
+
? ["sqladmin.googleapis.com", "sql-component.googleapis.com"]
|
|
36
|
+
: []),
|
|
37
|
+
],
|
|
38
|
+
config
|
|
39
|
+
);
|
|
40
|
+
instance.log("upsert artifacts registry...");
|
|
41
|
+
await upsertGcloudArtifactsRegistry(config);
|
|
42
|
+
|
|
43
|
+
instance.log("upsert deploy service account...");
|
|
44
|
+
await upsertGcloudServiceAccountAndSaveSecret(
|
|
45
|
+
instance,
|
|
46
|
+
context,
|
|
47
|
+
{
|
|
48
|
+
projectId: config.projectId,
|
|
49
|
+
displayName: "Catladder gcloud deploy",
|
|
50
|
+
description: "This service account deploys to google cloud",
|
|
51
|
+
name: "cl-d",
|
|
52
|
+
// TODO: run.admin is a bit much, would be better to follow https://stackoverflow.com/questions/55788714/deploying-to-cloud-run-with-a-custom-service-account-failed-with-iam-serviceacco
|
|
53
|
+
roles: [
|
|
54
|
+
"roles/artifactregistry.repoAdmin",
|
|
55
|
+
"roles/run.admin",
|
|
56
|
+
"roles/iam.serviceAccountUser",
|
|
57
|
+
"roles/cloudscheduler.admin", // for scheduling
|
|
58
|
+
...(config.cloudSql ? ["roles/cloudsql.admin"] : []),
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
GCLOUD_DEPLOY_CREDENTIALS_KEY
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// gcloud run automatically gives us a hostname
|
|
65
|
+
// but the pipeline need to know it before deployment
|
|
66
|
+
// so we get this through some magic and add this as a ci/cd variable
|
|
67
|
+
// the pipeline than can use this to construct the canonical host
|
|
68
|
+
instance.log(
|
|
69
|
+
"get service domain suffix... that might take a while initially"
|
|
70
|
+
);
|
|
71
|
+
const suffix = await getCloudRunDomainSuffix(config);
|
|
72
|
+
instance.log("domain suffix: " + suffix);
|
|
73
|
+
|
|
74
|
+
await upsertAllVariables(
|
|
75
|
+
instance,
|
|
76
|
+
{
|
|
77
|
+
[GCLOUD_RUN_CANONICAL_HOST_SUFFIX]: suffix,
|
|
78
|
+
},
|
|
79
|
+
context.environment.shortName,
|
|
80
|
+
context.componentName,
|
|
81
|
+
false, // backup
|
|
82
|
+
false // masked
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { Context
|
|
2
|
-
import {
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
|
+
import type { CommandInstance } from "vorpal";
|
|
4
|
+
import { setupCloudRun } from "./setupCloudRun";
|
|
5
|
+
|
|
3
6
|
import { setupKubernetes } from "./setupKubernetes";
|
|
4
7
|
|
|
5
8
|
export const setupContext = async (
|
|
@@ -19,6 +22,10 @@ export const setupContext = async (
|
|
|
19
22
|
"..."
|
|
20
23
|
);
|
|
21
24
|
instance.log("");
|
|
25
|
+
if (isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
26
|
+
await setupCloudRun(instance, context);
|
|
27
|
+
}
|
|
28
|
+
|
|
22
29
|
const deployConfig = context.componentConfig.deploy;
|
|
23
30
|
if (isOfDeployType(deployConfig, "kubernetes")) {
|
|
24
31
|
await setupKubernetes(instance, context);
|