@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.
Files changed (272) hide show
  1. package/bin/catenv +1 -1
  2. package/bin/catenv-dev +3 -0
  3. package/bin/catladder +1 -1
  4. package/bin/catladder-dev +3 -0
  5. package/dist/apps/catenv/catenv.d.ts +4 -1
  6. package/dist/apps/catenv/catenv.js +28 -20
  7. package/dist/apps/catenv/catenv.js.map +1 -1
  8. package/dist/apps/cli/cli.js +4 -2
  9. package/dist/apps/cli/cli.js.map +1 -1
  10. package/dist/apps/cli/commands/{project/commandCopyDB.d.ts → cloudSQL/commandRestoreDb.d.ts} +1 -1
  11. package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js +192 -0
  12. package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +1 -0
  13. package/dist/apps/cli/commands/cloudSQL/index.d.ts +3 -0
  14. package/dist/apps/cli/commands/cloudSQL/index.js +50 -0
  15. package/dist/apps/cli/commands/cloudSQL/index.js.map +1 -0
  16. package/dist/apps/cli/commands/general/index.d.ts +1 -1
  17. package/dist/apps/cli/commands/general/index.js +11 -11
  18. package/dist/apps/cli/commands/general/index.js.map +1 -1
  19. package/dist/apps/cli/commands/general/portForward.d.ts +1 -1
  20. package/dist/apps/cli/commands/general/portForward.js +3 -3
  21. package/dist/apps/cli/commands/general/portForward.js.map +1 -1
  22. package/dist/apps/cli/commands/mongodb/index.d.ts +1 -1
  23. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +1 -1
  24. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +2 -1
  25. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -1
  26. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +1 -1
  27. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +1 -1
  28. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +27 -11
  29. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
  30. package/dist/apps/cli/commands/mongodb/utils/index.js +16 -4
  31. package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -1
  32. package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +1 -1
  33. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +109 -45
  34. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
  35. package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -1
  36. package/dist/apps/cli/commands/project/commandConfigSecrets.js +29 -51
  37. package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
  38. package/dist/apps/cli/commands/project/commandDeletePods.d.ts +1 -1
  39. package/dist/apps/cli/commands/project/commandDeletePods.js +2 -1
  40. package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -1
  41. package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +1 -1
  42. package/dist/apps/cli/commands/project/commandEnvVars.d.ts +1 -1
  43. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +1 -1
  44. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +1 -1
  45. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -1
  46. package/dist/apps/cli/commands/project/commandGetShell.d.ts +1 -1
  47. package/dist/apps/cli/commands/project/commandGetShell.js +2 -1
  48. package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -1
  49. package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +1 -1
  50. package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
  51. package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +1 -1
  52. package/dist/apps/cli/commands/project/commandListPods.d.ts +1 -1
  53. package/dist/apps/cli/commands/project/commandListPods.js +2 -2
  54. package/dist/apps/cli/commands/project/commandListPods.js.map +1 -1
  55. package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +1 -1
  56. package/dist/apps/cli/commands/project/commandMigrateHelm3.js +1 -2
  57. package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -1
  58. package/dist/apps/cli/commands/project/commandNamespace.d.ts +1 -1
  59. package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +1 -1
  60. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +2 -2
  61. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -1
  62. package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +1 -1
  63. package/dist/apps/cli/commands/project/commandOpenDashboard.js +19 -20
  64. package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -1
  65. package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +1 -1
  66. package/dist/apps/cli/commands/project/commandOpenGit.d.ts +1 -1
  67. package/dist/apps/cli/commands/project/commandOpenGit.js +2 -7
  68. package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -1
  69. package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +1 -1
  70. package/dist/apps/cli/commands/project/commandOpenGrafana.js +2 -2
  71. package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -1
  72. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +1 -1
  73. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +4 -3
  74. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -1
  75. package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +1 -1
  76. package/dist/apps/cli/commands/project/commandOpenLogs.js +7 -20
  77. package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -1
  78. package/dist/apps/cli/commands/project/commandPauseProject.d.ts +1 -1
  79. package/dist/apps/cli/commands/project/commandPortForward.d.ts +1 -1
  80. package/dist/apps/cli/commands/project/commandPortForward.js +98 -36
  81. package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -1
  82. package/dist/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
  83. package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
  84. package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
  85. package/dist/apps/cli/commands/project/commandSetup.d.ts +1 -1
  86. package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +1 -1
  87. package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -1
  88. package/dist/apps/cli/commands/project/index.d.ts +1 -1
  89. package/dist/apps/cli/commands/project/index.js +2 -2
  90. package/dist/apps/cli/commands/project/index.js.map +1 -1
  91. package/dist/apps/cli/commands/project/setup/index.d.ts +1 -1
  92. package/dist/apps/cli/commands/project/setup/index.js +11 -7
  93. package/dist/apps/cli/commands/project/setup/index.js.map +1 -1
  94. package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -1
  95. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +5 -4
  96. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
  97. package/dist/apps/cli/commands/project/setup/setupCloudRun.d.ts +3 -0
  98. package/dist/apps/cli/commands/project/setup/setupCloudRun.js +118 -0
  99. package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -0
  100. package/dist/apps/cli/commands/project/setup/setupCloudSQL.d.ts +3 -0
  101. package/dist/apps/cli/commands/project/setup/setupCloudSQL.js +56 -0
  102. package/dist/apps/cli/commands/project/setup/setupCloudSQL.js.map +1 -0
  103. package/dist/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
  104. package/dist/apps/cli/commands/project/setup/setupContext.js +17 -3
  105. package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  106. package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
  107. package/dist/apps/cli/commands/project/setup/setupKubernetes.js +12 -16
  108. package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
  109. package/dist/apps/cli/commands/project/setup/setupTopic.d.ts +2 -0
  110. package/dist/apps/cli/commands/project/setup/setupTopic.js +69 -0
  111. package/dist/apps/cli/commands/project/setup/setupTopic.js.map +1 -0
  112. package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -1
  113. package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
  114. package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +1 -1
  115. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +1 -1
  116. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +1 -1
  117. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -1
  118. package/dist/apps/cli/config/writeConfig.d.ts +2 -2
  119. package/dist/apps/cli/verify/index.d.ts +1 -1
  120. package/dist/apps/cli/verify/migration/fromv2.d.ts +1 -1
  121. package/dist/apps/cli/verify/migration/fromv2.js +2 -0
  122. package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
  123. package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +3 -3
  124. package/dist/apps/cli/verify/migration/migrateSecrets.js +4 -3
  125. package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
  126. package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +1 -1
  127. package/dist/apps/cli/verify/migration/oldGitlabCi.js +1 -1
  128. package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -1
  129. package/dist/bundles/catenv/index.js +44895 -0
  130. package/dist/bundles/catenv/xdg-open +1066 -0
  131. package/dist/bundles/cli/clipboard_i686.exe +0 -0
  132. package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
  133. package/dist/bundles/cli/exec-child.js +39 -0
  134. package/dist/bundles/cli/index.js +358730 -0
  135. package/dist/bundles/cli/xdg-open +1066 -0
  136. package/dist/bundles/cli/xsel +0 -0
  137. package/dist/catenv.js +3 -3
  138. package/dist/catenv.js.map +1 -1
  139. package/dist/cli.js +0 -7
  140. package/dist/cli.js.map +1 -1
  141. package/dist/config/constants.d.ts +0 -1
  142. package/dist/config/constants.js +1 -2
  143. package/dist/config/constants.js.map +1 -1
  144. package/dist/config/getProjectConfig.d.ts +4 -7
  145. package/dist/config/getProjectConfig.js +21 -9
  146. package/dist/config/getProjectConfig.js.map +1 -1
  147. package/dist/config/parseChoice.d.ts +4 -0
  148. package/dist/config/parseChoice.js +9 -0
  149. package/dist/config/parseChoice.js.map +1 -0
  150. package/dist/gcloud/artifactsRegistry.d.ts +5 -0
  151. package/dist/gcloud/artifactsRegistry.js +59 -0
  152. package/dist/gcloud/artifactsRegistry.js.map +1 -0
  153. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.d.ts +2 -0
  154. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +67 -0
  155. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -0
  156. package/dist/gcloud/cloudRun/openCloudRunDashboards.d.ts +3 -0
  157. package/dist/gcloud/cloudRun/openCloudRunDashboards.js +62 -0
  158. package/dist/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -0
  159. package/dist/gcloud/enableServices.d.ts +3 -0
  160. package/dist/gcloud/enableServices.js +63 -0
  161. package/dist/gcloud/enableServices.js.map +1 -0
  162. package/dist/gcloud/openDashboard.d.ts +2 -0
  163. package/dist/{apps/cli/commands/shared/index.js → gcloud/openDashboard.js} +23 -27
  164. package/dist/gcloud/openDashboard.js.map +1 -0
  165. package/dist/gcloud/serviceAccounts.d.ts +12 -0
  166. package/dist/gcloud/serviceAccounts.js +144 -0
  167. package/dist/gcloud/serviceAccounts.js.map +1 -0
  168. package/dist/kubernetes/index.d.ts +3 -0
  169. package/dist/kubernetes/index.js +88 -0
  170. package/dist/kubernetes/index.js.map +1 -0
  171. package/dist/kubernetes/openKubernetesDashboards.d.ts +4 -0
  172. package/dist/kubernetes/openKubernetesDashboards.js +94 -0
  173. package/dist/kubernetes/openKubernetesDashboards.js.map +1 -0
  174. package/dist/kubernetes/portForward.d.ts +1 -0
  175. package/dist/kubernetes/portForward.js +55 -0
  176. package/dist/kubernetes/portForward.js.map +1 -0
  177. package/dist/tsconfig.tsbuildinfo +1 -1
  178. package/dist/utils/cluster.js +3 -8
  179. package/dist/utils/cluster.js.map +1 -1
  180. package/dist/utils/gitlab.d.ts +5 -3
  181. package/dist/utils/gitlab.js +165 -46
  182. package/dist/utils/gitlab.js.map +1 -1
  183. package/dist/utils/passwordstore/index.d.ts +0 -1
  184. package/dist/utils/passwordstore/index.js +1 -64
  185. package/dist/utils/passwordstore/index.js.map +1 -1
  186. package/dist/utils/portForwards.d.ts +12 -0
  187. package/dist/utils/{portForward.js → portForwards.js} +20 -16
  188. package/dist/utils/portForwards.js.map +1 -0
  189. package/dist/utils/projects/index.d.ts +0 -3
  190. package/dist/utils/projects/index.js +3 -53
  191. package/dist/utils/projects/index.js.map +1 -1
  192. package/package.json +24 -22
  193. package/scripts/bundle +4 -0
  194. package/src/apps/catenv/catenv.ts +15 -8
  195. package/src/apps/cli/cli.ts +3 -1
  196. package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +169 -0
  197. package/src/apps/cli/commands/cloudSQL/index.ts +8 -0
  198. package/src/apps/cli/commands/general/index.ts +11 -8
  199. package/src/apps/cli/commands/general/portForward.ts +4 -4
  200. package/src/apps/cli/commands/mongodb/index.ts +1 -1
  201. package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +3 -5
  202. package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +1 -1
  203. package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +18 -3
  204. package/src/apps/cli/commands/mongodb/utils/index.ts +19 -11
  205. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +110 -37
  206. package/src/apps/cli/commands/project/commandConfigSecrets.ts +12 -31
  207. package/src/apps/cli/commands/project/commandDeletePods.ts +3 -5
  208. package/src/apps/cli/commands/project/commandDeleteProject.ts +1 -1
  209. package/src/apps/cli/commands/project/commandEnvVars.ts +1 -1
  210. package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +2 -2
  211. package/src/apps/cli/commands/project/commandGetShell.ts +3 -5
  212. package/src/apps/cli/commands/project/commandGitlabCi.ts +2 -1
  213. package/src/apps/cli/commands/project/commandInitProject.old.ts +1 -1
  214. package/src/apps/cli/commands/project/commandListPods.ts +2 -2
  215. package/src/apps/cli/commands/project/commandMigrateHelm3.ts +4 -3
  216. package/src/apps/cli/commands/project/commandNamespace.ts +1 -1
  217. package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +3 -3
  218. package/src/apps/cli/commands/project/commandOpenDashboard.ts +12 -32
  219. package/src/apps/cli/commands/project/commandOpenEnv.ts +1 -1
  220. package/src/apps/cli/commands/project/commandOpenGit.ts +3 -3
  221. package/src/apps/cli/commands/project/commandOpenGrafana.ts +3 -3
  222. package/src/apps/cli/commands/project/commandOpenGrafanaPod.ts +5 -7
  223. package/src/apps/cli/commands/project/commandOpenLogs.ts +4 -35
  224. package/src/apps/cli/commands/project/commandPauseProject.ts +1 -1
  225. package/src/apps/cli/commands/project/commandPortForward.ts +75 -34
  226. package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
  227. package/src/apps/cli/commands/project/commandSetup.ts +1 -1
  228. package/src/apps/cli/commands/project/commandTriggerCronjob.ts +3 -2
  229. package/src/apps/cli/commands/project/index.ts +4 -3
  230. package/src/apps/cli/commands/project/setup/index.ts +3 -1
  231. package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +23 -11
  232. package/src/apps/cli/commands/project/setup/setupCloudRun.ts +84 -0
  233. package/src/apps/cli/commands/project/setup/setupCloudSQL.ts +22 -0
  234. package/src/apps/cli/commands/project/setup/setupContext.ts +12 -2
  235. package/src/apps/cli/commands/project/setup/setupKubernetes.ts +34 -27
  236. package/src/apps/cli/commands/project/setup/setupTopic.ts +22 -0
  237. package/src/apps/cli/commands/project/utils/ensureNamespace.ts +4 -2
  238. package/src/apps/cli/commands/project/utils/showProjectBanner.ts +1 -1
  239. package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +2 -2
  240. package/src/apps/cli/config/writeConfig.ts +2 -2
  241. package/src/apps/cli/verify/index.ts +1 -1
  242. package/src/apps/cli/verify/migration/fromv2.ts +5 -7
  243. package/src/apps/cli/verify/migration/migrateSecrets.ts +9 -4
  244. package/src/apps/cli/verify/migration/oldGitlabCi.ts +2 -2
  245. package/src/catenv.ts +6 -3
  246. package/src/cli.ts +1 -7
  247. package/src/config/constants.ts +0 -2
  248. package/src/config/getProjectConfig.ts +14 -12
  249. package/src/config/parseChoice.ts +4 -0
  250. package/src/gcloud/artifactsRegistry.ts +16 -0
  251. package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +35 -0
  252. package/src/gcloud/cloudRun/openCloudRunDashboards.ts +22 -0
  253. package/src/gcloud/enableServices.ts +14 -0
  254. package/src/gcloud/openDashboard.ts +19 -0
  255. package/src/gcloud/serviceAccounts.ts +101 -0
  256. package/src/kubernetes/index.ts +27 -0
  257. package/src/kubernetes/openKubernetesDashboards.ts +52 -0
  258. package/src/kubernetes/portForward.ts +15 -0
  259. package/src/types/child-process-promise.d.ts +36 -1
  260. package/src/utils/cluster.ts +3 -3
  261. package/src/utils/gitlab.ts +137 -26
  262. package/src/utils/passwordstore/index.ts +2 -30
  263. package/src/utils/{portForward.ts → portForwards.ts} +27 -22
  264. package/src/utils/projects/index.ts +3 -24
  265. package/dist/apps/cli/commands/project/commandCopyDB.js +0 -102
  266. package/dist/apps/cli/commands/project/commandCopyDB.js.map +0 -1
  267. package/dist/apps/cli/commands/shared/index.d.ts +0 -3
  268. package/dist/apps/cli/commands/shared/index.js.map +0 -1
  269. package/dist/utils/portForward.d.ts +0 -4
  270. package/dist/utils/portForward.js.map +0 -1
  271. package/src/apps/cli/commands/project/commandCopyDB.ts +0 -91
  272. package/src/apps/cli/commands/shared/index.ts +0 -36
