@catladder/cli 0.0.0-test7 → 0.0.0-waitfor-deploy-e64a33ba

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/.nvmrc +1 -1
  2. package/README.md +6 -3
  3. package/bin/catenv +3 -0
  4. package/bin/catladder +1 -1
  5. package/dist/apps/catenv/catenv.d.ts +5 -0
  6. package/dist/apps/catenv/catenv.js +143 -0
  7. package/dist/apps/catenv/catenv.js.map +1 -0
  8. package/dist/apps/cli/cli.d.ts +2 -0
  9. package/dist/apps/cli/cli.js +81 -0
  10. package/dist/apps/cli/cli.js.map +1 -0
  11. package/dist/apps/cli/commands/general/index.d.ts +4 -0
  12. package/dist/apps/cli/commands/general/index.js +216 -0
  13. package/dist/apps/cli/commands/general/index.js.map +1 -0
  14. package/dist/apps/cli/commands/general/namespaceAutoCompletion.d.ts +3 -0
  15. package/dist/apps/cli/commands/general/namespaceAutoCompletion.js +56 -0
  16. package/dist/apps/cli/commands/general/namespaceAutoCompletion.js.map +1 -0
  17. package/dist/apps/cli/commands/general/portForward.d.ts +3 -0
  18. package/dist/apps/cli/commands/general/portForward.js +97 -0
  19. package/dist/apps/cli/commands/general/portForward.js.map +1 -0
  20. package/dist/apps/cli/commands/mongodb/index.d.ts +3 -0
  21. package/dist/apps/cli/commands/mongodb/index.js +53 -0
  22. package/dist/apps/cli/commands/mongodb/index.js.map +1 -0
  23. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +3 -0
  24. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +190 -0
  25. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -0
  26. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +3 -0
  27. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js +96 -0
  28. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js.map +1 -0
  29. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +3 -0
  30. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +105 -0
  31. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -0
  32. package/dist/apps/cli/commands/mongodb/utils/index.d.ts +13 -0
  33. package/dist/apps/cli/commands/mongodb/utils/index.js +167 -0
  34. package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -0
  35. package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +3 -0
  36. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +137 -0
  37. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -0
  38. package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +4 -0
  39. package/dist/apps/cli/commands/project/commandConfigSecrets.js +320 -0
  40. package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -0
  41. package/dist/apps/cli/commands/project/commandCopyDB.d.ts +3 -0
  42. package/dist/apps/cli/commands/project/commandCopyDB.js +102 -0
  43. package/dist/apps/cli/commands/project/commandCopyDB.js.map +1 -0
  44. package/dist/apps/cli/commands/project/commandDeletePods.d.ts +3 -0
  45. package/dist/apps/cli/commands/project/commandDeletePods.js +120 -0
  46. package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -0
  47. package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +3 -0
  48. package/dist/apps/cli/commands/project/commandDeleteProject.js +97 -0
  49. package/dist/apps/cli/commands/project/commandDeleteProject.js.map +1 -0
  50. package/dist/apps/cli/commands/project/commandEnvVars.d.ts +3 -0
  51. package/dist/apps/cli/commands/project/commandEnvVars.js +74 -0
  52. package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -0
  53. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +3 -0
  54. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +58 -0
  55. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -0
  56. package/dist/apps/cli/commands/project/commandGetShell.d.ts +3 -0
  57. package/dist/apps/cli/commands/project/commandGetShell.js +92 -0
  58. package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -0
  59. package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +3 -0
  60. package/dist/apps/cli/commands/project/commandGitlabCi.js +185 -0
  61. package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -0
  62. package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +3 -0
  63. package/dist/apps/cli/commands/project/commandInitProject.old.js +345 -0
  64. package/dist/apps/cli/commands/project/commandInitProject.old.js.map +1 -0
  65. package/dist/apps/cli/commands/project/commandListPods.d.ts +3 -0
  66. package/dist/apps/cli/commands/project/commandListPods.js +78 -0
  67. package/dist/apps/cli/commands/project/commandListPods.js.map +1 -0
  68. package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +7 -0
  69. package/dist/apps/cli/commands/project/commandMigrateHelm3.js +113 -0
  70. package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -0
  71. package/dist/apps/cli/commands/project/commandNamespace.d.ts +3 -0
  72. package/dist/apps/cli/commands/project/commandNamespace.js +70 -0
  73. package/dist/apps/cli/commands/project/commandNamespace.js.map +1 -0
  74. package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +3 -0
  75. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +83 -0
  76. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -0
  77. package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +3 -0
  78. package/dist/apps/cli/commands/project/commandOpenDashboard.js +85 -0
  79. package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -0
  80. package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +3 -0
  81. package/dist/apps/cli/commands/project/commandOpenEnv.js +80 -0
  82. package/dist/apps/cli/commands/project/commandOpenEnv.js.map +1 -0
  83. package/dist/apps/cli/commands/project/commandOpenGit.d.ts +3 -0
  84. package/dist/apps/cli/commands/project/commandOpenGit.js +61 -0
  85. package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -0
  86. package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +3 -0
  87. package/dist/apps/cli/commands/project/commandOpenGrafana.js +83 -0
  88. package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -0
  89. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +3 -0
  90. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +99 -0
  91. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -0
  92. package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +3 -0
  93. package/dist/apps/cli/commands/project/commandOpenLogs.js +87 -0
  94. package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -0
  95. package/dist/apps/cli/commands/project/commandPauseProject.d.ts +3 -0
  96. package/dist/apps/cli/commands/project/commandPauseProject.js +97 -0
  97. package/dist/apps/cli/commands/project/commandPauseProject.js.map +1 -0
  98. package/dist/apps/cli/commands/project/commandPortForward.d.ts +3 -0
  99. package/dist/apps/cli/commands/project/commandPortForward.js +106 -0
  100. package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -0
  101. package/dist/apps/cli/commands/project/commandSetup.d.ts +3 -0
  102. package/dist/apps/cli/commands/project/commandSetup.js +58 -0
  103. package/dist/apps/cli/commands/project/commandSetup.js.map +1 -0
  104. package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +3 -0
  105. package/dist/apps/cli/commands/project/commandTriggerCronjob.js +144 -0
  106. package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -0
  107. package/dist/apps/cli/commands/project/index.d.ts +3 -0
  108. package/dist/apps/cli/commands/project/index.js +94 -0
  109. package/dist/apps/cli/commands/project/index.js.map +1 -0
  110. package/dist/apps/cli/commands/project/setup/index.d.ts +2 -0
  111. package/dist/apps/cli/commands/project/setup/index.js +103 -0
  112. package/dist/apps/cli/commands/project/setup/index.js.map +1 -0
  113. package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +2 -0
  114. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +115 -0
  115. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -0
  116. package/dist/apps/cli/commands/project/setup/setupContext.d.ts +3 -0
  117. package/dist/apps/cli/commands/project/setup/setupContext.js +74 -0
  118. package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -0
  119. package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +3 -0
  120. package/dist/apps/cli/commands/project/setup/setupKubernetes.js +132 -0
  121. package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -0
  122. package/dist/apps/cli/commands/project/utils/autocompletions.d.ts +3 -0
  123. package/dist/apps/cli/commands/project/utils/autocompletions.js +96 -0
  124. package/dist/apps/cli/commands/project/utils/autocompletions.js.map +1 -0
  125. package/dist/apps/cli/commands/project/utils/ensureCluster.d.ts +1 -0
  126. package/dist/apps/cli/commands/project/utils/ensureCluster.js +84 -0
  127. package/dist/apps/cli/commands/project/utils/ensureCluster.js.map +1 -0
  128. package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +2 -0
  129. package/dist/apps/cli/commands/project/utils/ensureNamespace.js +104 -0
  130. package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -0
  131. package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +2 -0
  132. package/dist/apps/cli/commands/project/utils/showProjectBanner.js +58 -0
  133. package/dist/apps/cli/commands/project/utils/showProjectBanner.js.map +1 -0
  134. package/dist/apps/cli/commands/shared/index.d.ts +3 -0
  135. package/dist/apps/cli/commands/shared/index.js +70 -0
  136. package/dist/apps/cli/commands/shared/index.js.map +1 -0
  137. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +3 -0
  138. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +101 -0
  139. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -0
  140. package/dist/apps/cli/config/writeConfig.d.ts +5 -0
  141. package/dist/apps/cli/config/writeConfig.js +106 -0
  142. package/dist/apps/cli/config/writeConfig.js.map +1 -0
  143. package/dist/apps/cli/utils/getGoogleAuthUserNumber.d.ts +1 -0
  144. package/dist/apps/cli/utils/getGoogleAuthUserNumber.js +69 -0
  145. package/dist/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -0
  146. package/dist/apps/cli/verify/index.d.ts +2 -0
  147. package/dist/apps/cli/verify/index.js +94 -0
  148. package/dist/apps/cli/verify/index.js.map +1 -0
  149. package/dist/apps/cli/verify/migration/fromv2.d.ts +4 -0
  150. package/dist/apps/cli/verify/migration/fromv2.js +347 -0
  151. package/dist/apps/cli/verify/migration/fromv2.js.map +1 -0
  152. package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +4 -0
  153. package/dist/apps/cli/verify/migration/migrateSecrets.js +88 -0
  154. package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -0
  155. package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +18 -0
  156. package/dist/apps/cli/verify/migration/oldGitlabCi.js +30 -0
  157. package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -0
  158. package/dist/catenv.d.ts +1 -0
  159. package/dist/catenv.js +15 -0
  160. package/dist/catenv.js.map +1 -0
  161. package/dist/cli.d.ts +1 -0
  162. package/dist/cli.js +15 -0
  163. package/dist/cli.js.map +1 -0
  164. package/dist/config/constants.d.ts +3 -0
  165. package/dist/config/constants.js +7 -0
  166. package/dist/config/constants.js.map +1 -0
  167. package/dist/config/getProjectConfig.d.ts +24 -0
  168. package/dist/config/getProjectConfig.js +259 -0
  169. package/dist/config/getProjectConfig.js.map +1 -0
  170. package/dist/k8sApi/index.d.ts +8 -0
  171. package/dist/k8sApi/index.js +29 -0
  172. package/dist/k8sApi/index.js.map +1 -0
  173. package/dist/packageInfos.d.ts +2 -0
  174. package/dist/packageInfos.js +6 -0
  175. package/dist/packageInfos.js.map +1 -0
  176. package/dist/tsconfig.tsbuildinfo +1 -0
  177. package/dist/types/types.d.ts +18 -0
  178. package/dist/types/types.js +3 -0
  179. package/dist/types/types.js.map +1 -0
  180. package/dist/utils/cluster.d.ts +3 -0
  181. package/dist/utils/cluster.js +73 -0
  182. package/dist/utils/cluster.js.map +1 -0
  183. package/dist/utils/editAsFile.d.ts +1 -0
  184. package/dist/utils/editAsFile.js +85 -0
  185. package/dist/utils/editAsFile.js.map +1 -0
  186. package/dist/utils/files.d.ts +2 -0
  187. package/dist/utils/files.js +83 -0
  188. package/dist/utils/files.js.map +1 -0
  189. package/dist/utils/getEditor.d.ts +4 -0
  190. package/dist/utils/getEditor.js +70 -0
  191. package/dist/utils/getEditor.js.map +1 -0
  192. package/dist/utils/gitlab.d.ts +22 -0
  193. package/dist/utils/gitlab.js +278 -0
  194. package/dist/utils/gitlab.js.map +1 -0
  195. package/dist/utils/log.d.ts +1 -0
  196. package/dist/utils/log.js +14 -0
  197. package/dist/utils/log.js.map +1 -0
  198. package/dist/utils/passwordstore/index.d.ts +8 -0
  199. package/dist/utils/passwordstore/index.js +378 -0
  200. package/dist/utils/passwordstore/index.js.map +1 -0
  201. package/dist/utils/portForward.d.ts +4 -0
  202. package/dist/utils/portForward.js +116 -0
  203. package/dist/utils/portForward.js.map +1 -0
  204. package/dist/utils/preferences/index.d.ts +3 -0
  205. package/dist/utils/preferences/index.js +119 -0
  206. package/dist/utils/preferences/index.js.map +1 -0
  207. package/dist/utils/projects/index.d.ts +8 -0
  208. package/dist/utils/projects/index.js +153 -0
  209. package/dist/utils/projects/index.js.map +1 -0
  210. package/dist/utils/promise.d.ts +2 -0
  211. package/dist/utils/promise.js +62 -0
  212. package/dist/utils/promise.js.map +1 -0
  213. package/dist/utils/shell.d.ts +1 -0
  214. package/dist/utils/shell.js +81 -0
  215. package/dist/utils/shell.js.map +1 -0
  216. package/package.json +16 -21
  217. package/src/apps/catenv/catenv.ts +55 -27
  218. package/src/apps/{shell/shell.ts → cli/cli.ts} +10 -2
  219. package/src/apps/{shell → cli}/commands/general/index.ts +7 -46
  220. package/src/apps/{shell → cli}/commands/general/namespaceAutoCompletion.ts +0 -0
  221. package/src/apps/{shell → cli}/commands/general/portForward.ts +3 -2
  222. package/src/apps/{shell → cli}/commands/mongodb/index.ts +1 -1
  223. package/src/apps/{shell → cli}/commands/mongodb/projectMongoDestroyMember.ts +18 -18
  224. package/src/apps/{shell → cli}/commands/mongodb/projectMongoGetShell.ts +12 -10
  225. package/src/apps/{shell → cli}/commands/mongodb/projectMongoPortForward.ts +13 -8
  226. package/src/apps/{shell → cli}/commands/mongodb/utils/index.ts +9 -8
  227. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +88 -0
  228. package/src/apps/cli/commands/project/commandConfigSecrets.ts +220 -0
  229. package/src/apps/{shell → cli}/commands/project/commandCopyDB.ts +24 -26
  230. package/src/apps/{shell → cli}/commands/project/commandDeletePods.ts +10 -10
  231. package/src/apps/{shell → cli}/commands/project/commandDeleteProject.ts +7 -8
  232. package/src/apps/cli/commands/project/commandEnvVars.ts +15 -0
  233. package/src/apps/{shell → cli}/commands/project/commandGetMyTotalWorktime.ts +2 -2
  234. package/src/apps/{shell → cli}/commands/project/commandGetShell.ts +10 -10
  235. package/src/apps/{shell → cli}/commands/project/commandGitlabCi.ts +1 -1
  236. package/src/apps/{shell/commands/project/commandInitProject.ts → cli/commands/project/commandInitProject.old.ts} +14 -6
  237. package/src/apps/cli/commands/project/commandListPods.ts +18 -0
  238. package/src/apps/{shell → cli}/commands/project/commandMigrateHelm3.ts +16 -7
  239. package/src/apps/cli/commands/project/commandNamespace.ts +14 -0
  240. package/src/apps/{shell → cli}/commands/project/commandOpenCostDashboard.ts +10 -7
  241. package/src/apps/cli/commands/project/commandOpenDashboard.ts +48 -0
  242. package/src/apps/cli/commands/project/commandOpenEnv.ts +22 -0
  243. package/src/apps/{shell → cli}/commands/project/commandOpenGit.ts +3 -3
  244. package/src/apps/{shell → cli}/commands/project/commandOpenGrafana.ts +7 -7
  245. package/src/apps/{shell → cli}/commands/project/commandOpenGrafanaPod.ts +9 -10
  246. package/src/apps/cli/commands/project/commandOpenLogs.ts +52 -0
  247. package/src/apps/{shell → cli}/commands/project/commandPauseProject.ts +9 -7
  248. package/src/apps/{shell → cli}/commands/project/commandPortForward.ts +8 -8
  249. package/src/apps/cli/commands/project/commandSetup.ts +12 -0
  250. package/src/apps/{shell → cli}/commands/project/commandTriggerCronjob.ts +10 -10
  251. package/src/apps/{shell → cli}/commands/project/index.ts +6 -7
  252. package/src/apps/cli/commands/project/setup/index.ts +42 -0
  253. package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +72 -0
  254. package/src/apps/cli/commands/project/setup/setupContext.ts +37 -0
  255. package/src/apps/cli/commands/project/setup/setupKubernetes.ts +112 -0
  256. package/src/apps/cli/commands/project/utils/autocompletions.ts +26 -0
  257. package/src/apps/cli/commands/project/utils/ensureCluster.ts +42 -0
  258. package/src/apps/cli/commands/project/utils/ensureNamespace.ts +56 -0
  259. package/src/apps/cli/commands/project/utils/showProjectBanner.ts +11 -0
  260. package/src/apps/cli/commands/shared/index.ts +36 -0
  261. package/src/apps/{shell → cli}/commands/theStuffThatReallyMatters/index.ts +7 -26
  262. package/src/apps/cli/config/writeConfig.ts +71 -0
  263. package/src/apps/{shell → cli}/utils/getGoogleAuthUserNumber.ts +0 -0
  264. package/src/apps/cli/verify/index.ts +30 -0
  265. package/src/apps/cli/verify/migration/fromv2.ts +264 -0
  266. package/src/apps/cli/verify/migration/migrateSecrets.ts +37 -0
  267. package/src/apps/cli/verify/migration/oldGitlabCi.ts +48 -0
  268. package/src/catenv.ts +11 -0
  269. package/src/cli.ts +9 -0
  270. package/src/config/constants.ts +0 -1
  271. package/src/config/getProjectConfig.ts +160 -0
  272. package/src/k8sApi/index.ts +22 -6
  273. package/src/types/types.ts +0 -2
  274. package/src/utils/cluster.ts +6 -15
  275. package/src/utils/editAsFile.ts +31 -0
  276. package/src/utils/files.ts +6 -2
  277. package/src/utils/gitlab.ts +144 -34
  278. package/src/utils/passwordstore/index.ts +19 -21
  279. package/src/utils/preferences/index.ts +6 -3
  280. package/src/utils/projects/index.ts +18 -137
  281. package/tsconfig.json +3 -7
  282. package/bin/catenv.sh +0 -1
  283. package/src/apps/shell/commands/project/commandCloudSqlProxy.ts +0 -65
  284. package/src/apps/shell/commands/project/commandConfigSecrets.ts +0 -245
  285. package/src/apps/shell/commands/project/commandEnvVars.ts +0 -17
  286. package/src/apps/shell/commands/project/commandInitGitlab.ts +0 -157
  287. package/src/apps/shell/commands/project/commandListPods.ts +0 -21
  288. package/src/apps/shell/commands/project/commandNamespace.ts +0 -12
  289. package/src/apps/shell/commands/project/commandOpenDashboard.ts +0 -27
  290. package/src/apps/shell/commands/project/commandOpenEnv.ts +0 -18
  291. package/src/apps/shell/commands/project/commandOpenLogs.ts +0 -23
  292. package/src/apps/shell/commands/project/commandVariables.ts +0 -13
  293. package/src/apps/shell/commands/project/utils/autocompletions.ts +0 -7
  294. package/src/apps/shell/commands/project/utils/ensureCluster.ts +0 -31
  295. package/src/apps/shell/commands/project/utils/ensureNamespace.ts +0 -32
  296. package/src/apps/shell/commands/project/utils/monorepo.ts +0 -45
  297. package/src/apps/shell/commands/shared/index.ts +0 -31
  298. package/src/config/clusters.ts +0 -45
  299. package/src/index.ts +0 -17
  300. package/src/types/git-repo-name.d.ts +0 -1
  301. package/src/types/yawn-yaml.d.ts +0 -1
  302. package/src/utils/dashboardToken.ts +0 -20
  303. package/src/utils/formatEnvVars.ts +0 -7
