@catladder/cli 0.0.0-node16-ddfae617 → 0.0.0-prettier-cbceeed9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/catenv +1 -1
- package/bin/catenv-dev +3 -0
- package/bin/catladder +1 -1
- package/bin/catladder-dev +3 -0
- package/dist/apps/catenv/catenv.d.ts +4 -1
- package/dist/apps/catenv/catenv.js +28 -20
- package/dist/apps/catenv/catenv.js.map +1 -1
- package/dist/apps/cli/cli.js +4 -2
- package/dist/apps/cli/cli.js.map +1 -1
- package/dist/apps/cli/commands/{project/commandCopyDB.d.ts → cloudSQL/commandRestoreDb.d.ts} +1 -1
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js +192 -0
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +1 -0
- package/dist/apps/cli/commands/cloudSQL/index.d.ts +3 -0
- package/dist/apps/cli/commands/cloudSQL/index.js +50 -0
- package/dist/apps/cli/commands/cloudSQL/index.js.map +1 -0
- package/dist/apps/cli/commands/general/index.d.ts +1 -1
- package/dist/apps/cli/commands/general/index.js +11 -11
- package/dist/apps/cli/commands/general/index.js.map +1 -1
- package/dist/apps/cli/commands/general/portForward.d.ts +1 -1
- package/dist/apps/cli/commands/general/portForward.js +3 -3
- package/dist/apps/cli/commands/general/portForward.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/index.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +2 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +27 -11
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/utils/index.js +16 -4
- package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -1
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +109 -45
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +29 -51
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/apps/cli/commands/project/commandDeletePods.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandDeletePods.js +2 -1
- package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -1
- package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandEnvVars.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +1 -1
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -1
- package/dist/apps/cli/commands/project/commandGetShell.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetShell.js +2 -1
- package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -1
- package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
- package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandListPods.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandListPods.js +2 -2
- package/dist/apps/cli/commands/project/commandListPods.js.map +1 -1
- package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js +1 -2
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -1
- package/dist/apps/cli/commands/project/commandNamespace.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +2 -2
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenDashboard.js +19 -20
- package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGit.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGit.js +2 -7
- package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafana.js +2 -2
- package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +4 -3
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenLogs.js +7 -20
- package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -1
- package/dist/apps/cli/commands/project/commandPauseProject.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandPortForward.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandPortForward.js +98 -36
- package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -1
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
- package/dist/apps/cli/commands/project/commandSetup.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -1
- package/dist/apps/cli/commands/project/index.d.ts +1 -1
- package/dist/apps/cli/commands/project/index.js +2 -2
- package/dist/apps/cli/commands/project/index.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/index.d.ts +1 -1
- package/dist/apps/cli/commands/project/setup/index.js +11 -7
- package/dist/apps/cli/commands/project/setup/index.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -1
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +5 -4
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupCloudRun.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.js +118 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.js +56 -0
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
- package/dist/apps/cli/commands/project/setup/setupContext.js +17 -3
- package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js +12 -16
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupTopic.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.js +69 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -1
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
- package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -1
- package/dist/apps/cli/config/writeConfig.d.ts +2 -2
- package/dist/apps/cli/verify/index.d.ts +1 -1
- package/dist/apps/cli/verify/migration/fromv2.d.ts +1 -1
- package/dist/apps/cli/verify/migration/fromv2.js +2 -0
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
- package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +3 -3
- package/dist/apps/cli/verify/migration/migrateSecrets.js +4 -3
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +1 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.js +1 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -1
- package/dist/bundles/catenv/index.js +44895 -0
- package/dist/bundles/catenv/xdg-open +1066 -0
- package/dist/bundles/cli/clipboard_i686.exe +0 -0
- package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
- package/dist/bundles/cli/exec-child.js +39 -0
- package/dist/bundles/cli/index.js +358730 -0
- package/dist/bundles/cli/xdg-open +1066 -0
- package/dist/bundles/cli/xsel +0 -0
- package/dist/catenv.js +3 -3
- package/dist/catenv.js.map +1 -1
- package/dist/cli.js +0 -7
- package/dist/cli.js.map +1 -1
- package/dist/config/constants.d.ts +0 -1
- package/dist/config/constants.js +1 -2
- package/dist/config/constants.js.map +1 -1
- package/dist/config/getProjectConfig.d.ts +4 -7
- package/dist/config/getProjectConfig.js +21 -9
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/config/parseChoice.d.ts +4 -0
- package/dist/config/parseChoice.js +9 -0
- package/dist/config/parseChoice.js.map +1 -0
- package/dist/gcloud/artifactsRegistry.d.ts +5 -0
- package/dist/gcloud/artifactsRegistry.js +59 -0
- package/dist/gcloud/artifactsRegistry.js.map +1 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.d.ts +2 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +67 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.d.ts +3 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js +62 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -0
- package/dist/gcloud/enableServices.d.ts +3 -0
- package/dist/gcloud/enableServices.js +63 -0
- package/dist/gcloud/enableServices.js.map +1 -0
- package/dist/gcloud/openDashboard.d.ts +2 -0
- package/dist/{apps/cli/commands/shared/index.js → gcloud/openDashboard.js} +23 -27
- package/dist/gcloud/openDashboard.js.map +1 -0
- package/dist/gcloud/serviceAccounts.d.ts +12 -0
- package/dist/gcloud/serviceAccounts.js +144 -0
- package/dist/gcloud/serviceAccounts.js.map +1 -0
- package/dist/kubernetes/index.d.ts +3 -0
- package/dist/kubernetes/index.js +88 -0
- package/dist/kubernetes/index.js.map +1 -0
- package/dist/kubernetes/openKubernetesDashboards.d.ts +4 -0
- package/dist/kubernetes/openKubernetesDashboards.js +94 -0
- package/dist/kubernetes/openKubernetesDashboards.js.map +1 -0
- package/dist/kubernetes/portForward.d.ts +1 -0
- package/dist/kubernetes/portForward.js +55 -0
- package/dist/kubernetes/portForward.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/cluster.js +3 -8
- package/dist/utils/cluster.js.map +1 -1
- package/dist/utils/gitlab.d.ts +5 -3
- package/dist/utils/gitlab.js +165 -46
- package/dist/utils/gitlab.js.map +1 -1
- package/dist/utils/passwordstore/index.d.ts +0 -1
- package/dist/utils/passwordstore/index.js +1 -64
- package/dist/utils/passwordstore/index.js.map +1 -1
- package/dist/utils/portForwards.d.ts +12 -0
- package/dist/utils/{portForward.js → portForwards.js} +20 -16
- package/dist/utils/portForwards.js.map +1 -0
- package/dist/utils/projects/index.d.ts +0 -3
- package/dist/utils/projects/index.js +3 -53
- package/dist/utils/projects/index.js.map +1 -1
- package/package.json +24 -22
- package/scripts/bundle +4 -0
- package/src/apps/catenv/catenv.ts +15 -8
- package/src/apps/cli/cli.ts +3 -1
- package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +169 -0
- package/src/apps/cli/commands/cloudSQL/index.ts +8 -0
- package/src/apps/cli/commands/general/index.ts +11 -8
- package/src/apps/cli/commands/general/portForward.ts +4 -4
- package/src/apps/cli/commands/mongodb/index.ts +1 -1
- package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +3 -5
- package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +1 -1
- package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +18 -3
- package/src/apps/cli/commands/mongodb/utils/index.ts +19 -11
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +110 -37
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +12 -31
- package/src/apps/cli/commands/project/commandDeletePods.ts +3 -5
- package/src/apps/cli/commands/project/commandDeleteProject.ts +1 -1
- package/src/apps/cli/commands/project/commandEnvVars.ts +1 -1
- package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +2 -2
- package/src/apps/cli/commands/project/commandGetShell.ts +3 -5
- package/src/apps/cli/commands/project/commandGitlabCi.ts +2 -1
- package/src/apps/cli/commands/project/commandInitProject.old.ts +1 -1
- package/src/apps/cli/commands/project/commandListPods.ts +2 -2
- package/src/apps/cli/commands/project/commandMigrateHelm3.ts +4 -3
- package/src/apps/cli/commands/project/commandNamespace.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +3 -3
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +12 -32
- package/src/apps/cli/commands/project/commandOpenEnv.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenGit.ts +3 -3
- package/src/apps/cli/commands/project/commandOpenGrafana.ts +3 -3
- package/src/apps/cli/commands/project/commandOpenGrafanaPod.ts +5 -7
- package/src/apps/cli/commands/project/commandOpenLogs.ts +4 -35
- package/src/apps/cli/commands/project/commandPauseProject.ts +1 -1
- package/src/apps/cli/commands/project/commandPortForward.ts +75 -34
- package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
- package/src/apps/cli/commands/project/commandSetup.ts +1 -1
- package/src/apps/cli/commands/project/commandTriggerCronjob.ts +3 -2
- package/src/apps/cli/commands/project/index.ts +4 -3
- package/src/apps/cli/commands/project/setup/index.ts +3 -1
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +23 -11
- package/src/apps/cli/commands/project/setup/setupCloudRun.ts +84 -0
- package/src/apps/cli/commands/project/setup/setupCloudSQL.ts +22 -0
- package/src/apps/cli/commands/project/setup/setupContext.ts +12 -2
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +34 -27
- package/src/apps/cli/commands/project/setup/setupTopic.ts +22 -0
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +4 -2
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +1 -1
- package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +2 -2
- package/src/apps/cli/config/writeConfig.ts +2 -2
- package/src/apps/cli/verify/index.ts +1 -1
- package/src/apps/cli/verify/migration/fromv2.ts +5 -7
- package/src/apps/cli/verify/migration/migrateSecrets.ts +9 -4
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +2 -2
- package/src/catenv.ts +6 -3
- package/src/cli.ts +1 -7
- package/src/config/constants.ts +0 -2
- package/src/config/getProjectConfig.ts +14 -12
- package/src/config/parseChoice.ts +4 -0
- package/src/gcloud/artifactsRegistry.ts +16 -0
- package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +35 -0
- package/src/gcloud/cloudRun/openCloudRunDashboards.ts +22 -0
- package/src/gcloud/enableServices.ts +14 -0
- package/src/gcloud/openDashboard.ts +19 -0
- package/src/gcloud/serviceAccounts.ts +101 -0
- package/src/kubernetes/index.ts +27 -0
- package/src/kubernetes/openKubernetesDashboards.ts +52 -0
- package/src/kubernetes/portForward.ts +15 -0
- package/src/types/child-process-promise.d.ts +36 -1
- package/src/utils/cluster.ts +3 -3
- package/src/utils/gitlab.ts +137 -26
- package/src/utils/passwordstore/index.ts +2 -30
- package/src/utils/{portForward.ts → portForwards.ts} +27 -22
- package/src/utils/projects/index.ts +3 -24
- package/dist/apps/cli/commands/project/commandCopyDB.js +0 -102
- package/dist/apps/cli/commands/project/commandCopyDB.js.map +0 -1
- package/dist/apps/cli/commands/shared/index.d.ts +0 -3
- package/dist/apps/cli/commands/shared/index.js.map +0 -1
- package/dist/utils/portForward.d.ts +0 -4
- package/dist/utils/portForward.js.map +0 -1
- package/src/apps/cli/commands/project/commandCopyDB.ts +0 -91
- package/src/apps/cli/commands/shared/index.ts +0 -36
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildConfig } from "@catladder/pipeline";
|
|
1
|
+
import type { BuildConfig } from "@catladder/pipeline";
|
|
2
2
|
|
|
3
3
|
export type OldGitlabCiFile = {
|
|
4
4
|
variables: {
|
|
@@ -43,6 +43,6 @@ export const detectBuildConfig = (
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
if (firstInclude.file === "rails-kubernetes.yml") {
|
|
46
|
-
|
|
46
|
+
return "rails";
|
|
47
47
|
}
|
|
48
48
|
};
|
package/src/catenv.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import catenv from "./apps/catenv/catenv";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
import { parseChoice } from "./config/parseChoice";
|
|
4
|
+
|
|
5
|
+
const choice = process.argv[2] ? parseChoice(process.argv[2]) : null;
|
|
6
|
+
|
|
7
|
+
catenv(choice).then(() => {
|
|
5
8
|
// we have to exit manually, because we have some file watches
|
|
6
9
|
process.exit();
|
|
7
10
|
});
|
package/src/cli.ts
CHANGED
package/src/config/constants.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
+
import type { Config } from "@catladder/pipeline";
|
|
1
2
|
import {
|
|
2
3
|
readConfigSync,
|
|
3
4
|
getAllEnvs,
|
|
4
5
|
getEnvironment as _getEnvironment,
|
|
5
6
|
createContext,
|
|
6
7
|
getSecretVarName,
|
|
7
|
-
Config,
|
|
8
8
|
} from "@catladder/pipeline";
|
|
9
9
|
|
|
10
|
-
import { CommandInstance } from "vorpal";
|
|
10
|
+
import type { CommandInstance } from "vorpal";
|
|
11
11
|
import { getAllVariables, getVariableValueByRawName } from "../utils/gitlab";
|
|
12
12
|
|
|
13
13
|
import { getGitRoot } from "../utils/projects";
|
|
14
14
|
import { readYaml } from "../utils/files";
|
|
15
15
|
import { watch } from "fs";
|
|
16
16
|
|
|
17
|
+
export { parseChoice } from "./parseChoice";
|
|
18
|
+
|
|
17
19
|
let currentConfig: Config = null;
|
|
18
20
|
|
|
19
21
|
// reload the config on change
|
|
@@ -59,17 +61,12 @@ export const getProjectComponents = async () => {
|
|
|
59
61
|
return Object.keys(config.components);
|
|
60
62
|
};
|
|
61
63
|
|
|
62
|
-
export const parseChoice = (envComponent: string) => {
|
|
63
|
-
const [env, componentName] = envComponent.split(":");
|
|
64
|
-
return { env, componentName };
|
|
65
|
-
};
|
|
66
|
-
|
|
67
64
|
export const getPipelineContextByChoice = async (
|
|
68
65
|
env: string,
|
|
69
66
|
componentName: string
|
|
70
67
|
) => {
|
|
71
68
|
const config = await getProjectConfig();
|
|
72
|
-
return createContext(config, componentName, env);
|
|
69
|
+
return await createContext(config, componentName, env);
|
|
73
70
|
};
|
|
74
71
|
export const getAllComponentsWithAllEnvsFlat = async (): Promise<
|
|
75
72
|
Array<{ env: string; componentName: string }>
|
|
@@ -153,8 +150,13 @@ export const getEnvVars = async (
|
|
|
153
150
|
env: string,
|
|
154
151
|
componentName: string
|
|
155
152
|
) => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
try {
|
|
154
|
+
const envionment = await getEnvironment(env, componentName);
|
|
155
|
+
// in the pipeline the secrets alreadyy exists and bash will expand them
|
|
156
|
+
// but here we need to manually load them
|
|
157
|
+
return resolveSecrets(vorpal, envionment.envVars);
|
|
158
|
+
} catch (e) {
|
|
159
|
+
// env is disabled
|
|
160
|
+
return {};
|
|
161
|
+
}
|
|
160
162
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Gcloudregion } from "@catladder/pipeline";
|
|
2
|
+
import { exec } from "child-process-promise";
|
|
3
|
+
|
|
4
|
+
export const upsertGcloudArtifactsRegistry = async (config: {
|
|
5
|
+
projectId: string;
|
|
6
|
+
region: Gcloudregion;
|
|
7
|
+
}) => {
|
|
8
|
+
try {
|
|
9
|
+
await exec(
|
|
10
|
+
`gcloud artifacts repositories create catladder-deploy --project="${config.projectId}" --repository-format=docker --location=${config.region}`
|
|
11
|
+
);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
// probably already exists
|
|
14
|
+
//
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DeployConfigCloudRun } from "@catladder/pipeline";
|
|
2
|
+
import { exec } from "child-process-promise";
|
|
3
|
+
|
|
4
|
+
const getSuffixFromService = (service: any) => {
|
|
5
|
+
const fullUrl = service.status.url;
|
|
6
|
+
const name = service.metadata.name;
|
|
7
|
+
|
|
8
|
+
return fullUrl.replace("https://" + name + "-", "");
|
|
9
|
+
};
|
|
10
|
+
export const getCloudRunDomainSuffix = async (config: DeployConfigCloudRun) => {
|
|
11
|
+
/* google cloud run domains are partially predictable, they have a fixed suffix that depends on the region and project, but we don't know it beforehand
|
|
12
|
+
|
|
13
|
+
So what we do is either:
|
|
14
|
+
- get one service and extract its suffix
|
|
15
|
+
- create a dummy project, extract the suffix and save that as a gitlab variable
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const dummyServiceName = "cl-dummy-service-delete-me";
|
|
21
|
+
|
|
22
|
+
const existingServices = await exec(
|
|
23
|
+
`gcloud run services list --format=json --project="${config.projectId}" --region=${config.region} --limit=1`
|
|
24
|
+
).then((r) => JSON.parse(r.stdout));
|
|
25
|
+
|
|
26
|
+
if (existingServices.length > 0) {
|
|
27
|
+
return getSuffixFromService(existingServices[0]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const result = await exec(
|
|
31
|
+
`gcloud run deploy ${dummyServiceName} --region=${config.region} --allow-unauthenticated --project ${config.projectId} --image=us-docker.pkg.dev/cloudrun/container/hello --format=json`
|
|
32
|
+
).then((r) => JSON.parse(r.stdout));
|
|
33
|
+
|
|
34
|
+
return await getSuffixFromService(result);
|
|
35
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
|
+
import type { CommandInstance } from "vorpal";
|
|
4
|
+
import { openGoogleCloudDashboard } from "../openDashboard";
|
|
5
|
+
|
|
6
|
+
export const openGoogleCloudRunDashboard = async (
|
|
7
|
+
instance: CommandInstance,
|
|
8
|
+
context: Context
|
|
9
|
+
) => {
|
|
10
|
+
if (!isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
11
|
+
throw new Error("deploy type is not google-cloudrun ");
|
|
12
|
+
}
|
|
13
|
+
const { fullName } = context.environment;
|
|
14
|
+
const { region, projectId } = context.componentConfig.deploy;
|
|
15
|
+
await openGoogleCloudDashboard(
|
|
16
|
+
instance,
|
|
17
|
+
`run/detail/${region}/${fullName}/metrics`,
|
|
18
|
+
{
|
|
19
|
+
project: projectId,
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { exec } from "child-process-promise";
|
|
2
|
+
|
|
3
|
+
export const enableGCloudServices = async (
|
|
4
|
+
services: string[],
|
|
5
|
+
config: {
|
|
6
|
+
projectId: string;
|
|
7
|
+
}
|
|
8
|
+
) => {
|
|
9
|
+
for (const service of services) {
|
|
10
|
+
await exec(
|
|
11
|
+
`gcloud services enable ${service} --project=${config.projectId}`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CommandInstance } from "vorpal";
|
|
2
|
+
import { getGoogleAuthUserNumber } from "../apps/cli/utils/getGoogleAuthUserNumber";
|
|
3
|
+
import open from "open";
|
|
4
|
+
export const openGoogleCloudDashboard = async (
|
|
5
|
+
instance: CommandInstance,
|
|
6
|
+
path: string,
|
|
7
|
+
params: Record<string, string>
|
|
8
|
+
) => {
|
|
9
|
+
const url = new URL("https://console.cloud.google.com/");
|
|
10
|
+
url.pathname = path;
|
|
11
|
+
for (const [key, value] of Object.entries(params)) {
|
|
12
|
+
url.searchParams.set(key, value);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const googleAuthUserNumber = await getGoogleAuthUserNumber.call(instance);
|
|
16
|
+
url.searchParams.set("authuser", googleAuthUserNumber);
|
|
17
|
+
|
|
18
|
+
open(url.toString());
|
|
19
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
|
|
3
|
+
import { exec } from "child-process-promise";
|
|
4
|
+
import { createHmac } from "crypto";
|
|
5
|
+
import type { CommandInstance } from "vorpal";
|
|
6
|
+
import { upsertAllVariables } from "../utils/gitlab";
|
|
7
|
+
|
|
8
|
+
export const accountExists = async (fullIdentifier: string) => {
|
|
9
|
+
try {
|
|
10
|
+
await exec(`gcloud iam service-accounts describe ${fullIdentifier}`);
|
|
11
|
+
return true;
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type ServiceAccount = {
|
|
18
|
+
projectId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
displayName: string;
|
|
21
|
+
roles: string[];
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
const upsertGcloudServiceAccount = async (
|
|
25
|
+
context: Context,
|
|
26
|
+
account: ServiceAccount
|
|
27
|
+
): Promise<string> => {
|
|
28
|
+
const { projectId, name, displayName, roles, description } = account;
|
|
29
|
+
|
|
30
|
+
// name has limit of 30
|
|
31
|
+
const namePrefix = `${name}-`;
|
|
32
|
+
const nameSuffix = `-${context.environment.shortName}-${context.componentName}`;
|
|
33
|
+
const nameMiddleLength = 30 - namePrefix.length - nameSuffix.length;
|
|
34
|
+
const nameMiddle = `${context.fullConfig.customerName}-${context.fullConfig.appName}`;
|
|
35
|
+
|
|
36
|
+
const middle = hashIfNessecary(nameMiddle, nameMiddleLength);
|
|
37
|
+
|
|
38
|
+
const fullName = `${namePrefix}${middle}${nameSuffix}`;
|
|
39
|
+
|
|
40
|
+
const fullDisplayName = `${context.fullConfig.customerName}-${context.fullConfig.appName} ${context.environment.shortName}:${context.componentName} | ${displayName}`;
|
|
41
|
+
|
|
42
|
+
const fullIdentifier = `${fullName}@${projectId}.iam.gserviceaccount.com`;
|
|
43
|
+
|
|
44
|
+
const existing = await accountExists(fullIdentifier);
|
|
45
|
+
|
|
46
|
+
if (!existing) {
|
|
47
|
+
await exec(
|
|
48
|
+
`gcloud iam service-accounts create ${fullName} --display-name="${fullDisplayName}" --project="${projectId}" --description="${description}"`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
const memberName = `serviceAccount:${fullIdentifier}`;
|
|
52
|
+
for (const role of roles) {
|
|
53
|
+
await exec(
|
|
54
|
+
`gcloud projects add-iam-policy-binding ${projectId} --member=${memberName} --role=${role} `
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// create key
|
|
59
|
+
|
|
60
|
+
// delete first all keys
|
|
61
|
+
const keys = await exec(
|
|
62
|
+
`gcloud iam service-accounts keys list --iam-account=${fullIdentifier} --managed-by=user --format=json`
|
|
63
|
+
).then((o) => JSON.parse(o.stdout));
|
|
64
|
+
|
|
65
|
+
for (const key of keys) {
|
|
66
|
+
await exec(
|
|
67
|
+
`gcloud iam service-accounts keys delete ${key.name} --quiet --iam-account=${fullIdentifier}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return await exec(
|
|
72
|
+
`gcloud iam service-accounts keys create /dev/stdout --iam-account=${fullIdentifier}`
|
|
73
|
+
).then((o) => o.stdout);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const upsertGcloudServiceAccountAndSaveSecret = async (
|
|
77
|
+
instance: CommandInstance,
|
|
78
|
+
context: Context,
|
|
79
|
+
account: ServiceAccount,
|
|
80
|
+
secretName: string
|
|
81
|
+
): Promise<void> => {
|
|
82
|
+
instance.log("upserting service account " + account.name + "...");
|
|
83
|
+
const key = await upsertGcloudServiceAccount(context, account);
|
|
84
|
+
|
|
85
|
+
await upsertAllVariables(
|
|
86
|
+
instance,
|
|
87
|
+
{
|
|
88
|
+
[secretName]: key,
|
|
89
|
+
},
|
|
90
|
+
context.environment.shortName,
|
|
91
|
+
context.componentName
|
|
92
|
+
);
|
|
93
|
+
instance.log("done!");
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const hashIfNessecary = (str: string, maxLength: number) =>
|
|
97
|
+
str.length > maxLength ? hash(str, maxLength) : str;
|
|
98
|
+
|
|
99
|
+
const hash = (str: string, length: number) => {
|
|
100
|
+
return createHmac("sha256", str).digest("hex").substring(0, length);
|
|
101
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { parseChoice } from "../config/parseChoice";
|
|
2
|
+
import { getk8sApi } from "../k8sApi";
|
|
3
|
+
import { getProjectNamespace } from "../utils/projects";
|
|
4
|
+
|
|
5
|
+
export const getProjectPods = async (envComponent: string) => {
|
|
6
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
7
|
+
const k8sApi = getk8sApi();
|
|
8
|
+
const res = await k8sApi.listNamespacedPod(namespace);
|
|
9
|
+
|
|
10
|
+
const { componentName } = parseChoice(envComponent);
|
|
11
|
+
return res.body.items.filter((item) =>
|
|
12
|
+
componentName ? item.metadata?.name?.includes(componentName + "-") : true
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const getProjectPvcs = async (envComponent: string) => {
|
|
17
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
18
|
+
const k8sApi = getk8sApi();
|
|
19
|
+
const res = await k8sApi.listNamespacedPersistentVolumeClaim(namespace);
|
|
20
|
+
|
|
21
|
+
return res.body.items;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const getProjectPodNames = async (envComponent: string) => {
|
|
25
|
+
const pods = await getProjectPods(envComponent);
|
|
26
|
+
return pods.map((n) => n.metadata.name);
|
|
27
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
|
+
import type { CommandInstance } from "vorpal";
|
|
4
|
+
import { openGoogleCloudDashboard } from "../gcloud/openDashboard";
|
|
5
|
+
|
|
6
|
+
export const openGoogleCloudLogs = async (
|
|
7
|
+
instance: CommandInstance,
|
|
8
|
+
context: Context
|
|
9
|
+
) => {
|
|
10
|
+
const deployConfig = context.componentConfig.deploy;
|
|
11
|
+
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
12
|
+
throw new Error("context is not of type kubernetes");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!deployConfig.cluster || deployConfig.cluster.type !== "gcloud") {
|
|
16
|
+
throw new Error("no gcloud custer configured");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const namespace = context.environment.envVars.KUBE_NAMESPACE;
|
|
20
|
+
const cluster = deployConfig.cluster;
|
|
21
|
+
|
|
22
|
+
const resource = `k8s_container/cluster_name/${cluster.name}${
|
|
23
|
+
namespace ? `/namespace_name/${namespace}` : ""
|
|
24
|
+
}`;
|
|
25
|
+
|
|
26
|
+
await openGoogleCloudDashboard(instance, "logs/viewer", {
|
|
27
|
+
project: cluster.projectId,
|
|
28
|
+
resource: resource,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const openGoogleCloudKubernetesDashboard = async (
|
|
33
|
+
instance: CommandInstance,
|
|
34
|
+
context: Context
|
|
35
|
+
) => {
|
|
36
|
+
const deployConfig = context.componentConfig.deploy;
|
|
37
|
+
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
38
|
+
throw new Error("context is not of type kubernetes");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!deployConfig.cluster || deployConfig.cluster.type !== "gcloud") {
|
|
42
|
+
throw new Error("no gcloud custer configured");
|
|
43
|
+
}
|
|
44
|
+
const namespace = context.environment.envVars.KUBE_NAMESPACE;
|
|
45
|
+
const cluster = deployConfig.cluster;
|
|
46
|
+
const pageState = `("savedViews":("c":["gke/${cluster.region}/${cluster.name}"],"n":["${namespace}"],"i":"4e42e0b9cd6147f8a4fba7516752ec48"))`;
|
|
47
|
+
|
|
48
|
+
await openGoogleCloudDashboard(instance, "kubernetes/workload", {
|
|
49
|
+
project: cluster.projectId,
|
|
50
|
+
pageState: pageState,
|
|
51
|
+
});
|
|
52
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { startPortForwardCommand } from "../utils/portForwards";
|
|
2
|
+
|
|
3
|
+
export const startKubePortForward = async (
|
|
4
|
+
podname: string,
|
|
5
|
+
localPort: number,
|
|
6
|
+
remotePort: number,
|
|
7
|
+
namespace: string
|
|
8
|
+
) => {
|
|
9
|
+
const name = `kube/${namespace}/${podname}/${localPort}:${remotePort}`;
|
|
10
|
+
|
|
11
|
+
await startPortForwardCommand(
|
|
12
|
+
name,
|
|
13
|
+
`kubectl port-forward ${podname} ${localPort}:${remotePort} -n ${namespace}`
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -1 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ReadStream } from "fs-extra";
|
|
2
|
+
|
|
3
|
+
declare module "child-process-promise" {
|
|
4
|
+
function exec(
|
|
5
|
+
cmd: string,
|
|
6
|
+
options?: {
|
|
7
|
+
env?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
): Promise<{
|
|
10
|
+
stdout: string;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
type Stdio = "inherit" | "pipe";
|
|
14
|
+
type SpawnOptions = {
|
|
15
|
+
stdio?: Stdio | Stdio[];
|
|
16
|
+
shell?: boolean;
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function spawn(
|
|
21
|
+
cmd: string,
|
|
22
|
+
options?: SpawnOptions
|
|
23
|
+
): Promise<{
|
|
24
|
+
stdout: string;
|
|
25
|
+
}>;
|
|
26
|
+
|
|
27
|
+
function spawn(
|
|
28
|
+
cmd: string,
|
|
29
|
+
args: string[],
|
|
30
|
+
options?: SpawnOptions
|
|
31
|
+
): Promise<unknown> & {
|
|
32
|
+
childProcess: {
|
|
33
|
+
stdout: ReadStream;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|
package/src/utils/cluster.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { exec } from "child-process-promise";
|
|
2
2
|
|
|
3
3
|
export const getCurrentContext = async () =>
|
|
4
|
-
(await
|
|
4
|
+
(await exec(`kubectl config current-context`)).stdout.trim();
|
|
5
5
|
|
|
6
6
|
export const getCurrentConnectedClusterName = async () => {
|
|
7
7
|
return await getCurrentContext();
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export const connectToCluster = async (fullname: string) => {
|
|
11
|
-
await
|
|
11
|
+
await exec(`kubectl config use-context ${fullname}`);
|
|
12
12
|
};
|