@@ -1,17 +1,23 @@
1
+ import type { Context } from "@catladder/pipeline";
1
2
  import { isOfDeployType } from "@catladder/pipeline";
2
3
  import { spawn } from "child-process-promise";
3
4
  import { writeFile } from "fs-extra";
4
5
  import { withFile } from "tmp-promise";
5
- import Vorpal from "vorpal";
6
+ import type Vorpal from "vorpal";
6
7
  import {
7
8
  getEnvVars,
8
9
  getGitlabVar,
9
10
  getPipelineContextByChoice,
10
- getProjectConfig,
11
11
  parseChoice,
12
12
  } from "../../../../config/getProjectConfig";
13
13
  import { envAndComponents } from "./utils/autocompletions";
14
14
 
15
+ type ProxyInfo = {
16
+ instanceName: string;
17
+ DB_NAME: string;
18
+ DB_PASSWORD: string;
19
+ DB_USER: string;
20
+ };
15
21
  export default async (vorpal: Vorpal) =>
16
22
  vorpal
17
23
  .command("project-cloud-sql-proxy <envComponent>", "proxy to cloud sql db")
@@ -19,9 +25,26 @@ export default async (vorpal: Vorpal) =>
19
25
  .action(async function ({ envComponent }) {
20
26
  const { env, componentName } = parseChoice(envComponent);
21
27
 
22
- const config = await getProjectConfig();
23
- // skynet-164509:europe-west6:pvl-cyclomania-review=tcp:5432
28
+ const context = await getPipelineContextByChoice(env, componentName);
29
+ let proxyInfo: ProxyInfo;
30
+
31
+ if (env === "review") {
32
+ vorpal.log(
33
+ "⚠️ connection string does not include mr information on review environments"
34
+ );
35
+ }
36
+ if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
37
+ proxyInfo = await getProxyInfoForKubernetes(context);
38
+ } else if (
39
+ isOfDeployType(context.componentConfig.deploy, "google-cloudrun")
40
+ ) {
41
+ proxyInfo = await getProxyInfoForCloudRun(context);
42
+ } else {
43
+ throw new Error("unsupported environment");
44
+ }
24
45
 
46
+ // skynet-164509:europe-west6:pvl-cyclomania-review=tcp:5432
47
+ const { DB_PASSWORD, DB_NAME, DB_USER, instanceName } = proxyInfo;
25
48
  const { localPort } = await this.prompt({
26
49
  type: "number",
27
50
  name: "localPort",
@@ -29,35 +52,16 @@ export default async (vorpal: Vorpal) =>
29
52
  message: "Local port: ",
30
53
  });
31
54
 
32
- const envVars = await getEnvVars(this, env, componentName);
33
- const POSTGRESQL_PASSWORD = envVars?.POSTGRESQL_PASSWORD;
34
-
35
- const context = await getPipelineContextByChoice(env, componentName);
36
- if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
37
- throw new Error("currently only supported for kubernetes deployment");
38
- }
39
55
  this.log("");
