@catladder/cli 0.0.0-test3 → 0.0.0-yarnrc-support-bdbef31f

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 (292) hide show
  1. package/.nvmrc +1 -1
  2. package/README.md +4 -2
  3. package/bin/catenv +3 -0
  4. package/bin/catladder +1 -1
  5. package/dist/apps/catenv/catenv.d.ts +2 -0
  6. package/dist/apps/catenv/catenv.js +135 -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 +208 -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 +98 -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 +129 -0
  37. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -0
  38. package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +3 -0
  39. package/dist/apps/cli/commands/project/commandConfigSecrets.js +294 -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 +119 -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/commandInitGitlab.d.ts +3 -0
  63. package/dist/apps/cli/commands/project/commandInitGitlab.js +136 -0
  64. package/dist/apps/cli/commands/project/commandInitGitlab.js.map +1 -0
  65. package/dist/apps/cli/commands/project/commandInitProject.d.ts +3 -0
  66. package/dist/apps/cli/commands/project/commandInitProject.js +345 -0
  67. package/dist/apps/cli/commands/project/commandInitProject.js.map +1 -0
  68. package/dist/apps/cli/commands/project/commandListPods.d.ts +3 -0
  69. package/dist/apps/cli/commands/project/commandListPods.js +78 -0
  70. package/dist/apps/cli/commands/project/commandListPods.js.map +1 -0
  71. package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +7 -0
  72. package/dist/apps/cli/commands/project/commandMigrateHelm3.js +113 -0
  73. package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -0
  74. package/dist/apps/cli/commands/project/commandNamespace.d.ts +3 -0
  75. package/dist/apps/cli/commands/project/commandNamespace.js +70 -0
  76. package/dist/apps/cli/commands/project/commandNamespace.js.map +1 -0
  77. package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +3 -0
  78. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +83 -0
  79. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -0
  80. package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +3 -0
  81. package/dist/apps/cli/commands/project/commandOpenDashboard.js +85 -0
  82. package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -0
  83. package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +3 -0
  84. package/dist/apps/cli/commands/project/commandOpenEnv.js +80 -0
  85. package/dist/apps/cli/commands/project/commandOpenEnv.js.map +1 -0
  86. package/dist/apps/cli/commands/project/commandOpenGit.d.ts +3 -0
  87. package/dist/apps/cli/commands/project/commandOpenGit.js +61 -0
  88. package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -0
  89. package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +3 -0
  90. package/dist/apps/cli/commands/project/commandOpenGrafana.js +83 -0
  91. package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -0
  92. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +3 -0
  93. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +99 -0
  94. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -0
  95. package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +3 -0
  96. package/dist/apps/cli/commands/project/commandOpenLogs.js +87 -0
  97. package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -0
  98. package/dist/apps/cli/commands/project/commandPauseProject.d.ts +3 -0
  99. package/dist/apps/cli/commands/project/commandPauseProject.js +97 -0
  100. package/dist/apps/cli/commands/project/commandPauseProject.js.map +1 -0
  101. package/dist/apps/cli/commands/project/commandPortForward.d.ts +3 -0
  102. package/dist/apps/cli/commands/project/commandPortForward.js +106 -0
  103. package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -0
  104. package/dist/apps/cli/commands/project/commandReloadConfig.d.ts +3 -0
  105. package/dist/apps/cli/commands/project/commandReloadConfig.js +62 -0
  106. package/dist/apps/cli/commands/project/commandReloadConfig.js.map +1 -0
  107. package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +3 -0
  108. package/dist/apps/cli/commands/project/commandTriggerCronjob.js +144 -0
  109. package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -0
  110. package/dist/apps/cli/commands/project/index.d.ts +3 -0
  111. package/dist/apps/cli/commands/project/index.js +97 -0
  112. package/dist/apps/cli/commands/project/index.js.map +1 -0
  113. package/dist/apps/cli/commands/project/utils/autocompletions.d.ts +3 -0
  114. package/dist/apps/cli/commands/project/utils/autocompletions.js +96 -0
  115. package/dist/apps/cli/commands/project/utils/autocompletions.js.map +1 -0
  116. package/dist/apps/cli/commands/project/utils/ensureCluster.d.ts +1 -0
  117. package/dist/apps/cli/commands/project/utils/ensureCluster.js +84 -0
  118. package/dist/apps/cli/commands/project/utils/ensureCluster.js.map +1 -0
  119. package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +2 -0
  120. package/dist/apps/cli/commands/project/utils/ensureNamespace.js +106 -0
  121. package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -0
  122. package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +2 -0
  123. package/dist/apps/cli/commands/project/utils/showProjectBanner.js +58 -0
  124. package/dist/apps/cli/commands/project/utils/showProjectBanner.js.map +1 -0
  125. package/dist/apps/cli/commands/shared/index.d.ts +3 -0
  126. package/dist/apps/cli/commands/shared/index.js +70 -0
  127. package/dist/apps/cli/commands/shared/index.js.map +1 -0
  128. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +3 -0
  129. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +101 -0
  130. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -0
  131. package/dist/apps/cli/config/writeConfig.d.ts +5 -0
  132. package/dist/apps/cli/config/writeConfig.js +106 -0
  133. package/dist/apps/cli/config/writeConfig.js.map +1 -0
  134. package/dist/apps/cli/utils/getGoogleAuthUserNumber.d.ts +1 -0
  135. package/dist/apps/cli/utils/getGoogleAuthUserNumber.js +69 -0
  136. package/dist/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -0
  137. package/dist/apps/cli/verify/index.d.ts +2 -0
  138. package/dist/apps/cli/verify/index.js +94 -0
  139. package/dist/apps/cli/verify/index.js.map +1 -0
  140. package/dist/apps/cli/verify/migration/fromv2.d.ts +4 -0
  141. package/dist/apps/cli/verify/migration/fromv2.js +345 -0
  142. package/dist/apps/cli/verify/migration/fromv2.js.map +1 -0
  143. package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +4 -0
  144. package/dist/apps/cli/verify/migration/migrateSecrets.js +88 -0
  145. package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -0
  146. package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +18 -0
  147. package/dist/apps/cli/verify/migration/oldGitlabCi.js +30 -0
  148. package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -0
  149. package/dist/catenv.d.ts +1 -0
  150. package/dist/catenv.js +10 -0
  151. package/dist/catenv.js.map +1 -0
  152. package/dist/cli.d.ts +1 -0
  153. package/dist/cli.js +15 -0
  154. package/dist/cli.js.map +1 -0
  155. package/dist/config/constants.d.ts +3 -0
  156. package/dist/config/constants.js +7 -0
  157. package/dist/config/constants.js.map +1 -0
  158. package/dist/config/getProjectConfig.d.ts +24 -0
  159. package/dist/config/getProjectConfig.js +232 -0
  160. package/dist/config/getProjectConfig.js.map +1 -0
  161. package/dist/k8sApi/index.d.ts +6 -0
  162. package/dist/k8sApi/index.js +15 -0
  163. package/dist/k8sApi/index.js.map +1 -0
  164. package/dist/packageInfos.d.ts +2 -0
  165. package/dist/packageInfos.js +6 -0
  166. package/dist/packageInfos.js.map +1 -0
  167. package/dist/tsconfig.tsbuildinfo +1 -0
  168. package/dist/types/types.d.ts +18 -0
  169. package/dist/types/types.js +3 -0
  170. package/dist/types/types.js.map +1 -0
  171. package/dist/utils/cluster.d.ts +3 -0
  172. package/dist/utils/cluster.js +75 -0
  173. package/dist/utils/cluster.js.map +1 -0
  174. package/dist/utils/editAsFile.d.ts +1 -0
  175. package/dist/utils/editAsFile.js +85 -0
  176. package/dist/utils/editAsFile.js.map +1 -0
  177. package/dist/utils/files.d.ts +2 -0
  178. package/dist/utils/files.js +83 -0
  179. package/dist/utils/files.js.map +1 -0
  180. package/dist/utils/formatEnvVars.d.ts +2 -0
  181. package/dist/utils/formatEnvVars.js +10 -0
  182. package/dist/utils/formatEnvVars.js.map +1 -0
  183. package/dist/utils/getEditor.d.ts +4 -0
  184. package/dist/utils/getEditor.js +70 -0
  185. package/dist/utils/getEditor.js.map +1 -0
  186. package/dist/utils/gitlab.d.ts +21 -0
  187. package/dist/utils/gitlab.js +262 -0
  188. package/dist/utils/gitlab.js.map +1 -0
  189. package/dist/utils/log.d.ts +1 -0
  190. package/dist/utils/log.js +14 -0
  191. package/dist/utils/log.js.map +1 -0
  192. package/dist/utils/passwordstore/index.d.ts +8 -0
  193. package/dist/utils/passwordstore/index.js +378 -0
  194. package/dist/utils/passwordstore/index.js.map +1 -0
  195. package/dist/utils/portForward.d.ts +4 -0
  196. package/dist/utils/portForward.js +116 -0
  197. package/dist/utils/portForward.js.map +1 -0
  198. package/dist/utils/preferences/index.d.ts +3 -0
  199. package/dist/utils/preferences/index.js +119 -0
  200. package/dist/utils/preferences/index.js.map +1 -0
  201. package/dist/utils/projects/index.d.ts +8 -0
  202. package/dist/utils/projects/index.js +154 -0
  203. package/dist/utils/projects/index.js.map +1 -0
  204. package/dist/utils/promise.d.ts +2 -0
  205. package/dist/utils/promise.js +62 -0
  206. package/dist/utils/promise.js.map +1 -0
  207. package/dist/utils/shell.d.ts +1 -0
  208. package/dist/utils/shell.js +81 -0
  209. package/dist/utils/shell.js.map +1 -0
  210. package/package.json +16 -21
  211. package/src/apps/catenv/catenv.ts +48 -27
  212. package/src/apps/{shell/shell.ts → cli/cli.ts} +10 -2
  213. package/src/apps/{shell → cli}/commands/general/index.ts +2 -40
  214. package/src/apps/{shell → cli}/commands/general/namespaceAutoCompletion.ts +0 -0
  215. package/src/apps/{shell → cli}/commands/general/portForward.ts +1 -1
  216. package/src/apps/{shell → cli}/commands/mongodb/index.ts +1 -1
  217. package/src/apps/{shell → cli}/commands/mongodb/projectMongoDestroyMember.ts +18 -18
  218. package/src/apps/{shell → cli}/commands/mongodb/projectMongoGetShell.ts +12 -10
  219. package/src/apps/{shell → cli}/commands/mongodb/projectMongoPortForward.ts +13 -8
  220. package/src/apps/{shell → cli}/commands/mongodb/utils/index.ts +9 -8
  221. package/src/apps/{shell → cli}/commands/project/commandCloudSqlProxy.ts +26 -21
  222. package/src/apps/cli/commands/project/commandConfigSecrets.ts +205 -0
  223. package/src/apps/{shell → cli}/commands/project/commandCopyDB.ts +24 -26
  224. package/src/apps/{shell → cli}/commands/project/commandDeletePods.ts +8 -9
  225. package/src/apps/{shell → cli}/commands/project/commandDeleteProject.ts +7 -8
  226. package/src/apps/cli/commands/project/commandEnvVars.ts +15 -0
  227. package/src/apps/{shell → cli}/commands/project/commandGetMyTotalWorktime.ts +2 -2
  228. package/src/apps/{shell → cli}/commands/project/commandGetShell.ts +10 -10
  229. package/src/apps/{shell → cli}/commands/project/commandGitlabCi.ts +1 -1
  230. package/src/apps/cli/commands/project/commandInitGitlab.ts +248 -0
  231. package/src/apps/{shell → cli}/commands/project/commandInitProject.ts +14 -6
  232. package/src/apps/cli/commands/project/commandListPods.ts +18 -0
  233. package/src/apps/{shell → cli}/commands/project/commandMigrateHelm3.ts +16 -7
  234. package/src/apps/cli/commands/project/commandNamespace.ts +14 -0
  235. package/src/apps/{shell → cli}/commands/project/commandOpenCostDashboard.ts +10 -7
  236. package/src/apps/cli/commands/project/commandOpenDashboard.ts +48 -0
  237. package/src/apps/cli/commands/project/commandOpenEnv.ts +22 -0
  238. package/src/apps/{shell → cli}/commands/project/commandOpenGit.ts +3 -3
  239. package/src/apps/{shell → cli}/commands/project/commandOpenGrafana.ts +7 -7
  240. package/src/apps/{shell → cli}/commands/project/commandOpenGrafanaPod.ts +9 -10
  241. package/src/apps/cli/commands/project/commandOpenLogs.ts +52 -0
  242. package/src/apps/{shell → cli}/commands/project/commandPauseProject.ts +9 -7
  243. package/src/apps/{shell → cli}/commands/project/commandPortForward.ts +8 -8
  244. package/src/apps/cli/commands/project/commandReloadConfig.ts +12 -0
  245. package/src/apps/{shell → cli}/commands/project/commandTriggerCronjob.ts +7 -7
  246. package/src/apps/{shell → cli}/commands/project/index.ts +4 -3
  247. package/src/apps/cli/commands/project/utils/autocompletions.ts +26 -0
  248. package/src/apps/cli/commands/project/utils/ensureCluster.ts +42 -0
  249. package/src/apps/cli/commands/project/utils/ensureNamespace.ts +55 -0
  250. package/src/apps/cli/commands/project/utils/showProjectBanner.ts +11 -0
  251. package/src/apps/cli/commands/shared/index.ts +36 -0
  252. package/src/apps/{shell → cli}/commands/theStuffThatReallyMatters/index.ts +7 -26
  253. package/src/apps/cli/config/writeConfig.ts +71 -0
  254. package/src/apps/{shell → cli}/utils/getGoogleAuthUserNumber.ts +0 -0
  255. package/src/apps/cli/verify/index.ts +30 -0
  256. package/src/apps/cli/verify/migration/fromv2.ts +262 -0
  257. package/src/apps/cli/verify/migration/migrateSecrets.ts +37 -0
  258. package/src/apps/cli/verify/migration/oldGitlabCi.ts +48 -0
  259. package/src/catenv.ts +4 -0
  260. package/src/cli.ts +9 -0
  261. package/src/config/constants.ts +0 -1
  262. package/src/config/getProjectConfig.ts +136 -0
  263. package/src/k8sApi/index.ts +5 -1
  264. package/src/types/types.ts +0 -2
  265. package/src/utils/cluster.ts +8 -15
  266. package/src/utils/editAsFile.ts +31 -0
  267. package/src/utils/files.ts +6 -2
  268. package/src/utils/gitlab.ts +133 -34
  269. package/src/utils/passwordstore/index.ts +19 -21
  270. package/src/utils/preferences/index.ts +6 -3
  271. package/src/utils/projects/index.ts +15 -136
  272. package/tsconfig.json +3 -7
  273. package/bin/catenv.sh +0 -1
  274. package/src/apps/shell/commands/project/commandConfigSecrets.ts +0 -245
  275. package/src/apps/shell/commands/project/commandEnvVars.ts +0 -17
  276. package/src/apps/shell/commands/project/commandInitGitlab.ts +0 -157
  277. package/src/apps/shell/commands/project/commandListPods.ts +0 -21
  278. package/src/apps/shell/commands/project/commandNamespace.ts +0 -12
  279. package/src/apps/shell/commands/project/commandOpenDashboard.ts +0 -27
  280. package/src/apps/shell/commands/project/commandOpenEnv.ts +0 -18
  281. package/src/apps/shell/commands/project/commandOpenLogs.ts +0 -23
  282. package/src/apps/shell/commands/project/commandVariables.ts +0 -13
  283. package/src/apps/shell/commands/project/utils/autocompletions.ts +0 -7
  284. package/src/apps/shell/commands/project/utils/ensureCluster.ts +0 -31
  285. package/src/apps/shell/commands/project/utils/ensureNamespace.ts +0 -32
  286. package/src/apps/shell/commands/project/utils/monorepo.ts +0 -45
  287. package/src/apps/shell/commands/shared/index.ts +0 -31
  288. package/src/config/clusters.ts +0 -45
  289. package/src/index.ts +0 -17
  290. package/src/types/git-repo-name.d.ts +0 -1
  291. package/src/types/yawn-yaml.d.ts +0 -1
  292. package/src/utils/dashboardToken.ts +0 -20