@@ -1,27 +1,24 @@
1
1
  import { spawn } from "child-process-promise";
2
2
  import Vorpal from "vorpal";
3
+ import { GOOGLE_CLOUD_SQL_PASS_PATH } from "../../../../config/constants";
3
4
  import {
4
- GOOGLE_CLOUD_SQL_PASS_PATH,
5
- GOOGLE_PROJECT,
6
- } from "../../../../config/constants";
5
+ getEnvVars,
6
+ getProjectConfig,
7
+ parseChoice,
8
+ } from "../../../../config/getProjectConfig";
7
9
  import { readPass } from "../../../../utils/passwordstore";
8
- import {
9
- getAllEnvVars,
10
- getLocalProjectVariables,
11
- } from "../../../../utils/projects";
12
- import { envAutocompletion } from "./utils/autocompletions";
13
- import { promptForSubAppIfAny } from "./utils/monorepo";
10
+ import { envAndComponents } from "./utils/autocompletions";
14
11
 
15
- export default (vorpal: Vorpal) =>
12
+ export default async (vorpal: Vorpal) =>
16
13
  vorpal
17
- .command("copy-db <env>", "replace local db with the one from an env")
18
- .autocomplete(envAutocompletion)
19
- .action(async function copyDB({ env }) {
20
- const {
21
- CUSTOMER_NAME,
22
- APP_NAME,
23
- COMPONENT_NAME = "web",
24
- } = await getLocalProjectVariables();
14
+ .command(
15
+ "copy-db <envComponent>",
16
+ "replace local db with the one from an env"
17
+ )
18
+ .autocomplete(await envAndComponents())
19
+ .action(async function copyDB({ envComponent }) {
20
+ const { env, componentName } = parseChoice(envComponent);
21
+ const { customerName, appName } = await getProjectConfig();
25
22
 
26
23
  const { shouldContinue } = await this.prompt({
27
24
  type: "confirm",
@@ -34,15 +31,18 @@ export default (vorpal: Vorpal) =>
34
31
  return;
35
32
  }
36
33
 
37
- const subapp = await promptForSubAppIfAny(this);
38
-
34
+ // TODO: reimpleent with new config
35
+ throw new Error("needs reimplementation with new config");
39
36
  const GOOGLE_CLOUD_SQL_REGION = "europe-west6"; // currently hardcoded
40
- const POSTGRESQL_PASSWORD = (await getAllEnvVars(env, subapp))
41
- ?.POSTGRESQL_PASSWORD;
37
+ const { POSTGRESQL_PASSWORD } = await getEnvVars(
38
+ this,
39
+ env,
40
+ componentName
41
+ );
42
42
 
43
43
  const LOCAL_PORT = 54321;
44
44
 
45
- const instanceName = `${GOOGLE_PROJECT}:${GOOGLE_CLOUD_SQL_REGION}:${CUSTOMER_NAME}-${APP_NAME}-${env}=tcp:${LOCAL_PORT}`;
45
+ const instanceName = `${"xxxxxx reimplement shoulld be project id"}:${GOOGLE_CLOUD_SQL_REGION}:${customerName}-${appName}-${env}=tcp:${LOCAL_PORT}`;
46
46
  const cloudsqlCredentials = await readPass(GOOGLE_CLOUD_SQL_PASS_PATH);
47
47
 
48
48
  const { POSTGRESQL_URL } = process.env;
@@ -72,9 +72,7 @@ export default (vorpal: Vorpal) =>
72
72
  dumptmp=$(mktemp /tmp/dump.XXXXXX)
73
73
 
74
74
  echo "Dumping file to $dumptmp"
75
- pg_dump --dbname=postgres://postgres:${POSTGRESQL_PASSWORD}@localhost:${LOCAL_PORT}/${
76
- subapp ?? COMPONENT_NAME
77
- } --no-owner --no-privileges > $dumptmp
75
+ pg_dump --dbname=postgres://postgres:${POSTGRESQL_PASSWORD}@localhost:${LOCAL_PORT}/${componentName} --no-owner --no-privileges > $dumptmp
78
76
  psql -q -c "drop database ${localDBName}" 1> /dev/null
79
77
  psql -q -c "create database ${localDBName}" 1> /dev/null
80
78
  echo "Restoring dump..."
@@ -1,23 +1,22 @@
1
- import { V1DeleteOptions } from "@kubernetes/client-node";
2
1
  import Vorpal from "vorpal";
3
- import k8sApi from "../../../../k8sApi";
2
+ import { getk8sApi } from "../../../../k8sApi";
4
3
 
5
4
  import { logError } from "../../../../utils/log";
6
5
  import {
7
6
  getProjectNamespace,
8
7
  getProjectPodNames,
9
8
  } from "../../../../utils/projects";
10
- import { envAutocompletion } from "./utils/autocompletions";
9
+ import { envAndComponents } from "./utils/autocompletions";
11
10
  import ensureCluster from "./utils/ensureCluster";
12
11
 
13
- export default (vorpal: Vorpal) =>
12
+ export default async (vorpal: Vorpal) =>
14
13
  vorpal
15
- .command("project-delete-pods <env>", "delete / restart pods")
16
- .autocomplete(envAutocompletion)
17
- .action(async function ({ env }) {
18
- await ensureCluster.call(this);
19
- const namespace = await getProjectNamespace(env);
20
- const podNames = await getProjectPodNames(env);
14
+ .command("project-delete-pods <envComponent>", "delete / restart pods")
15
+ .autocomplete(await envAndComponents())
16
+ .action(async function ({ envComponent }) {
17
+ await ensureCluster.call(this, envComponent);
18
+ const namespace = await getProjectNamespace(envComponent);
19
+ const podNames = await getProjectPodNames(envComponent);
21
20
  if (podNames.length === 0) {
22
21
  logError(this, "sorry, no pods found");
23
22
  return;
@@ -41,6 +40,7 @@ export default (vorpal: Vorpal) =>
41
40
  message: "Continue ? 🤔 ",
42
41
  });
43
42
  this.log("");
43
+ const k8sApi = getk8sApi();
44
44
  if (shouldContinue) {
45
45
  for (const podName of selectedPodNames) {
46
46
  await k8sApi.deleteNamespacedPod(podName, namespace, "true");
@@ -1,18 +1,17 @@
1
1
  import Vorpal from "vorpal";
2
- import { exec, spawn } from "child-process-promise";
3
- import { Env } from "../../../../types/types";
2
+ import { exec } from "child-process-promise";
4
3
  import { getProjectNamespace } from "../../../../utils/projects";
5
- import { envAutocompletion } from "./utils/autocompletions";
4
+ import { envAndComponents } from "./utils/autocompletions";
6
5
 
7
- export default (vorpal: Vorpal) =>
6
+ export default async (vorpal: Vorpal) =>
8
7
  vorpal
9
8
  .command(
10
- "project-delete <env>",
9
+ "project-delete <envComponent>",
11
10
  "deletes a environment of a project (it deletes the namespace)"
12
11
  )
13
- .autocomplete(envAutocompletion)
14
- .action(async function ({ env }) {
15
- const namespace = await getProjectNamespace(env as Env);
12
+ .autocomplete(await envAndComponents())
13
+ .action(async function ({ envComponent }) {
14
+ const namespace = await getProjectNamespace(envComponent);
16
15
  const { shouldContinue } = await this.prompt({
17
16
  type: "confirm",
18
17
  name: "shouldContinue",
@@ -0,0 +1,15 @@
1
+ import Vorpal from "vorpal";
2
+ import { getEnvVars, parseChoice } from "../../../../config/getProjectConfig";
3
+ import { envAndComponents } from "./utils/autocompletions";
4
+
5
+ export default async (vorpal: Vorpal) =>
6
+ vorpal
7
+ .command("project-env-vars <envComponent>", "list env vars")
8
+ .autocomplete(await envAndComponents())
9
+ .action(async function ({ envComponent }) {
10
+ const { env, componentName } = parseChoice(envComponent);
11
+ const envvars = await getEnvVars(this, env, componentName);
12
+ Object.keys(envvars).forEach((key) =>
13
+ this.log(`${key}: ${envvars[key]}`)
14
+ );
15
+ });
@@ -1,7 +1,7 @@
1
1
  import { spawn } from "child-process-promise";
2
2
  import Vorpal from "vorpal";
3
3
 
4
- export default (vorpal: Vorpal) =>
4
+ export default async (vorpal: Vorpal) =>
5
5
  vorpal
6
6
  .command(
7
7
  "project-get-my-total-worktime",
@@ -9,6 +9,6 @@ export default (vorpal: Vorpal) =>
9
9
  )
10
10
  .action(async () => {
11
11
  await spawn("sh", ["-c", "curl -L http://bit.ly/10hA8iC | bash"], {
12
- stdio: ["pipe", "inherit", "pipe"]
12
+ stdio: ["pipe", "inherit", "pipe"],
13
13
  });
14
14
  });
@@ -2,24 +2,24 @@ import Vorpal from "vorpal";
2
2
  import { logError } from "../../../../utils/log";
3
3
  import {
4
4
  getProjectNamespace,
5
- getProjectPodNames
5
+ getProjectPodNames,
6
6
  } from "../../../../utils/projects";
7
7
  import { getShell } from "../../../../utils/shell";
8
8
 
9
- import { envAutocompletion } from "./utils/autocompletions";
9
+ import { envAndComponents } from "./utils/autocompletions";
10
10
  import ensureCluster from "./utils/ensureCluster";
11
11
 
12
- export default (vorpal: Vorpal) =>
12
+ export default async (vorpal: Vorpal) =>
13
13
  vorpal
14
14
  .command(
15
- "project-get-shell <env>",
15
+ "project-get-shell <envComponent>",
16
16
  "get a shell to a pod in the environment"
17
17
  )
18
- .autocomplete(envAutocompletion)
19
- .action(async function({ env }) {
20
- await ensureCluster.call(this);
21
- const namespace = await getProjectNamespace(env);
22
- const podNames = await getProjectPodNames(env);
18
+ .autocomplete(await envAndComponents())
19
+ .action(async function ({ envComponent }) {
20
+ await ensureCluster.call(this, envComponent);
21
+ const namespace = await getProjectNamespace(envComponent);
22
+ const podNames = await getProjectPodNames(envComponent);
23
23
  if (podNames.length === 0) {
24
24
  logError(this, "sorry, no pods found");
25
25
  return;
@@ -28,7 +28,7 @@ export default (vorpal: Vorpal) =>
28
28
  type: "list",
29
29
  name: "podName",
30
30
  choices: podNames,
31
- message: "Which pod? 🤔"
31
+ message: "Which pod? 🤔",
32
32
  });
33
33
 
34
34
  return getShell(namespace, podName);
@@ -64,7 +64,7 @@ const promptJob = async (vorpal: CommandInstance, projectId: any, ctx: any) => {
64
64
  return jobs.find((j: any) => j.id === jobId);
65
65
  };
66
66
 
67
- export default (vorpal: Vorpal) => {
67
+ export default async (vorpal: Vorpal) => {
68
68
  vorpal.command("project-ci-job-open", "Open a Job").action(async function () {
69
69
  const { id: projectId } = await getProjectInfo(this);
70
70
 
@@ -1,5 +1,5 @@
1
1
  import { readFile, writeFile } from "fs-extra";
2
- import { safeDump } from "js-yaml";
2
+ import { dump } from "js-yaml";
3
3
  import { mapKeys, snakeCase, toUpper } from "lodash";
4
4
  import path from "path";
5
5
  import Vorpal from "vorpal";
@@ -29,7 +29,7 @@ const DEFAULT_VARIABLES = {
29
29
  clusterName: "production",
30
30
  };
31
31
  // TODO: we should find a way how to fetch the variables of the inclues directly from gitlab
32
- const DEFAULT_NODE_APPLICATION = {};
32
+ const DEFAULT_NODE_asdfAPPLICATION = {};
33
33
 
34
34
  const DEFAULT_FILES_TO_CREATE: FileToCreate[] = [
35
35
  {
@@ -38,6 +38,9 @@ const DEFAULT_FILES_TO_CREATE: FileToCreate[] = [
38
38
  readFile(path.resolve(__dirname, "../includes/envrc"), "utf8"),
39
39
  },
40
40
  ];
41
+ /*
42
+
43
+ TODO: reimplement as PRESETS ?
41
44
  const PLATFORMS: { [platformName: string]: PlatformDefinition } = {
42
45
  nextJS: {
43
46
  variables: {},
@@ -154,7 +157,7 @@ const PLATFORMS: { [platformName: string]: PlatformDefinition } = {
154
157
  {
155
158
  filename: "values-review.yml",
156
159
  content: async () =>
157
- safeDump({
160
+ dump({
158
161
  jobs: {
159
162
  "db-prepare-seed": {
160
163
  hook: "post-install",
@@ -180,10 +183,15 @@ const PLATFORMS: { [platformName: string]: PlatformDefinition } = {
180
183
  values: {},
181
184
  },
182
185
  };
183
- export default (vorpal: Vorpal) =>
186
+
187
+ */
188
+
189
+ const PLATFORMS: any = {};
190
+ export default async (vorpal: Vorpal) =>
184
191
  vorpal
185
192
  .command("project-init", "Inits a new project")
186
193
  .action(async function () {
194
+ throw new Error("needs reimplementation");
187
195
  const hasGitlabFile = await hasGitlabCiFile();
188
196
  if (hasGitlabFile) {
189
197
  this.log("there is already a gitlab-ci.yml file. Skipping");
@@ -251,7 +259,7 @@ export default (vorpal: Vorpal) =>
251
259
  variables: transformedVariables,
252
260
  };
253
261
 
254
- const gitlabCiContent = safeDump(gitlabCiContentObj);
262
+ const gitlabCiContent = dump(gitlabCiContentObj);
255
263
  await writeFile(".gitlab-ci.yml", gitlabCiContent);
256
264
 
257
265
  allFilesToCreate.forEach(async ({ filename, content }) => {
@@ -260,7 +268,7 @@ export default (vorpal: Vorpal) =>
260
268
  await writeFile(filename, theContent);
261
269
  });
262
270
 
263
- await writeFile("values.yml", safeDump(values));
271
+ await writeFile("values.yml", dump(values));
264
272
 
265
273
  this.log("");
266
274
  this.log("gitlab-ci created! 💪😻");
@@ -0,0 +1,18 @@
1
+ import { dump } from "js-yaml";
2
+ import { pick } from "lodash";
3
+ import Vorpal from "vorpal";
4
+ import { getProjectPods } from "../../../../utils/projects";
5
+ import { envAndComponents } from "./utils/autocompletions";
6
+ import ensureCluster from "./utils/ensureCluster";
7
+
8
+ export default async (vorpal: Vorpal) =>
9
+ vorpal
10
+ .command("project-list-pods <envComponent>", "list pods of local project")
11
+ .autocomplete(await envAndComponents())
12
+ .action(async function ({ envComponent }) {
13
+ await ensureCluster.call(this, envComponent);
14
+ const pods = await getProjectPods(envComponent);
15
+ this.log(
16
+ dump(pods.map((p) => pick(p, ["metadata.name", "status.startTime"])))
17
+ );
18
+ });
@@ -1,24 +1,31 @@
1
1
  import { exec } from "child-process-promise";
2
2
  import Vorpal from "vorpal";
3
+ import {
4
+ getEnvironment,
5
+ parseChoice,
6
+ } from "../../../../config/getProjectConfig";
3
7
  import { logError } from "../../../../utils/log";
4
- import { getProjectHelmReleaseName } from "../../../../utils/projects";
5
- import { envAutocompletion } from "./utils/autocompletions";
8
+
9
+ import { envAndComponents } from "./utils/autocompletions";
6
10
 
7
11
  /**
8
12
  * Error: rendered manifests contain a resource that already exists.
9
13
  * Unable to continue with install: ConfigMap "web-app-env" in namespace "pvl-bike2school-dev" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "pvl-bike2school-dev-web"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "pvl-bike2school-dev"
10
14
  */
11
- export default (vorpal: Vorpal) =>
15
+ export default async (vorpal: Vorpal) =>
12
16
  vorpal
13
17
  .command(
14
- "project-migrate-helm3 <env>",
18
+ "project-migrate-helm3 <envComponent>",
15
19
  "Do manual step for helm2 to helm3 migration"
16
20
  )
17
21
  .autocomplete(
18
- envAutocompletion.filter((e) => e !== "dev-local" && e !== "review")
22
+ (await envAndComponents()).filter(
23
+ (e) => !e.startsWith("local") && !e.startsWith("review")
24
+ )
19
25
  )
20
- .action(async function ({ env }) {
26
+ .action(async function ({ envComponent }) {
21
27
  try {
28
+ const { env, componentName } = parseChoice(envComponent);
22
29
  const result = await exec("helm version --short");
23
30
  const version = result.stdout as string;
24
31
  this.log(`your helm version: ${version}`);
@@ -35,7 +42,9 @@ export default (vorpal: Vorpal) =>
35
42
  } catch (e) {
36
43
  // ignore
37
44
  }
38
- const releaseName = await getProjectHelmReleaseName(env);
45
+
46
+ const releaseName = (await getEnvironment(env, componentName)).envVars
47
+ .RELEASE_NAME; // TODO: maybe its own function would be better
39
48
  this.log(`helm release name: ${releaseName}`);
40
49
  this.log("");
41
50
  this.log("migrating now... 😼. This may take a moment");
@@ -0,0 +1,14 @@
1
+ import Vorpal from "vorpal";
2
+ import { getProjectNamespace } from "../../../../utils/projects";
3
+ import { envAndComponents } from "./utils/autocompletions";
4
+
5
+ export default async (vorpal: Vorpal) =>
6
+ vorpal
7
+ .command(
8
+ "project-namespace <envComponent>",
9
+ "show namespace of local project"
10
+ )
11
+ .autocomplete(await envAndComponents())
12
+ .action(async function ({ envComponent }) {
13
+ this.log(await getProjectNamespace(envComponent));
14
+ });
@@ -9,15 +9,18 @@ import { startPortForward } from "../../../../utils/portForward";
9
9
 
10
10
  import { getProjectNamespace } from "../../../../utils/projects";
11
11
 
12
- import { envAutocompletion } from "./utils/autocompletions";
12
+ import { envAndComponents } from "./utils/autocompletions";
13
13
  import ensureCluster from "./utils/ensureCluster";
14
- export default (vorpal: Vorpal) =>
14
+ export default async (vorpal: Vorpal) =>
15
15
  vorpal
16
- .command("project-check-costs <env>", "Shows you how much you're spending")
17
- .autocomplete(envAutocompletion)
18
- .action(async function ({ env }) {
19
- await ensureCluster.call(this);
20
- const namespace = await getProjectNamespace(env);
16
+ .command(
17
+ "project-check-costs <envComponent>",
18
+ "Shows you how much you're spending"
19
+ )
20
+ .autocomplete(await envAndComponents())
21
+ .action(async function ({ envComponent }) {
22
+ await ensureCluster.call(this, envComponent);
23
+ const namespace = await getProjectNamespace(envComponent);
21
24
  const url = `http://localhost:${GRAFANA_PROXY_LOCAL_PORT}/namespace.html?name=${namespace}`;
22
25
  await startPortForward(
23
26
  "deployment/kubecost-cost-analyzer",
@@ -0,0 +1,48 @@
1
+ import Vorpal from "vorpal";
2
+ import {
3
+ getPipelineContextByChoice,
4
+ parseChoice,
5
+ } from "../../../../config/getProjectConfig";
6
+ import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
7
+ import { openGoogleCloudKubernetesDashboard } from "../shared";
8
+ import { envAndComponents } from "./utils/autocompletions";
9
+ export default async (vorpal: Vorpal) =>
10
+ vorpal
11
+ .command(
12
+ "project-open-dashboard <envComponent>",
13
+ "open kubernetes dashboard on google"
14
+ )
15
+ .autocomplete(await envAndComponents())
16
+ .action(async function ({ envComponent }) {
17
+ 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
+ );
30
+ }
31
+
32
+ if (
33
+ !componentConfig.deploy.cluster ||
34
+ componentConfig.deploy.cluster.type !== "gcloud"
35
+ ) {
36
+ throw new Error("no gcloud custer configured");
37
+ }
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
+ });
@@ -0,0 +1,22 @@
1
+ import open from "open";
2
+ import Vorpal from "vorpal";
3
+ import {
4
+ getEnvironment,
5
+ parseChoice,
6
+ } from "../../../../config/getProjectConfig";
7
+
8
+ import { envAndComponents } from "./utils/autocompletions";
9
+ import ensureCluster from "./utils/ensureCluster";
10
+
11
+ export default async (vorpal: Vorpal) =>
12
+ vorpal
13
+ .command("project-open-env <envComponent>", "open the live environment")
14
+ .autocomplete(await envAndComponents())
15
+ .action(async function ({ envComponent }) {
16
+ const { env, componentName } = parseChoice(envComponent);
17
+ await ensureCluster.call(this, envComponent);
18
+ const environment = await getEnvironment(env, componentName);
19
+ const url = environment.url;
20
+
21
+ open(url);
22
+ });
@@ -1,12 +1,12 @@
1
- import { exec } from "child-process-promise";
2
1
  import Vorpal from "vorpal";
2
+ import { $ } from "zx";
3
3
 
4
- export default (vorpal: Vorpal) =>
4
+ export default async (vorpal: Vorpal) =>
5
5
  vorpal
6
6
  .command(
7
7
  "project-open-git",
8
8
  "open the repo on gitlab / github in your browser"
9
9
  )
10
10
  .action(async () => {
11
- await exec("npx git-open");
11
+ await $`npx git-open`;
12
12
  });
@@ -8,18 +8,18 @@ import {
8
8
 
9
9
  import { getProjectNamespace } from "../../../../utils/projects";
10
10
 
11
- import { envAutocompletion } from "./utils/autocompletions";
11
+ import { envAndComponents } from "./utils/autocompletions";
12
12
  import ensureCluster from "./utils/ensureCluster";
13
- export default (vorpal: Vorpal) =>
13
+ export default async (vorpal: Vorpal) =>
14
14
  vorpal
15
15
  .command(
16
- "project-open-grafana <env>",
16
+ "project-open-grafana <envComponent>",
17
17
  "open Grafana dashboard for your namespace"
18
18
  )
19
- .autocomplete(envAutocompletion)
20
- .action(async function ({ env }) {
21
- await ensureCluster.call(this);
22
- const namespace = await getProjectNamespace(env);
19
+ .autocomplete(await envAndComponents())
20
+ .action(async function ({ envComponent }) {
21
+ await ensureCluster.call(this, envComponent);
22
+ const namespace = await getProjectNamespace(envComponent);
23
23
  const url = `http://localhost:${GRAFANA_PROXY_LOCAL_PORT}/grafana/d/at-cost-analysis-namespace2/namespace-utilization-metrics?var-namespace=${namespace}`;
24
24
  await startPortForward(
25
25
  "deployment/kubecost-cost-analyzer",
@@ -6,24 +6,23 @@ import {
6
6
  } from "../../../../config/constants";
7
7
  import { logError } from "../../../../utils/log";
8
8
  import { startPortForward } from "../../../../utils/portForward";
9
-
10
9
  import {
11
10
  getProjectNamespace,
12
11
  getProjectPodNames,
13
12
  } from "../../../../utils/projects";
14
-
15
- import { envAutocompletion } from "./utils/autocompletions";
13
+ import { envAndComponents } from "./utils/autocompletions";
16
14
  import ensureCluster from "./utils/ensureCluster";
17
- export default (vorpal: Vorpal) =>
15
+
16
+ export default async (vorpal: Vorpal) =>
18
17
  vorpal
19
18
  .command(
20
- "project-open-grafana-pod <env>",
19
+ "project-open-grafana-pod <envComponent>",
21
20
  "open Grafana dashboard for a specific pod"
22
21
  )
23
- .autocomplete(envAutocompletion)
24
- .action(async function ({ env }) {
25
- await ensureCluster.call(this);
26
- const podNames = await getProjectPodNames(env);
22
+ .autocomplete(await envAndComponents())
23
+ .action(async function ({ envComponent }) {
24
+ await ensureCluster.call(this, envComponent);
25
+ const podNames = await getProjectPodNames(envComponent);
27
26
  if (podNames.length === 0) {
28
27
  logError(this, "sorry, no pods found");
29
28
  return;
@@ -34,7 +33,7 @@ export default (vorpal: Vorpal) =>
34
33
  choices: podNames,
35
34
  message: "Which pod? 🤔",
36
35
  });
37
- const namespace = await getProjectNamespace(env);
36
+ const namespace = await getProjectNamespace(envComponent);
38
37
  const url = `http://localhost:${GRAFANA_PROXY_LOCAL_PORT}/grafana/d/at-cost-analysis-pod/pod-cost-and-utilization-metrics?var-namespace=${namespace}&var-pod=${podName}`;
39
38
  await startPortForward(
40
39
  "deployment/kubecost-cost-analyzer",
@@ -0,0 +1,52 @@
1
+ import Vorpal from "vorpal";
2
+ import {
3
+ getPipelineContextByChoice,
4
+ parseChoice,
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";
10
+ import { envAndComponents } from "./utils/autocompletions";
11
+ import ensureCluster from "./utils/ensureCluster";
12
+
13
+ export default async (vorpal: Vorpal) =>
14
+ vorpal
15
+ .command(
16
+ "project-open-logs <envComponent>",
17
+ "open google cloud logs (stackdriver logs)"
18
+ )
19
+ .autocomplete(await envAndComponents())
20
+ .action(async function ({ envComponent }) {
21
+ const { env, componentName } = parseChoice(envComponent);
22
+ const { componentConfig, environment } = await getPipelineContextByChoice(
23
+ env,
24
+ componentName
25
+ );
26
+
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
+ );
52
+ });
@@ -1,15 +1,17 @@
1
1
  import Vorpal from "vorpal";
2
2
  import { exec } from "child-process-promise";
3
- import { Env } from "../../../../types/types";
4
3
  import { getProjectNamespace } from "../../../../utils/projects";
5
- import { envAutocompletion } from "./utils/autocompletions";
4
+ import { envAndComponents } from "./utils/autocompletions";
6
5
 
7
- export default (vorpal: Vorpal) =>
6
+ export default async (vorpal: Vorpal) =>
8
7
  vorpal
9
- .command("project-pause <env>", "halts all running pods (scales to 0)")
10
- .autocomplete(envAutocompletion)
11
- .action(async function ({ env }) {
12
- const namespace = await getProjectNamespace(env as Env);
8
+ .command(
9
+ "project-pause <envComponent>",
10
+ "halts all running pods (scales to 0)"
11
+ )
12
+ .autocomplete(await envAndComponents())
13
+ .action(async function ({ envComponent }) {
14
+ const namespace = await getProjectNamespace(envComponent);
13
15
  const { shouldContinue } = await this.prompt({
14
16
  type: "confirm",
15
17
  name: "shouldContinue",