40
- this.log(`postgres-PW: ${POSTGRESQL_PASSWORD}`);
56
+ this.log(`postgres-PW: ${DB_PASSWORD}`);
41
57
  this.log("");
42
58
  this.log(
43
- `POSTGRESQL_URL=postgresql://postgres:${POSTGRESQL_PASSWORD}@localhost:${localPort}/${context.environment.envVars.KUBE_APP_NAME}?schema=public`
59
+ `POSTGRESQL_URL=postgresql://${DB_USER}:${DB_PASSWORD}@localhost:${localPort}/${DB_NAME}?schema=public`
44
60
  );
45
61
  this.log("");
46
62
 
47
- const values = context.componentConfig.deploy.values;
48
-
49
- const projectId =
50
- values?.cloudsql?.projectId ||
51
- context.componentConfig.deploy.cluster?.projectId;
52
-
53
- const defaultInstanceId = `${config.customerName}-${config.appName}-${env}`;
54
- const instanceId = values?.cloudsql?.instanceId || defaultInstanceId;
55
-
56
- const defaultRegion = "europe-west6"; // currently hardcoded
57
- const region = values?.cloudsql?.region || defaultRegion;
58
-
59
- const instanceName = `${projectId}:${region}:${instanceId}=tcp:${localPort}`;
60
-
63
+ // legacy, some projects have the cloudsqlProxyCredentials in the secrets
64
+ // actually it works without, if the current local shell user has access to the db through google cloud
61
65
  const cloudsqlProxyCredentials = await getGitlabVar(
62
66
  this,
63
67
  env,
@@ -65,20 +69,20 @@ export default async (vorpal: Vorpal) =>
65
69
  "cloudsqlProxyCredentials"
66
70
  );