@@ -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",
@@ -5,17 +5,17 @@ import {
5
5
  getProjectNamespace,
6
6
  getProjectPodNames,
7
7
  } from "../../../../utils/projects";
8
- import { envAutocompletion } from "./utils/autocompletions";
8
+ import { envAndComponents } from "./utils/autocompletions";
9
9
  import ensureCluster from "./utils/ensureCluster";
10
10
 
11
- export default (vorpal: Vorpal) =>
11
+ export default async (vorpal: Vorpal) =>
12
12
  vorpal
13
- .command("project-port-forward <env>", "start port-forwarding")
14
- .autocomplete(envAutocompletion)
15
- .action(async function ({ env }) {
16
- await ensureCluster.call(this);
17
- const namespace = await getProjectNamespace(env);
18
- const podNames = await getProjectPodNames(env);
13
+ .command("project-port-forward <envComponent>", "start port-forwarding")
14
+ .autocomplete(await envAndComponents())
15
+ .action(async function ({ envComponent }) {
16
+ await ensureCluster.call(this, envComponent);
17
+ const namespace = await getProjectNamespace(envComponent);
18
+ const podNames = await getProjectPodNames(envComponent);
19
19
  if (podNames.length === 0) {
20
20
  logError(this, "sorry, no pods found");
21
21
  return;
@@ -0,0 +1,12 @@
1
+ import Vorpal from "vorpal";
2
+ import { reloadConfig } from "../../../../config/getProjectConfig";
3
+ import { showProjectBanner } from "./utils/showProjectBanner";
4
+
5
+ export default async (vorpal: Vorpal) =>
6
+ vorpal
7
+ .command("project-reload-config", "reloads the config")
8
+
9
+ .action(async function () {
10
+ await reloadConfig();
11
+ await showProjectBanner(vorpal);
12
+ });
@@ -6,7 +6,7 @@ import { logError } from "../../../../utils/log";
6
6
  import { namespaceAutoCompletion } from "../general/namespaceAutoCompletion";
7
7
 
8
8
  import { getProjectNamespace } from "../../../../utils/projects";
9
- import { envAutocompletion } from "./utils/autocompletions";
9
+ import { envAndComponents } from "./utils/autocompletions";
10
10
  import ensureCluster from "./utils/ensureCluster";
11
11
 
12
12
  async function triggerCronjob(namespace: string) {
@@ -43,7 +43,7 @@ async function triggerCronjob(namespace: string) {
43
43
  logError(this, "command failed", e.body);
44
44
  }
45
45
  }
46
- export default (vorpal: Vorpal) => {
46
+ export default async (vorpal: Vorpal) => {
47
47
  vorpal
48
48
  .command("trigger-cronjob <namespace>", "trigger cronjob")
49
49
  .autocomplete(namespaceAutoCompletion)
@@ -51,11 +51,11 @@ export default (vorpal: Vorpal) => {
51
51
  await triggerCronjob.call(this, namespace);
52
52
  });
53
53
  vorpal
54
- .command("project-trigger-cronjob <env>", "trigger cronjob")
55
- .autocomplete(envAutocompletion)
56
- .action(async function ({ env }) {
57
- await ensureCluster.call(this);
58
- const namespace = await getProjectNamespace(env);
54
+ .command("project-trigger-cronjob <envComponent>", "trigger cronjob")
55
+ .autocomplete(await envAndComponents())
56
+ .action(async function ({ envComponent }) {
57
+ await ensureCluster.call(this, envComponent);
58
+ const namespace = await getProjectNamespace(envComponent);
59
59
  await triggerCronjob.call(this, namespace);
60
60
  });
61
61
  };
@@ -22,15 +22,16 @@ import commandPauseProject from "./commandPauseProject";
22
22
  import commandOpenGrafana from "./commandOpenGrafana";
23
23
  import commandPortForward from "./commandPortForward";
24
24
  import commandTriggerCronjob from "./commandTriggerCronjob";
25
- import commandVariables from "./commandVariables";
25
+
26
26
  import commandOpenGrafanaPod from "./commandOpenGrafanaPod";
27
+ import commandReloadConfig from "./commandReloadConfig";
27
28
 
28
- export default (vorpal: Vorpal) => {
29
+ export default async (vorpal: Vorpal) => {
30
+ commandReloadConfig(vorpal);
29
31
  commandInitProject(vorpal);
30
32
  commandInitGitlab(vorpal);
31
33
  commandEnvVars(vorpal);
32
34
 
33
- commandVariables(vorpal);
34
35
  commandNamespace(vorpal);
35
36
  commandListPods(vorpal);
36
37
  commandPauseProject(vorpal);
@@ -0,0 +1,26 @@
1
+ import { getAllEnvs, getAllEnvsInAllComponents } from "@catladder/pipeline";
2
+ import {
3
+ getAllComponentsWithAllEnvsFlat,
4
+ getProjectConfig,
5
+ } from "../../../../../config/getProjectConfig";
6
+
7
+ export const allEnvs = async () => {
8
+ const config = await getProjectConfig();
9
+ if (!config) {
10
+ return [];
11
+ }
12
+ return getAllEnvsInAllComponents(config);
13
+ };
14
+
15
+ export const envAndComponents = async () => {
16
+ const allEnvAndcomponents = await getAllComponentsWithAllEnvsFlat();
17
+
18
+ return allEnvAndcomponents.reduce<string[]>(
19
+ (acc, { env, componentName }) => [...acc, env + ":" + componentName],
20
+ []
21
+ );
22
+ };
23
+
24
+ export const allEnvsAndAllComponents = async () => {
25
+ return [...(await allEnvs()), ...(await envAndComponents())];
26
+ };
@@ -0,0 +1,42 @@
1
+ import {
2
+ isOfDeployType,
3
+ getFullKubernetesClusterName,
4
+ } from "@catladder/pipeline";
5
+ import {
6
+ getPipelineContextByChoice,
7
+ parseChoice,
8
+ } from "../../../../../config/getProjectConfig";
9
+ import {
10
+ connectToCluster,
11
+ getCurrentConnectedClusterName,
12
+ } from "../../../../../utils/cluster";
13
+ export default async function (envComponent: string) {
14
+ const { env, componentName } = parseChoice(envComponent);
15
+ const context = await getPipelineContextByChoice(env, componentName);
16
+ if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
17
+ throw new Error("can't ensure cluster for non-kubernetes deployments");
18
+ }
19
+ const cluster = getFullKubernetesClusterName(
20
+ context.componentConfig.deploy.cluster
21
+ );
22
+ const connectedClusterName = await getCurrentConnectedClusterName();
23
+
24
+ if (cluster !== connectedClusterName) {
25
+ this.log(
26
+ `you are currently connected to cluster '${connectedClusterName}'`
27
+ );
28
+ this.log(`but the project requires cluster '${cluster}'`);
29
+ const { shouldContinue } = await this.prompt({
30
+ type: "confirm",
31
+ name: "shouldContinue",
32
+ default: true,
33
+ message: `Do you want to connect to '${cluster}'?`,
34
+ });
35
+ if (!shouldContinue) {
36
+ this.log("abort");
37
+ } else {
38
+ await connectToCluster(cluster);
39
+ this.log(`connected to cluster '${cluster}'`);
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,55 @@
1
+ import { Context, getKubernetesNamespace } from "@catladder/pipeline";
2
+ import { V1Namespace, V1ObjectMeta } from "@kubernetes/client-node";
3
+ import k8sApi from "../../../../../k8sApi";
4
+
5
+ export default async function (context: Context) {
6
+ const namespace = getKubernetesNamespace(
7
+ context.fullConfig,
8
+ context.environment.shortName
9
+ );
10
+ const namespaceBody = new V1Namespace();
11
+ const metadata: V1ObjectMeta = {
12
+ name: namespace,
13
+ labels: {
14
+ customerName: context.fullConfig.customerName,
15
+ appName: context.fullConfig.appName,
16
+ environment: context.environment.shortName,
17
+ components: Object.keys(context.fullConfig.components).join("_"), // limited chars available...
18
+ buildTypes: Object.values(context.fullConfig.components)
19
+ .map((config) => config.build.type)
20
+ .join("_"), // limited chars available...
21
+ ...Object.fromEntries(
22
+ Object.entries(context.fullConfig.components).map(
23
+ ([componentName, config]) => [
24
+ "buildType_" + componentName,
25
+ config.build.type,
26
+ ]
27
+ )
28
+ ),
29
+ ...(context.fullConfig.meta?.labels ?? {}),
30
+ },
31
+ };
32
+
33
+ namespaceBody.metadata = metadata;
34
+ try {
35
+ await k8sApi.readNamespace(namespace);
36
+
37
+ await k8sApi.patchNamespace(
38
+ namespace,
39
+ namespaceBody,
40
+ undefined,
41
+ undefined,
42
+ undefined,
43
+ undefined,
44
+ { headers: { "content-type": "application/merge-patch+json" } } // see https://github.com/kubernetes-client/javascript/issues/443
45
+ ); // update meta data
46
+ } catch (e) {
47
+ if (e.response?.body?.reason === "NotFound") {
48
+ await k8sApi.createNamespace(namespaceBody);
49
+ } else {
50
+ console.error(e.response?.body);
51
+ throw e;
52
+ }
53
+ }
54
+ return namespace;
55
+ }
@@ -0,0 +1,11 @@
1
+ import Vorpal from "vorpal";
2
+ import { getProjectConfig } from "../../../../../config/getProjectConfig";
3
+
4
+ export const showProjectBanner = async (vorpal: Vorpal) => {
5
+ const projectConfig = await getProjectConfig();
6
+ if (projectConfig) {
7
+ vorpal.log("project: " + projectConfig.appName);
8
+ vorpal.log("customer: " + projectConfig.customerName);
9
+ vorpal.log("");
10
+ }
11
+ };
@@ -0,0 +1,36 @@
1
+ import { DeployConfigKubernetesCluster } from "@catladder/pipeline";
2
+ import open from "open";
3
+
4
+ export const openGoogleCloudLogs = async (
5
+ cluster?: DeployConfigKubernetesCluster,
6
+ namespace?: string,
7
+ googleAuthUserNumber = 0
8
+ ) => {
9
+ const resource = `k8s_container/cluster_name/${cluster.name}${
10
+ namespace ? `/namespace_name/${namespace}` : ""
11
+ }`;
12
+
13
+ const url = `https://console.cloud.google.com/logs/viewer?project=${
14
+ cluster.projectId
15
+ }${
16
+ resource ? `&resource=${encodeURIComponent(resource)}` : ""
17
+ }&authuser=${googleAuthUserNumber}`;
18
+ open(url);
19
+ };
20
+
21
+ export const openGoogleCloudKubernetesDashboard = async (
22
+ cluster: DeployConfigKubernetesCluster,
23
+ namespace: string,
24
+ googleAuthUserNumber = 0
25
+ ) => {
26
+ //gke_skynet-164509_europe-west1-d_production
27
+ // ?authuser=1&project=skynet-swiss&pageState=pageState%3D(%22savedViews%22:(%22c%22:%5B%22gke%2Feurope-west6-a%2Fch-production%22%5D,%22n%22:%5B%22pvl-bike2school-review%22%5D,%22i%22:%224e42e0b9cd6147f8a4fba7516752ec48%22))
28
+ // ?authuser=1&project=skynet-swiss&pageState=(%22savedViews%22:(%22i%22:%2279802e2b154d46d480dff4e086e87875%22,%22c%22:%5B%22gke%2Feurope-west6-a%2Fch-production%22%5D,%22n%22:%5B%22pvl-bike2school-review%22%5D))
29
+
30
+ const pageState = `("savedViews":("c":["gke/${cluster.region}/${cluster.name}"],"n":["${namespace}"],"i":"4e42e0b9cd6147f8a4fba7516752ec48"))`;
31
+ const url = `https://console.cloud.google.com/kubernetes/workload?authuser=${googleAuthUserNumber}&project=${
32
+ cluster.projectId
33
+ }&pageState=${encodeURIComponent(pageState)}`;
34
+
35
+ open(url);
36
+ };
@@ -2,50 +2,31 @@ import { spawn } from "child-process-promise";
2
2
  import fetch from "node-fetch";
3
3
  import Vorpal from "vorpal";
4
4
 
5
- export default (vorpal: Vorpal) => {
6
- vorpal.command("dadjoke", "something for jonas.").action(async function() {
5
+ export default async (vorpal: Vorpal) => {
6
+ vorpal.command("dadjoke", "something for jonas.").action(async function () {
7
7
  const result = await fetch("https://icanhazdadjoke.com/", {
8
8
  headers: {
9
- Accept: "text/plain"
10
- }
9
+ Accept: "text/plain",
10
+ },
11
11
  });
12
12
  const text = await result.text();
13
13
  this.log("");
14
14
  this.log(text);
15
15
  this.log("");
16
16
  });
17
- vorpal.command("pantobot", "the allknowing oracle").action(async function() {
18
- const { message } = await this.prompt({
19
- type: "string",
20
- name: "message",
21
17
 
22
- message: "Your question, unworthy?: "
23
- });
24
- const result = await fetch(
25
- `https://paas.panter.cloud/api/pantobot/${message}`,
26
- {
27
- headers: {
28
- Accept: "text/plain"
29
- }
30
- }
31
- );
32
- const text = await result.text();
33
- this.log("");
34
- this.log(text);
35
- this.log("");
36
- });
37
18
  let starwarsPromise: any;
38
19
  vorpal
39
20
  .command("starwars", "Long time ago... in a galaxy far far away...")
40
- .action(async function() {
21
+ .action(async function () {
41
22
  starwarsPromise = spawn("telnet", ["towel.blinkenlights.nl"], {
42
- stdio: ["pipe", "inherit", "pipe"]
23
+ stdio: ["pipe", "inherit", "pipe"],
43
24
  });
44
25
  await starwarsPromise;
45
26
  })
46
27
  // we need to close it properly, because telnet towel.blinkenlights.nl has no way to cancel and stop itself
47
28
  // this is also why we need to only inherit the stdout and not the stdin
48
- .cancel(async function() {
29
+ .cancel(async function () {
49
30
  starwarsPromise.childProcess.kill();
50
31
  });
51
32
  };
@@ -0,0 +1,71 @@
1
+ import { Config } from "@catladder/pipeline";
2
+ import { spawn, exec } from "child-process-promise";
3
+ import { writeFile } from "fs-extra";
4
+ import { dump } from "js-yaml";
5
+ import { format } from "prettier";
6
+ import { CommandInstance } from "vorpal";
7
+ import { getGitRoot } from "../../../utils/projects";
8
+
9
+ export const writeConfig = async (
10
+ vorpal: CommandInstance,
11
+ config: Config,
12
+ options?: {
13
+ endComment?: string;
14
+ }
15
+ ) => {
16
+ const gitRoot = await getGitRoot();
17
+ const TS = "typescript (recommended)";
18
+ const { configType } = await vorpal.prompt({
19
+ type: "list",
20
+ name: "configType",
21
+ choices: [TS, "yaml"],
22
+ message: "In which format do you want the config? 🤔",
23
+ });
24
+ vorpal.log("");
25
+ if (configType === TS) {
26
+ const file = gitRoot + "/catladder.ts";
27
+ const content = format(
28
+ `
29
+ import type { Config } from "@catladder/pipeline";
30
+
31
+ const config: Config = ${JSON.stringify(config)};
32
+
33
+ export default config;
34
+
35
+
36
+ ${options?.endComment ? `/*${options.endComment}*/` : ""}
37
+
38
+ `,
39
+ {
40
+ parser: "babel",
41
+ }
42
+ );
43
+
44
+ await writeFile(file, content, {
45
+ encoding: "utf-8",
46
+ });
47
+ vorpal.log("adding type @catladder/pipeline....");
48
+ await spawn("yarn add --non-interactive @catladder/pipeline -DW", {
49
+ shell: true,
50
+ });
51
+ await exec("git add " + file);
52
+ } else {
53
+ const file = gitRoot + "/catladder.yml";
54
+ const content = dump(config);
55
+
56
+ await writeFile(
57
+ file,
58
+ content +
59
+ "\n\n" +
60
+ (options.endComment
61
+ ? "# " + options.endComment.split("\n").join("\n# ")
62
+ : ""),
63
+ {
64
+ encoding: "utf-8",
65
+ }
66
+ );
67
+ await exec("git add " + file);
68
+ }
69
+ vorpal.log("done!");
70
+ vorpal.log("");
71
+ };
@@ -0,0 +1,30 @@
1
+ import Vorpal from "vorpal";
2
+ import {
3
+ getGitlabCi,
4
+ getProjectConfig,
5
+ } from "../../../config/getProjectConfig";
6
+ import { hasGitlabToken, setupGitlabToken } from "../../../utils/gitlab";
7
+ import { isV2, migrateV2 } from "./migration/fromv2";
8
+
9
+ export const verify = async (vorpal: Vorpal) => {
10
+ // check if has all settings
11
+
12
+ if (!(await hasGitlabToken())) {
13
+ vorpal.command("setup-gitlab-token").action(async function () {
14
+ await setupGitlabToken(this);
15
+ });
16
+ vorpal.exec("setup-gitlab-token");
17
+ }
18
+
19
+ const projectConfig = await getProjectConfig();
20
+ try {
21
+ const gitlabCi = getGitlabCi();
22
+
23
+ if (gitlabCi && !projectConfig && (await isV2())) {
24
+ vorpal.log("no project config, needs migration");
25
+ await migrateV2(vorpal);
26
+ }
27
+ } catch (e) {
28
+ // no gitroot, ignore
29
+ }
30
+ };