67
71
 
68
- if (!cloudsqlProxyCredentials) {
69
- // we store cloudsqlProxyCredentials on gitlab, but its currently get pushed via bitwarden due to legacy reasons
70
- // this will be fixed with when https://git.panter.ch/catladder/catladder/-/merge_requests/32/ is merged
71
- this.log(
72
- "cloudsqlProxyCredentials env var missing in gitlab. Please contact gilde-ci-cd about that."
73
- );
74
- throw new Error("cloudsqlProxyCredentials missing in secrets");
75
- }
76
72
  await withFile(async ({ path: tmpFilePath }) => {
77
- await writeFile(tmpFilePath, cloudsqlProxyCredentials);
73
+ if (cloudsqlProxyCredentials) {
74
+ await writeFile(tmpFilePath, cloudsqlProxyCredentials);
75
+ }
78
76
 
79
77
  await spawn(
80
78
  "cloud_sql_proxy",
81
- ["-instances", instanceName, "-credential_file", tmpFilePath],
79
+ [
80
+ "-instances",
81
+ `${instanceName}=tcp:${localPort}`,
82
+ ...(cloudsqlProxyCredentials
83
+ ? ["-credential_file", tmpFilePath]
84
+ : []),
85
+ ],
82
86
  {
83
87
  stdio: "inherit",
84
88
  shell: true,
@@ -86,3 +90,72 @@ export default async (vorpal: Vorpal) =>
86
90
  );
87
91
  });
88
92
  });
93
+
94
+ const getProxyInfoForKubernetes = async (
95
+ context: Context
96
+ ): Promise<ProxyInfo> => {
97
+ if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
98
+ throw new Error("unsupported");
99
+ }
100
+
101
+ const envVars = await getEnvVars(
102
+ this,
103
+ context.environment.shortName,
104
+ context.componentName
105
+ );
106
+
107
+ const DB_PASSWORD = envVars?.DB_PASSWORD || envVars?.POSTGRESQL_PASSWORD;
108
+
109
+ const DB_NAME = context.environment.envVars.KUBE_APP_NAME;
110
+
111
+ const values = context.componentConfig.deploy.values;
112
+
113
+ const projectId =
114
+ values?.cloudsql?.projectId ||
115
+ context.componentConfig.deploy.cluster?.projectId;
116
+
117
+ const defaultInstanceId = `${context.fullConfig.customerName}-${context.fullConfig.appName}-${context.environment.shortName}`;
118
+ const instanceId = values?.cloudsql?.instanceId || defaultInstanceId;
119
+
120
+ const defaultRegion = "europe-west6"; // currently hardcoded
121
+ const region = values?.cloudsql?.region || defaultRegion;
122
+
123
+ const instanceName = `${projectId}:${region}:${instanceId}`;
124
+
125
+ return {
126
+ instanceName,
127
+ DB_PASSWORD,
128
+ DB_NAME,
129
+ DB_USER: "postgres",
130
+ };
131
+ };
132
+
133
+ const getProxyInfoForCloudRun = async (
134
+ context: Context
135
+ ): Promise<ProxyInfo> => {
136
+ if (
137
+ !isOfDeployType(context.componentConfig.deploy, "google-cloudrun") ||
138
+ !context.componentConfig.deploy.cloudSql
139
+ ) {
140
+ throw new Error("unsupported");
141
+ }
142
+
143
+ const envVars = await getEnvVars(
144
+ this,
145
+ context.environment.shortName,
146
+ context.componentName
147
+ );
148
+
149
+ const DB_PASSWORD = envVars?.DB_PASSWORD;
150
+ const DB_USER = envVars?.DB_USER;
151
+
152
+ const DB_NAME = context.environment.envVars.DB_NAME;
153
+
154
+ return {
155
+ instanceName:
156
+ context.componentConfig.deploy.cloudSql.instanceConnectionName,
157
+ DB_PASSWORD,
158
+ DB_NAME,
159
+ DB_USER,
160
+ };
161
+ };
@@ -1,19 +1,18 @@
1
1
  /* eslint-disable no-constant-condition */
2
+ import { getSecretVarName } from "@catladder/pipeline";
2
3
  import { stripIndents } from "common-tags";
3
4
  import { difference } from "lodash";
4
- import Vorpal, { CommandInstance } from "vorpal";
5
- import { GOOGLE_CLOUD_SQL_PASS_PATH } from "../../../../config/constants";
5
+ import type { CommandInstance } from "vorpal";
6
+ import type Vorpal from "vorpal";
6
7
  import {
7
8
  getAllComponentsWithAllEnvsHierarchical,
8
9
  getEnvironment,
9
10
  getEnvVars,
10
- getPipelineContextByChoice,
11
11
  getProjectComponents,
12
12
  parseChoice,
13
13
  } from "../../../../config/getProjectConfig";
14
14
  import { editAsFile } from "../../../../utils/editAsFile";
15
15
  import { upsertAllVariables } from "../../../../utils/gitlab";
16
- import { hasBitwarden, readPass } from "../../../../utils/passwordstore";
17
16
  import { delay } from "../../../../utils/promise";
18
17
  import { allEnvsAndAllComponents } from "./utils/autocompletions";
19
18
 
@@ -45,6 +44,7 @@ const resolveJson = (v: Vars) =>
45
44
  ];
46
45
  })
47
46
  );
47
+
48
48
  const getEnvVarsToEdit = async (
49
49
  instance: CommandInstance,
50
50
  env: string,
@@ -54,7 +54,13 @@ const getEnvVarsToEdit = async (
54
54
 
55
55
  const allEnvVars = await getEnvVars(instance, env, componentName);
56
56
  return Object.fromEntries(
57
- secretEnvVarKeys.map((key) => [key, allEnvVars[key]])
57
+ secretEnvVarKeys.map((key) => {
58
+ const value = allEnvVars[key];
59
+ // due to some quirky way to resolve these variables, unset variables have the $CL_ prefix, so we remove thouse here
60
+ const variableIsNotSet =
61
+ value === "$" + getSecretVarName(env, componentName, key);
62
+ return [key, variableIsNotSet ? "🚨 FILL ME" : value];
63
+ })
58
64
  );
59
65
  };
60
66
  const doItFor = async (
@@ -148,32 +154,7 @@ const doItFor = async (
148
154
  env,
149
155
  componentName
150
156
  );
151
-
152
- if (hasBitwarden()) {
153
- // add cloud sql secret if needed.
154
- // TODO: this is legacy, in the future we want to have one service account per app
155
- try {
156
- const context = await getPipelineContextByChoice(env, componentName);
157
- if (
158
- context.componentConfig.deploy &&
159
- context.componentConfig.deploy.type === "kubernetes" &&
160
- context.componentConfig.deploy.values?.cloudsql?.enabled
161
- ) {
162
- await upsertAllVariables(
163
- instance,
164
- {
165
- cloudsqlProxyCredentials: await readPass(
166
- GOOGLE_CLOUD_SQL_PASS_PATH
167
- ),
168
- },
169
- env,
170
- componentName
171
- );
172
- }
173
- } catch (e) {
174
- // ignore atm
175
- }
176
- }
157
+ instance.log("");
177
158
  instance.log("✅ " + env + ":" + componentName);
178
159
  }
179
160
  }
@@ -1,11 +1,9 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { getk8sApi } from "../../../../k8sApi";
3
+ import { getProjectPodNames } from "../../../../kubernetes";
3
4
 
4
5
  import { logError } from "../../../../utils/log";
5
- import {
6
- getProjectNamespace,
7
- getProjectPodNames,
8
- } from "../../../../utils/projects";
6
+ import { getProjectNamespace } from "../../../../utils/projects";
9
7
  import { envAndComponents } from "./utils/autocompletions";
10
8
  import ensureCluster from "./utils/ensureCluster";
11
9
 
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { exec } from "child-process-promise";
3
3
  import { getProjectNamespace } from "../../../../utils/projects";
4
4
  import { envAndComponents } from "./utils/autocompletions";
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { getEnvVars, parseChoice } from "../../../../config/getProjectConfig";
3
3
  import { envAndComponents } from "./utils/autocompletions";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { spawn } from "child-process-promise";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
3
 
4
4
  export default async (vorpal: Vorpal) =>
5
5
  vorpal
@@ -8,7 +8,7 @@ export default async (vorpal: Vorpal) =>
8
8
  "show the total worktime that you spent on a project"
9
9
  )
10
10
  .action(async () => {
11
- await spawn("sh", ["-c", "curl -L http://bit.ly/10hA8iC | bash"], {
11
+ await spawn("sh", ["-c", "curl -s -L http://bit.ly/3VQEKNq | bash"], {
12
12
  stdio: ["pipe", "inherit", "pipe"],
13
13
  });
14
14
  });
@@ -1,9 +1,7 @@
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
- getProjectNamespace,
5
- getProjectPodNames,
6
- } from "../../../../utils/projects";
4
+ import { getProjectNamespace } from "../../../../utils/projects";
7
5
  import { getShell } from "../../../../utils/shell";
8
6
 
9
7
  import { envAndComponents } from "./utils/autocompletions";
@@ -1,7 +1,8 @@
1
1
  import { exec } from "child-process-promise";
2
2
  import { last } from "lodash";
3
3
  import open from "open";
4
- import Vorpal, { CommandInstance } from "vorpal";
4
+ import type { CommandInstance } from "vorpal";
5
+ import type Vorpal from "vorpal";
5
6
  import {
6
7
  doGitlabRequest,
7
8
  getGitlabToken,
@@ -2,7 +2,7 @@ import { readFile, writeFile } from "fs-extra";
2
2
  import { dump } from "js-yaml";
3
3
  import { mapKeys, snakeCase, toUpper } from "lodash";
4
4
  import path from "path";
5
- import Vorpal from "vorpal";
5
+ import type Vorpal from "vorpal";
6
6
  import { hasGitlabCiFile } from "../../../../utils/projects";
7
7
 
8
8
  const transformVar = (key: string) => toUpper(snakeCase(key));
@@ -1,7 +1,7 @@
1
1
  import { dump } from "js-yaml";
2
2
  import { pick } from "lodash";
3
- import Vorpal from "vorpal";
4
- import { getProjectPods } from "../../../../utils/projects";
3
+ import type Vorpal from "vorpal";
4
+ import { getProjectPods } from "../../../../kubernetes";
5
5
  import { envAndComponents } from "./utils/autocompletions";
6
6
  import ensureCluster from "./utils/ensureCluster";
7
7
 
@@ -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
- const releaseName = (await getEnvironment(env, componentName)).envVars
47
- .RELEASE_NAME; // TODO: maybe its own function would be better
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,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { getProjectNamespace } from "../../../../utils/projects";
3
3
  import { envAndComponents } from "./utils/autocompletions";
4
4
 
@@ -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 { startPortForward } from "../../../../utils/portForward";
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 startPortForward(
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 Vorpal from "vorpal";
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 { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
7
- import { openGoogleCloudKubernetesDashboard } from "../shared";
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 kubernetes dashboard on google"
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 { componentConfig, environment } = await getPipelineContextByChoice(
19
- env,
20
- componentName
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
- if (
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
1
  import open from "open";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
3
  import {
4
4
  getEnvironment,
5
5
  parseChoice,
@@ -1,5 +1,5 @@
1
- import Vorpal from "vorpal";
2
- import { $ } from "zx";
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 $`npx git-open`;
11
+ await exec("npx git-open");
12
12
  });
@@ -1,6 +1,6 @@
1
1
  import open from "open";
2
- import { startPortForward } from "../../../../utils/portForward";
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 startPortForward(
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 { startPortForward } from "../../../../utils/portForward";
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 startPortForward(
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 { getCurrentConnectedClusterName } from "../../../../utils/cluster";
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 { componentConfig, environment } = await getPipelineContextByChoice(
23
- env,
24
- componentName
25
- );
18
+ const context = await getPipelineContextByChoice(env, componentName);
26
19
 
27
- if (
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,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { exec } from "child-process-promise";
3
3
  import { getProjectNamespace } from "../../../../utils/projects";
4
4
  import { envAndComponents } from "./utils/autocompletions";