@vaharoni/devops 1.0.47

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 (342) hide show
  1. package/README.md +51 -0
  2. package/dist/app-support/crypto/index.d.ts +15 -0
  3. package/dist/app-support/crypto/index.d.ts.map +1 -0
  4. package/dist/app-support/crypto/index.js +30 -0
  5. package/dist/app-support/crypto/internal-token.d.ts +20 -0
  6. package/dist/app-support/crypto/internal-token.d.ts.map +1 -0
  7. package/dist/app-support/crypto/internal-token.js +42 -0
  8. package/dist/app-support/crypto/internal-token.spec.d.ts +2 -0
  9. package/dist/app-support/crypto/internal-token.spec.d.ts.map +1 -0
  10. package/dist/app-support/crypto/internal-token.spec.js +45 -0
  11. package/dist/app-support/crypto/secret.d.ts +3 -0
  12. package/dist/app-support/crypto/secret.d.ts.map +1 -0
  13. package/dist/app-support/crypto/secret.js +12 -0
  14. package/dist/app-support/crypto/secret.spec.d.ts +2 -0
  15. package/dist/app-support/crypto/secret.spec.d.ts.map +1 -0
  16. package/dist/app-support/crypto/secret.spec.js +15 -0
  17. package/dist/app-support/discovery/dev-discovery-loader.d.ts +2 -0
  18. package/dist/app-support/discovery/dev-discovery-loader.d.ts.map +1 -0
  19. package/dist/app-support/discovery/dev-discovery-loader.js +30 -0
  20. package/dist/app-support/discovery/service-endpoint.d.ts +2 -0
  21. package/dist/app-support/discovery/service-endpoint.d.ts.map +1 -0
  22. package/dist/app-support/discovery/service-endpoint.js +10 -0
  23. package/dist/cli/affected.d.ts +11 -0
  24. package/dist/cli/affected.d.ts.map +1 -0
  25. package/dist/cli/affected.js +103 -0
  26. package/dist/cli/common.d.ts +89 -0
  27. package/dist/cli/common.d.ts.map +1 -0
  28. package/dist/cli/common.js +236 -0
  29. package/dist/cli/common.spec.d.ts +2 -0
  30. package/dist/cli/common.spec.d.ts.map +1 -0
  31. package/dist/cli/common.spec.js +64 -0
  32. package/dist/cli/console.d.ts +11 -0
  33. package/dist/cli/console.d.ts.map +1 -0
  34. package/dist/cli/console.js +35 -0
  35. package/dist/cli/constant.d.ts +11 -0
  36. package/dist/cli/constant.d.ts.map +1 -0
  37. package/dist/cli/constant.js +22 -0
  38. package/dist/cli/db.d.ts +11 -0
  39. package/dist/cli/db.d.ts.map +1 -0
  40. package/dist/cli/db.js +119 -0
  41. package/dist/cli/dml.d.ts +11 -0
  42. package/dist/cli/dml.d.ts.map +1 -0
  43. package/dist/cli/dml.js +116 -0
  44. package/dist/cli/env.d.ts +11 -0
  45. package/dist/cli/env.d.ts.map +1 -0
  46. package/dist/cli/env.js +67 -0
  47. package/dist/cli/exec.d.ts +11 -0
  48. package/dist/cli/exec.d.ts.map +1 -0
  49. package/dist/cli/exec.js +50 -0
  50. package/dist/cli/image.d.ts +11 -0
  51. package/dist/cli/image.d.ts.map +1 -0
  52. package/dist/cli/image.js +140 -0
  53. package/dist/cli/init.d.ts +11 -0
  54. package/dist/cli/init.d.ts.map +1 -0
  55. package/dist/cli/init.js +66 -0
  56. package/dist/cli/internal-curl.d.ts +11 -0
  57. package/dist/cli/internal-curl.d.ts.map +1 -0
  58. package/dist/cli/internal-curl.js +43 -0
  59. package/dist/cli/job.d.ts +11 -0
  60. package/dist/cli/job.d.ts.map +1 -0
  61. package/dist/cli/job.js +67 -0
  62. package/dist/cli/jwt.d.ts +11 -0
  63. package/dist/cli/jwt.d.ts.map +1 -0
  64. package/dist/cli/jwt.js +27 -0
  65. package/dist/cli/namespace.d.ts +11 -0
  66. package/dist/cli/namespace.d.ts.map +1 -0
  67. package/dist/cli/namespace.js +70 -0
  68. package/dist/cli/prep-build.d.ts +11 -0
  69. package/dist/cli/prep-build.d.ts.map +1 -0
  70. package/dist/cli/prep-build.js +82 -0
  71. package/dist/cli/prisma.d.ts +11 -0
  72. package/dist/cli/prisma.d.ts.map +1 -0
  73. package/dist/cli/prisma.js +25 -0
  74. package/dist/cli/redis.d.ts +11 -0
  75. package/dist/cli/redis.d.ts.map +1 -0
  76. package/dist/cli/redis.js +76 -0
  77. package/dist/cli/registry.d.ts +11 -0
  78. package/dist/cli/registry.d.ts.map +1 -0
  79. package/dist/cli/registry.js +58 -0
  80. package/dist/cli/run-many.d.ts +11 -0
  81. package/dist/cli/run-many.d.ts.map +1 -0
  82. package/dist/cli/run-many.js +50 -0
  83. package/dist/cli/run.d.ts +11 -0
  84. package/dist/cli/run.d.ts.map +1 -0
  85. package/dist/cli/run.js +37 -0
  86. package/dist/cli/template.d.ts +11 -0
  87. package/dist/cli/template.d.ts.map +1 -0
  88. package/dist/cli/template.js +123 -0
  89. package/dist/cli/test.d.ts +11 -0
  90. package/dist/cli/test.d.ts.map +1 -0
  91. package/dist/cli/test.js +28 -0
  92. package/dist/devops.d.ts +3 -0
  93. package/dist/devops.d.ts.map +1 -0
  94. package/dist/devops.js +103 -0
  95. package/dist/index.d.ts +4 -0
  96. package/dist/index.d.ts.map +1 -0
  97. package/dist/index.js +3 -0
  98. package/dist/libs/affected-entities.d.ts +15 -0
  99. package/dist/libs/affected-entities.d.ts.map +1 -0
  100. package/dist/libs/affected-entities.js +52 -0
  101. package/dist/libs/config.d.ts +6 -0
  102. package/dist/libs/config.d.ts.map +1 -0
  103. package/dist/libs/config.js +98 -0
  104. package/dist/libs/dependencies.d.ts +19 -0
  105. package/dist/libs/dependencies.d.ts.map +1 -0
  106. package/dist/libs/dependencies.js +62 -0
  107. package/dist/libs/dependencies.spec.d.ts +2 -0
  108. package/dist/libs/dependencies.spec.d.ts.map +1 -0
  109. package/dist/libs/dependencies.spec.js +21 -0
  110. package/dist/libs/digital-ocean/container-reg.d.ts +6 -0
  111. package/dist/libs/digital-ocean/container-reg.d.ts.map +1 -0
  112. package/dist/libs/digital-ocean/container-reg.js +69 -0
  113. package/dist/libs/discovery/dependencies.d.ts +19 -0
  114. package/dist/libs/discovery/dependencies.d.ts.map +1 -0
  115. package/dist/libs/discovery/dependencies.js +62 -0
  116. package/dist/libs/discovery/dependencies.spec.d.ts +2 -0
  117. package/dist/libs/discovery/dependencies.spec.d.ts.map +1 -0
  118. package/dist/libs/discovery/dependencies.spec.js +21 -0
  119. package/dist/libs/discovery/images.d.ts +5 -0
  120. package/dist/libs/discovery/images.d.ts.map +1 -0
  121. package/dist/libs/discovery/images.js +45 -0
  122. package/dist/libs/discovery/index.d.ts +5 -0
  123. package/dist/libs/discovery/index.d.ts.map +1 -0
  124. package/dist/libs/discovery/index.js +55 -0
  125. package/dist/libs/discovery/package-json-processor.d.ts +3 -0
  126. package/dist/libs/discovery/package-json-processor.d.ts.map +1 -0
  127. package/dist/libs/discovery/package-json-processor.js +34 -0
  128. package/dist/libs/discovery/process-common.d.ts +25 -0
  129. package/dist/libs/discovery/process-common.d.ts.map +1 -0
  130. package/dist/libs/discovery/process-common.js +40 -0
  131. package/dist/libs/discovery/process-package-json.d.ts +3 -0
  132. package/dist/libs/discovery/process-package-json.d.ts.map +1 -0
  133. package/dist/libs/discovery/process-package-json.js +34 -0
  134. package/dist/libs/discovery/process-pyproject-toml.d.ts +3 -0
  135. package/dist/libs/discovery/process-pyproject-toml.d.ts.map +1 -0
  136. package/dist/libs/discovery/process-pyproject-toml.js +36 -0
  137. package/dist/libs/discovery/pyproject-toml-processor.d.ts +3 -0
  138. package/dist/libs/discovery/pyproject-toml-processor.d.ts.map +1 -0
  139. package/dist/libs/discovery/pyproject-toml-processor.js +39 -0
  140. package/dist/libs/git-helpers.d.ts +8 -0
  141. package/dist/libs/git-helpers.d.ts.map +1 -0
  142. package/dist/libs/git-helpers.js +20 -0
  143. package/dist/libs/hetzner/reg-secret.d.ts +3 -0
  144. package/dist/libs/hetzner/reg-secret.d.ts.map +1 -0
  145. package/dist/libs/hetzner/reg-secret.js +39 -0
  146. package/dist/libs/k8s-constants.d.ts +12 -0
  147. package/dist/libs/k8s-constants.d.ts.map +1 -0
  148. package/dist/libs/k8s-constants.js +66 -0
  149. package/dist/libs/k8s-db.d.ts +18 -0
  150. package/dist/libs/k8s-db.d.ts.map +1 -0
  151. package/dist/libs/k8s-db.js +73 -0
  152. package/dist/libs/k8s-generate.d.ts +17 -0
  153. package/dist/libs/k8s-generate.d.ts.map +1 -0
  154. package/dist/libs/k8s-generate.js +179 -0
  155. package/dist/libs/k8s-helpers.d.ts +11 -0
  156. package/dist/libs/k8s-helpers.d.ts.map +1 -0
  157. package/dist/libs/k8s-helpers.js +42 -0
  158. package/dist/libs/k8s-image-config.d.ts +8 -0
  159. package/dist/libs/k8s-image-config.d.ts.map +1 -0
  160. package/dist/libs/k8s-image-config.js +113 -0
  161. package/dist/libs/k8s-job-waiter.d.ts +8 -0
  162. package/dist/libs/k8s-job-waiter.d.ts.map +1 -0
  163. package/dist/libs/k8s-job-waiter.js +84 -0
  164. package/dist/libs/k8s-namespace.d.ts +7 -0
  165. package/dist/libs/k8s-namespace.d.ts.map +1 -0
  166. package/dist/libs/k8s-namespace.js +27 -0
  167. package/dist/libs/k8s-redis.d.ts +6 -0
  168. package/dist/libs/k8s-redis.d.ts.map +1 -0
  169. package/dist/libs/k8s-redis.js +31 -0
  170. package/dist/libs/k8s-secrets-manager.d.ts +5 -0
  171. package/dist/libs/k8s-secrets-manager.d.ts.map +1 -0
  172. package/dist/libs/k8s-secrets-manager.js +61 -0
  173. package/dist/libs/validate-env.d.ts +56 -0
  174. package/dist/libs/validate-env.d.ts.map +1 -0
  175. package/dist/libs/validate-env.js +214 -0
  176. package/dist/libs/validate-env.spec.d.ts +2 -0
  177. package/dist/libs/validate-env.spec.d.ts.map +1 -0
  178. package/dist/libs/validate-env.spec.js +168 -0
  179. package/dist/libs/workspace-discovery.d.ts +2 -0
  180. package/dist/libs/workspace-discovery.d.ts.map +1 -0
  181. package/dist/libs/workspace-discovery.js +75 -0
  182. package/dist/test.d.ts +2 -0
  183. package/dist/test.d.ts.map +1 -0
  184. package/dist/test.js +1 -0
  185. package/dist/types/index.d.ts +925 -0
  186. package/dist/types/index.d.ts.map +1 -0
  187. package/dist/types/index.js +79 -0
  188. package/package.json +55 -0
  189. package/src/app-support/crypto/index.ts +31 -0
  190. package/src/app-support/crypto/internal-token.spec.ts +53 -0
  191. package/src/app-support/crypto/internal-token.ts +82 -0
  192. package/src/app-support/crypto/secret.spec.ts +18 -0
  193. package/src/app-support/crypto/secret.ts +13 -0
  194. package/src/app-support/discovery/dev-discovery-loader.ts +35 -0
  195. package/src/app-support/discovery/service-endpoint.ts +12 -0
  196. package/src/cli/affected.ts +116 -0
  197. package/src/cli/common.spec.ts +78 -0
  198. package/src/cli/common.ts +323 -0
  199. package/src/cli/console.ts +46 -0
  200. package/src/cli/constant.ts +25 -0
  201. package/src/cli/db.ts +133 -0
  202. package/src/cli/dml.ts +126 -0
  203. package/src/cli/env.ts +87 -0
  204. package/src/cli/exec.sh +21 -0
  205. package/src/cli/exec.ts +57 -0
  206. package/src/cli/image.ts +197 -0
  207. package/src/cli/init.ts +75 -0
  208. package/src/cli/internal-curl.ts +48 -0
  209. package/src/cli/job.ts +80 -0
  210. package/src/cli/jwt.ts +32 -0
  211. package/src/cli/namespace.ts +78 -0
  212. package/src/cli/prep-build.ts +96 -0
  213. package/src/cli/prisma.ts +33 -0
  214. package/src/cli/redis.ts +83 -0
  215. package/src/cli/registry.ts +76 -0
  216. package/src/cli/run-many.ts +61 -0
  217. package/src/cli/run.ts +46 -0
  218. package/src/cli/template.ts +169 -0
  219. package/src/cli/test.ts +30 -0
  220. package/src/devops.ts +119 -0
  221. package/src/index.ts +3 -0
  222. package/src/libs/affected-entities.ts +71 -0
  223. package/src/libs/config.ts +117 -0
  224. package/src/libs/digital-ocean/container-reg.ts +81 -0
  225. package/src/libs/discovery/dependencies.spec.ts +25 -0
  226. package/src/libs/discovery/dependencies.ts +73 -0
  227. package/src/libs/discovery/images.ts +57 -0
  228. package/src/libs/discovery/index.ts +60 -0
  229. package/src/libs/discovery/process-common.ts +55 -0
  230. package/src/libs/discovery/process-package-json.ts +47 -0
  231. package/src/libs/discovery/process-pyproject-toml.ts +43 -0
  232. package/src/libs/git-helpers.ts +32 -0
  233. package/src/libs/hetzner/reg-secret.ts +54 -0
  234. package/src/libs/k8s-constants.ts +83 -0
  235. package/src/libs/k8s-db.ts +83 -0
  236. package/src/libs/k8s-generate.ts +211 -0
  237. package/src/libs/k8s-helpers.ts +59 -0
  238. package/src/libs/k8s-image-config.ts +165 -0
  239. package/src/libs/k8s-job-waiter.ts +124 -0
  240. package/src/libs/k8s-namespace.ts +41 -0
  241. package/src/libs/k8s-redis.ts +31 -0
  242. package/src/libs/k8s-secrets-manager.ts +79 -0
  243. package/src/libs/validate-env.spec.ts +223 -0
  244. package/src/libs/validate-env.ts +266 -0
  245. package/src/target-templates/.devops/config/constants.yaml +17 -0
  246. package/src/target-templates/.devops/config/images.yaml +88 -0
  247. package/src/target-templates/.devops/docker-images/common/docker-common.sh +23 -0
  248. package/src/target-templates/.devops/docker-images/node-services/node-exec.sh +8 -0
  249. package/src/target-templates/.devops/docker-images/node-services/node-run.sh +8 -0
  250. package/src/target-templates/.devops/docker-images/node-services.Dockerfile +34 -0
  251. package/src/target-templates/.devops/docker-images/python-services/python-exec.sh +8 -0
  252. package/src/target-templates/.devops/docker-images/python-services/python-run.sh +8 -0
  253. package/src/target-templates/.devops/docker-images/python-services.Dockerfile +29 -0
  254. package/src/target-templates/.devops/env.example.yaml +23 -0
  255. package/src/target-templates/.devops/infra/hetzner/abandoned/harbor-values.yaml +30 -0
  256. package/src/target-templates/.devops/infra/hetzner/abandoned/hcloud-config.yaml +134 -0
  257. package/src/target-templates/.devops/infra/hetzner/cert-manager.yaml +25 -0
  258. package/src/target-templates/.devops/infra/hetzner/harbor-cert.yaml +13 -0
  259. package/src/target-templates/.devops/infra/hetzner/harbor-values.yaml +76 -0
  260. package/src/target-templates/.devops/infra/hetzner/hcloud-config.yaml +113 -0
  261. package/src/target-templates/.devops/infra/hetzner/ingress-nginx-annotations.yaml +49 -0
  262. package/src/target-templates/.devops/infra/hetzner/ingress-nginx-configmap.yaml +8 -0
  263. package/src/target-templates/.devops/infra/hetzner/retain-storage-class.yaml +8 -0
  264. package/src/target-templates/.devops/infra/monitoring-ingress.yaml +62 -0
  265. package/src/target-templates/.devops/infra/stackgres-ui-ingress.yaml +35 -0
  266. package/src/target-templates/.devops/infra/test.yaml +60 -0
  267. package/src/target-templates/.devops/manifests/_index.yaml +21 -0
  268. package/src/target-templates/.devops/manifests/cron-jobs.yaml.hb +55 -0
  269. package/src/target-templates/.devops/manifests/db-migrate-job.yaml.hb +42 -0
  270. package/src/target-templates/.devops/manifests/deployment-debug.yaml.hb +44 -0
  271. package/src/target-templates/.devops/manifests/deployment-process.yaml.hb +47 -0
  272. package/src/target-templates/.devops/manifests/deployment-web.yaml.hb +53 -0
  273. package/src/target-templates/.devops/manifests/ingress.yaml.hb +21 -0
  274. package/src/target-templates/.devops/manifests/prefect.yaml.hb +62 -0
  275. package/src/target-templates/.devops/manifests/service.yaml.hb +15 -0
  276. package/src/target-templates/.devops/milvus/production/milvus-values.yaml +2 -0
  277. package/src/target-templates/.devops/milvus/staging/milvus-values.yaml +2 -0
  278. package/src/target-templates/.devops/postgres/DailyOperatorRestart.yaml +54 -0
  279. package/src/target-templates/.devops/postgres/production/cluster/PodDisruptionBudget.yaml +27 -0
  280. package/src/target-templates/.devops/postgres/production/cluster/SGCluster.yaml +47 -0
  281. package/src/target-templates/.devops/postgres/production/cluster/StackGres-alerts.yaml +191 -0
  282. package/src/target-templates/.devops/postgres/production/configurations/06-SGDistributedLogs.yaml +11 -0
  283. package/src/target-templates/.devops/postgres/production/configurations/07-SGObjectStorage.yaml +18 -0
  284. package/src/target-templates/.devops/postgres/production/configurations/08-SGScript.yaml +12 -0
  285. package/src/target-templates/.devops/postgres/staging/cluster/SGCluster.yaml +42 -0
  286. package/src/target-templates/.devops/postgres/staging/configurations/07-SGObjectStorage.yaml +18 -0
  287. package/src/target-templates/.devops/postgres/staging/configurations/08-SGScript.yaml +12 -0
  288. package/src/target-templates/.devops/prefect/production/prefect-values.yaml +14 -0
  289. package/src/target-templates/.devops/prefect/staging/prefect-values.yaml +14 -0
  290. package/src/target-templates/.devops/redis/production/redis-values.yaml +20 -0
  291. package/src/target-templates/.devops/redis/staging/redis-values.yaml +8 -0
  292. package/src/target-templates/.envrc +5 -0
  293. package/src/target-templates/.github/actions/build-image@v1/action.yaml +86 -0
  294. package/src/target-templates/.github/actions/connect-to-digital-ocean@v1/action.yaml +29 -0
  295. package/src/target-templates/.github/actions/connect-to-hetzner@v1/action.yaml +31 -0
  296. package/src/target-templates/.github/actions/connect-to-infra@v1/action.yaml +46 -0
  297. package/src/target-templates/.github/actions/db-migrate@v1/action.yaml +23 -0
  298. package/src/target-templates/.github/actions/deploy-image@v1/action.yaml +33 -0
  299. package/src/target-templates/.github/actions/setup-prereq@v1/action.yaml +29 -0
  300. package/src/target-templates/.github/workflows/k8s-build.yaml +84 -0
  301. package/src/target-templates/applications/example-data-pipeline/pyproject.toml +14 -0
  302. package/src/target-templates/applications/example-data-pipeline/src/example_data_pipeline/main.py +38 -0
  303. package/src/target-templates/applications/example-node/index.ts +30 -0
  304. package/src/target-templates/applications/example-node/package.json +26 -0
  305. package/src/target-templates/applications/example-node/tsconfig.json +3 -0
  306. package/src/target-templates/applications/example-python/pyproject.toml +20 -0
  307. package/src/target-templates/applications/example-python/src/example_python/__init__.py +0 -0
  308. package/src/target-templates/applications/example-python/src/example_python/main.py +13 -0
  309. package/src/target-templates/applications/example-python/src/example_python/scripts.py +17 -0
  310. package/src/target-templates/applications/example-python/tests/__init__.py +0 -0
  311. package/src/target-templates/applications/jobs/README.md +68 -0
  312. package/src/target-templates/applications/jobs/index.ts +1 -0
  313. package/src/target-templates/applications/jobs/package.json +30 -0
  314. package/src/target-templates/applications/jobs/tsconfig.json +3 -0
  315. package/src/target-templates/config/.env.development +1 -0
  316. package/src/target-templates/config/.env.global +4 -0
  317. package/src/target-templates/config/.env.test +1 -0
  318. package/src/target-templates/db/db/__init__.py +0 -0
  319. package/src/target-templates/db/db/db_client_test.py +46 -0
  320. package/src/target-templates/db/db-client-test.ts +140 -0
  321. package/src/target-templates/db/db-client.ts +19 -0
  322. package/src/target-templates/db/env.yaml +4 -0
  323. package/src/target-templates/db/package.json +17 -0
  324. package/src/target-templates/db/prisma/schema.prisma +24 -0
  325. package/src/target-templates/db/prisma-setup-vitest.ts +27 -0
  326. package/src/target-templates/db/pyproject.toml +14 -0
  327. package/src/target-templates/db/tsconfig.json +3 -0
  328. package/src/target-templates/devops +3 -0
  329. package/src/target-templates/devopspy +3 -0
  330. package/src/target-templates/dml/package.json +7 -0
  331. package/src/target-templates/dml/tsconfig.json +3 -0
  332. package/src/target-templates/libs/example-node-lib/bun.lock +27 -0
  333. package/src/target-templates/libs/example-node-lib/index.ts +3 -0
  334. package/src/target-templates/libs/example-node-lib/package.json +12 -0
  335. package/src/target-templates/libs/example-node-lib/tsconfig.json +3 -0
  336. package/src/target-templates/libs/example-python-lib/pyproject.toml +11 -0
  337. package/src/target-templates/libs/example-python-lib/src/example_python_lib/__init__.py +2 -0
  338. package/src/target-templates/pyproject.toml +19 -0
  339. package/src/target-templates/tmp/.gitkeep +0 -0
  340. package/src/target-templates/tsconfig.json +27 -0
  341. package/src/test.ts +0 -0
  342. package/src/types/index.ts +173 -0
@@ -0,0 +1,67 @@
1
+ import { globSync } from "glob";
2
+ import { deleteMonorepoSecret, getMonorepoSecret, setMonorepoSecret, } from "../libs/k8s-secrets-manager";
3
+ import { CombinedEnvValidator } from "../libs/validate-env";
4
+ import { CLICommandParser, dotEnvFilesForEnv, printUsageAndExit, } from "./common";
5
+ const oneLiner = "Commands to manipulate env variables";
6
+ const keyExamples = `
7
+ $ devops env get --env staging
8
+ $ devops env get KEY1 KEY2 --env staging
9
+ $ devops env set KEY1=123 KEY2=345 --env staging
10
+ $ devops env delete KEY1 KEY2 --env staging
11
+ $ devops env validate
12
+ `;
13
+ const usage = `
14
+ ${oneLiner}
15
+
16
+ COMMANDS
17
+ get Fetches secrets for the chosen environment and printes them to console
18
+ set Sets specific secrets for the chosen environment
19
+ delete Deletes specific secrets for the chosen environment
20
+ validate Validate locally, verifying the existence and type of environment variables against all env.yaml files
21
+
22
+ EXAMPLES
23
+ ${keyExamples}
24
+ `;
25
+ function run(cmdObj) {
26
+ if (cmdObj.help || cmdObj.args.length === 0)
27
+ printUsageAndExit(usage);
28
+ const [command, ...rest] = cmdObj.args;
29
+ switch (command) {
30
+ case "validate": {
31
+ const envYamlFiles = globSync("**/env.yaml");
32
+ // We have to have a _validate so that we go through a CommandExecutor which injects env variables into the process
33
+ cmdObj
34
+ .executorFromEnv(`devops env _validate ${envYamlFiles.join(" ")}`, { quiet: false })
35
+ .exec();
36
+ break;
37
+ }
38
+ case "_validate": {
39
+ const options = cmdObj.parseOptions({ booleans: ["--skip-dotenv"] });
40
+ const [_subcmd, ...envYamlFiles] = options.args;
41
+ const envFiles = options.options["--skip-dotenv"]
42
+ ? []
43
+ : dotEnvFilesForEnv(cmdObj.env);
44
+ const validator = new CombinedEnvValidator(envYamlFiles, envFiles);
45
+ validator.validate();
46
+ break;
47
+ }
48
+ case "get": {
49
+ console.log(getMonorepoSecret(cmdObj.env, rest));
50
+ break;
51
+ }
52
+ case "set": {
53
+ setMonorepoSecret(cmdObj.env, rest);
54
+ break;
55
+ }
56
+ case "delete": {
57
+ deleteMonorepoSecret(cmdObj.env, rest);
58
+ break;
59
+ }
60
+ default: {
61
+ printUsageAndExit(usage);
62
+ }
63
+ }
64
+ }
65
+ export default {
66
+ env: { oneLiner, keyExamples, run },
67
+ };
@@ -0,0 +1,11 @@
1
+ import { CLICommandParser } from "./common";
2
+ declare function run(cmdObj: CLICommandParser): void;
3
+ declare const _default: {
4
+ exec: {
5
+ oneLiner: string;
6
+ keyExamples: string;
7
+ run: typeof run;
8
+ };
9
+ };
10
+ export default _default;
11
+ //# sourceMappingURL=exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/cli/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsC,MAAM,UAAU,CAAC;AA4BhF,iBAAS,GAAG,CAAC,MAAM,EAAE,gBAAgB,QAwBpC;;;;;;;;AAED,wBAEE"}
@@ -0,0 +1,50 @@
1
+ import { CLICommandParser, CommandExecutor, printUsageAndExit } from "./common";
2
+ import url from "url";
3
+ import path from "path";
4
+ import { getWorkspace } from "../libs/discovery";
5
+ const __file__ = url.fileURLToPath(import.meta.url);
6
+ const __src__ = path.join(path.dirname(__file__), "../..", "src");
7
+ const execShPath = path.join(__src__, "cli/exec.sh");
8
+ const oneLiner = "Executes a command after injecting env variables, either globally or in a workspace";
9
+ const keyExamples = `
10
+ $ devops exec tmp/test.sh
11
+ $ devops exec bun test.ts --in myworkspace --env staging
12
+ `.trim();
13
+ const usage = `
14
+ ${oneLiner}
15
+
16
+ USAGE
17
+ devops exec <command>
18
+ devops exec --in <workspace> <command>
19
+ devops exec --in <workspace> <command> --interactive
20
+
21
+ EXAMPLES
22
+ ${keyExamples}
23
+ `;
24
+ function run(cmdObj) {
25
+ if (cmdObj.help || cmdObj.args.length === 0)
26
+ printUsageAndExit(usage);
27
+ const parsed = cmdObj.parseOptions({
28
+ params: ["--in"],
29
+ booleans: ["--interactive"],
30
+ });
31
+ const workspace = parsed.options["--in"];
32
+ let executor;
33
+ if (workspace) {
34
+ const rootPath = getWorkspace(workspace).rootPath;
35
+ executor = cmdObj.executorFromEnv(`${execShPath} ${rootPath} ${parsed.argsStr}`, { checkEnvYaml: true });
36
+ }
37
+ else {
38
+ executor = cmdObj.executorFromEnv(parsed.argsStr, { checkEnvYaml: true });
39
+ }
40
+ const interactive = Boolean(parsed.options["--interactive"]);
41
+ if (interactive) {
42
+ executor.spawn();
43
+ }
44
+ else {
45
+ executor.exec();
46
+ }
47
+ }
48
+ export default {
49
+ exec: { oneLiner, keyExamples, run },
50
+ };
@@ -0,0 +1,11 @@
1
+ import { CLICommandParser } from "../../src/cli/common";
2
+ declare function run(cmdObj: CLICommandParser): void;
3
+ declare const _default: {
4
+ image: {
5
+ oneLiner: string;
6
+ keyExamples: string;
7
+ run: typeof run;
8
+ };
9
+ };
10
+ export default _default;
11
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/cli/image.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,sBAAsB,CAAC;AAiKzF,iBAAS,GAAG,CAAC,MAAM,EAAE,gBAAgB,QA8BpC;;;;;;;;AAED,wBAEE"}
@@ -0,0 +1,140 @@
1
+ import { deleteImageVersion, getImageVersion, getWorkspaceScale, resetWorkspaceScale, setImageVersion, setWorkspaceScale } from "../libs/k8s-image-config";
2
+ import { CLICommandParser, printUsageAndExit, StrongParams } from "../../src/cli/common";
3
+ import { generateImageDeployments } from "../libs/k8s-generate";
4
+ import { applyHandler } from "../libs/k8s-helpers";
5
+ const oneLiner = "Applies image-related manifests, retrieves or set the version deployed, and scales deployments of applications";
6
+ const keyExamples = `
7
+ $ devops image deployment gen main-node sha --env staging
8
+ $ devops image deployment create main-node sha --env staging
9
+ $ devops image deployment delete main-node --env staging
10
+ $ devops image version get main-node --env staging
11
+ $ devops image version set main-node sha --env staging
12
+ $ devops image version unset main-node --env staging
13
+ $ devops image scale get main-node --env staging
14
+ $ devops image scale get main-node www --env staging
15
+ $ devops image scale set main-node www 3 --env staging
16
+ $ devops image scale unset main-node --env staging
17
+ $ devops image scale unset main-node www --env staging
18
+ `.trim();
19
+ const usage = `
20
+ ${oneLiner}
21
+
22
+ GENERATING DEPLOYMENT MANIFESTS
23
+ devops image deployment gen|create|delete <image-name> <sha>
24
+
25
+ gen - generates the manifest file with all applications that are deployed with the image
26
+ create - generates the manifest file and then runs kubectl apply
27
+ delete - generates the manifest file and then runs kubectl delete
28
+
29
+ MANAGINE APPLICATION SCALE
30
+ devops image scale get|unset <image-name> [<workspace-name>]
31
+ devops image scale set <image-name> <workspace-name> <replica-count>
32
+
33
+ set - sets the scale count in the image's config map so that it persists across deployments.
34
+ get - retrieves the current scale count. If workspace is not provided, all workspaces are returned.
35
+ unset - resets the scale count by removing the key from the image's config map. If workspace is not provided, all workspaces are reset.
36
+
37
+ Both 'set' and 'unset' return the previous scale count prior to the operation.
38
+
39
+ MANAGING IMAGE VERSIONS
40
+ devops image version get|unset <image>
41
+ devops image version set <image> <sha>
42
+
43
+ Meant to be called during deployment in order to maintain a record of the most recent deployed version.
44
+
45
+ EXAMPLES
46
+ ${keyExamples}
47
+ `;
48
+ const handlers = {
49
+ deployment: {
50
+ gen: (opts) => {
51
+ console.log(generateImageDeployments(opts.required("env"), opts.required("image"), opts.required("sha")));
52
+ },
53
+ create: (opts) => {
54
+ applyHandler('apply-deployment-', 'apply', generateImageDeployments(opts.required("env"), opts.required("image"), opts.required("sha")));
55
+ },
56
+ delete: (opts) => {
57
+ applyHandler('delete-deployment-', 'delete', generateImageDeployments(opts.required("env"), opts.required("image"), "dummy-sha"));
58
+ },
59
+ },
60
+ scale: {
61
+ set: (opts) => {
62
+ const workspace = opts.required("workspace");
63
+ const image = opts.required("image");
64
+ const replicas = Number(opts.required("replicas"));
65
+ const res = setWorkspaceScale(opts.required("env"), image, workspace, replicas);
66
+ if (res) {
67
+ console.warn(`Scale for ${workspace} in ${image} set to ${replicas}. Previous value:`);
68
+ console.log(res);
69
+ }
70
+ },
71
+ get: (opts) => {
72
+ const workspace = opts.optional("workspace");
73
+ // Satiate the type checker
74
+ if (!workspace) {
75
+ console.log(getWorkspaceScale(opts.required("env"), opts.required("image")));
76
+ }
77
+ else {
78
+ console.log(getWorkspaceScale(opts.required("env"), opts.required("image"), workspace));
79
+ }
80
+ },
81
+ unset: (opts) => {
82
+ const image = opts.required("image");
83
+ const workspace = opts.optional("workspace");
84
+ const prev = resetWorkspaceScale(opts.required("env"), image, workspace);
85
+ if (workspace) {
86
+ console.warn(`Scale for ${workspace} in ${image} unset. Previous scale:`);
87
+ console.log(prev);
88
+ }
89
+ else {
90
+ console.warn(`Scale for all workspaces in ${image} unset. Previous scale:`);
91
+ console.log(prev);
92
+ }
93
+ },
94
+ },
95
+ version: {
96
+ get: (opts) => {
97
+ const version = getImageVersion(opts.required("env"), opts.required("image"));
98
+ console.log(version ?? "");
99
+ },
100
+ set: (opts) => {
101
+ setImageVersion(opts.required("env"), opts.required("image"), opts.required("sha"));
102
+ },
103
+ unset: (opts) => {
104
+ deleteImageVersion(opts.required("env"), opts.required("image"));
105
+ },
106
+ },
107
+ };
108
+ function run(cmdObj) {
109
+ if (cmdObj.help || cmdObj.args.length < 1)
110
+ printUsageAndExit(usage);
111
+ const [command, subcommand, image, param1, param2] = cmdObj.args;
112
+ const commandHandler = handlers[command];
113
+ if (!commandHandler) {
114
+ console.error(`Unknown command: ${command}`);
115
+ printUsageAndExit(usage);
116
+ }
117
+ const handler = commandHandler[subcommand];
118
+ if (!handler) {
119
+ console.error(`Unknown subcommand: ${subcommand}`);
120
+ printUsageAndExit(usage);
121
+ }
122
+ function getExtraParams() {
123
+ if (command === 'scale') {
124
+ return subcommand === 'set' ? { workspace: param1, replicas: param2 } : { workspace: param1 };
125
+ }
126
+ else {
127
+ return { sha: param1 };
128
+ }
129
+ }
130
+ const params = new StrongParams(usage, {
131
+ env: cmdObj.env,
132
+ subcommand,
133
+ image,
134
+ ...getExtraParams()
135
+ });
136
+ handler(params);
137
+ }
138
+ export default {
139
+ image: { oneLiner, keyExamples, run },
140
+ };
@@ -0,0 +1,11 @@
1
+ import { CLICommandParser } from "./common";
2
+ declare function run(cmdObj: CLICommandParser): Promise<void>;
3
+ declare const _default: {
4
+ init: {
5
+ oneLiner: string;
6
+ keyExamples: string;
7
+ run: typeof run;
8
+ };
9
+ };
10
+ export default _default;
11
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,UAAU,CAAC;AAgB/D,iBAAe,GAAG,CAAC,MAAM,EAAE,gBAAgB,iBAG1C;;;;;;;;AAED,wBAEE"}
@@ -0,0 +1,66 @@
1
+ import url from "url";
2
+ import path from "path";
3
+ import fs from "fs-extra";
4
+ const __file__ = url.fileURLToPath(import.meta.url);
5
+ const __root__ = path.join(path.dirname(__file__), "../..");
6
+ const templatesDir = path.join(__root__, "src/target-templates");
7
+ const targetDir = process.cwd(); // User's current working directory
8
+ import { CLICommandParser, printUsageAndExit } from "./common";
9
+ const oneLiner = "Initializes the devops utility by copying template files to the current folder";
10
+ const keyExamples = `$ devops init`;
11
+ const usage = `
12
+ ${oneLiner}
13
+
14
+ NOTE
15
+ No files are overwritten.
16
+
17
+ EXAMPLES
18
+ ${keyExamples}
19
+ `;
20
+ async function run(cmdObj) {
21
+ if (cmdObj.help)
22
+ printUsageAndExit(usage);
23
+ copyTemplates();
24
+ }
25
+ export default {
26
+ init: { oneLiner, keyExamples, run },
27
+ };
28
+ async function copyTemplates() {
29
+ console.log(`Initializing devops files from ${templatesDir} to ${targetDir}`);
30
+ try {
31
+ // Copy files without overriding existing ones
32
+ await fs.copy(templatesDir, targetDir, {
33
+ overwrite: false,
34
+ errorOnExist: false,
35
+ dereference: false,
36
+ });
37
+ console.log(successMessage);
38
+ }
39
+ catch (error) {
40
+ console.error("❌ Failed to initialize devops files:", error);
41
+ process.exit(1);
42
+ }
43
+ }
44
+ const successMessage = `
45
+ ✅ Devops files initialized successfully!
46
+
47
+ To finish the setup:
48
+
49
+ 1. add the following entry to the main package.json:
50
+ "workspaces": [
51
+ "libs/**",
52
+ "applications/**",
53
+ "db/**",
54
+ "dml/**"
55
+ ],
56
+
57
+ 2. add the following to your .gitignore:
58
+ .envrc
59
+ **/.DS_Store
60
+ **/.env*
61
+ config/kubeconfig
62
+ tmp/**
63
+ !tmp/**/.gitkeep
64
+ venv/
65
+ **/__pycache__
66
+ `;
@@ -0,0 +1,11 @@
1
+ import { CLICommandParser } from "./common";
2
+ declare function run(cmdObj: CLICommandParser): Promise<void>;
3
+ declare const _default: {
4
+ 'internal-curl': {
5
+ oneLiner: string;
6
+ keyExamples: string;
7
+ run: typeof run;
8
+ };
9
+ };
10
+ export default _default;
11
+ //# sourceMappingURL=internal-curl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-curl.d.ts","sourceRoot":"","sources":["../../src/cli/internal-curl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,UAAU,CAAC;AAuB/D,iBAAe,GAAG,CAAC,MAAM,EAAE,gBAAgB,iBAmB1C;;;;;;;;AAED,wBAEE"}
@@ -0,0 +1,43 @@
1
+ import { InternalToken } from "../app-support/crypto";
2
+ import { CLICommandParser, printUsageAndExit } from "./common";
3
+ const oneLiner = "Runs a curl command bearing an internal jwt-like token to allow verifying internal communication within the namespace";
4
+ const keyExamples = `$ devops internal-curl jobs http://service-name:port/path`;
5
+ const usage = `
6
+ ${oneLiner}
7
+
8
+ GENERAL USAGE
9
+ devops internal-curl <subject> [curl-options] <url>
10
+
11
+ NOTE
12
+ --env should not be used with this command. It is expected to be run inside pods in the namespace.
13
+ Relies on the MONOREPO_BASE_SECRET environment variable for signing the token.
14
+
15
+ 'subject' is the subject of the token. Receiving endpoints should verify it matches the expected value using the
16
+ 'InternalToken' class exposed by @vaharoni/devops.
17
+
18
+ EXAMPLES
19
+ ${keyExamples}
20
+ `;
21
+ async function run(cmdObj) {
22
+ if (cmdObj.help || cmdObj.args.length === 0 || cmdObj.envForced)
23
+ printUsageAndExit(usage);
24
+ const [subject, ...rest] = cmdObj.args;
25
+ // A trick to allow running this command locally while setting the MONOREPO_BASE_SECRET in .env.global.
26
+ // Basically we have to inject the env variables into the shell, which is why we execute 'devops jwt' first
27
+ let token;
28
+ if (process.env.MONOREPO_BASE_SECRET) {
29
+ token = new InternalToken(subject).generate();
30
+ }
31
+ else {
32
+ const res = cmdObj.executorFromEnv(`devops jwt ${subject}`).exec({ asObject: true });
33
+ if (res.statusCode !== 0) {
34
+ console.error("Failed to generate token. Aborting.");
35
+ process.exit(1);
36
+ }
37
+ token = res.stdout.trim();
38
+ }
39
+ cmdObj.executorFromEnv(`curl -H "Authorization: Bearer ${token}" ${rest.join(" ")}`).exec();
40
+ }
41
+ export default {
42
+ 'internal-curl': { oneLiner, keyExamples, run },
43
+ };
@@ -0,0 +1,11 @@
1
+ import { CLICommandParser } from "../../src/cli/common";
2
+ declare function run(cmdObj: CLICommandParser): void;
3
+ declare const _default: {
4
+ job: {
5
+ oneLiner: string;
6
+ keyExamples: string;
7
+ run: typeof run;
8
+ };
9
+ };
10
+ export default _default;
11
+ //# sourceMappingURL=job.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../../src/cli/job.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,sBAAsB,CAAC;AA6CzF,iBAAS,GAAG,CAAC,MAAM,EAAE,gBAAgB,QA4BpC;;;;;;;;AAED,wBAEE"}
@@ -0,0 +1,67 @@
1
+ import {} from "../libs/k8s-image-config";
2
+ import { CLICommandParser, printUsageAndExit, StrongParams } from "../../src/cli/common";
3
+ import { generateDbMigrateJob } from "../libs/k8s-generate";
4
+ import { applyHandler } from "../libs/k8s-helpers";
5
+ import { k8sJobWaiter, printJobStatuses } from "../libs/k8s-job-waiter";
6
+ import { dbMigrateJobName } from "../libs/k8s-constants";
7
+ const oneLiner = "Creates a k8s job and waits for it to run";
8
+ const keyExamples = `
9
+ $ devops job db-migrate gen main-node <sha> --env staging
10
+ $ devops job db-migrate create main-node <sha> --env staging --timeout 120
11
+ `.trim();
12
+ const usage = `
13
+ ${oneLiner}
14
+
15
+ GENERAL USAGE
16
+ devops job db-migrate gen <image> <sha>
17
+ devops job db-migrate create <image> <sha> --timeout <timeout>
18
+
19
+ EXAMPLES
20
+ ${keyExamples}
21
+ `;
22
+ const handlers = {
23
+ gen: (opts) => {
24
+ console.log(generateDbMigrateJob(opts.required("env"), opts.required("image"), opts.required("sha")));
25
+ },
26
+ create: async (opts) => {
27
+ const env = opts.required("env");
28
+ const image = opts.required("image");
29
+ const sha = opts.required("sha");
30
+ const timeout = opts.optional("timeout") ?? '240';
31
+ const manifest = generateDbMigrateJob(env, image, sha);
32
+ const jobName = dbMigrateJobName(sha);
33
+ applyHandler(`apply-${jobName}`, 'apply', manifest);
34
+ const statuses = await k8sJobWaiter(env, Number(timeout ?? '240'), [jobName]);
35
+ if (statuses && Object.keys(statuses).length > 0) {
36
+ printJobStatuses(statuses);
37
+ }
38
+ },
39
+ };
40
+ function run(cmdObj) {
41
+ if (cmdObj.help || cmdObj.args.length < 1)
42
+ printUsageAndExit(usage);
43
+ const parsedArgs = cmdObj.parseOptions({
44
+ params: ["--timeout"]
45
+ });
46
+ const [jobName, command, image, sha] = parsedArgs.args;
47
+ if (jobName !== 'db-migrate') {
48
+ console.error(`Unknown job: ${jobName}. Only db-migrate is supported at this time.`);
49
+ process.exit(1);
50
+ }
51
+ const handler = handlers[command];
52
+ if (!handler) {
53
+ console.error(`Unknown command: ${command}`);
54
+ printUsageAndExit(usage);
55
+ }
56
+ const timeout = parsedArgs.options["--timeout"];
57
+ const params = new StrongParams(usage, {
58
+ env: cmdObj.env,
59
+ image,
60
+ sha,
61
+ timeout
62
+ });
63
+ handler(params);
64
+ }
65
+ export default {
66
+ job: { oneLiner, keyExamples, run },
67
+ };
@@ -0,0 +1,11 @@
1
+ import { CLICommandParser } from "./common";
2
+ declare function run(cmdObj: CLICommandParser): Promise<void>;
3
+ declare const _default: {
4
+ jwt: {
5
+ oneLiner: string;
6
+ keyExamples: string;
7
+ run: typeof run;
8
+ };
9
+ };
10
+ export default _default;
11
+ //# sourceMappingURL=jwt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/cli/jwt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,UAAU,CAAC;AAqB/D,iBAAe,GAAG,CAAC,MAAM,EAAE,gBAAgB,iBAK1C;;;;;;;;AAED,wBAEE"}
@@ -0,0 +1,27 @@
1
+ import { InternalToken } from "../app-support/crypto";
2
+ import { CLICommandParser, printUsageAndExit } from "./common";
3
+ const oneLiner = "Returns a JWT-like token to allow verifying internal communication within the namespace";
4
+ const keyExamples = `$ devops jwt jobs`;
5
+ const usage = `
6
+ ${oneLiner}
7
+
8
+ GENERAL USAGE
9
+ devops jwt <subject>
10
+
11
+ NOTE
12
+ The token is valid for 60 seconds and bears the specified subject.
13
+ --env should not be used with this command. It is expected to be run inside pods in the namespace.
14
+ Relies on the MONOREPO_BASE_SECRET environment variable for signing the token.
15
+
16
+ EXAMPLES
17
+ ${keyExamples}
18
+ `;
19
+ async function run(cmdObj) {
20
+ if (cmdObj.help || cmdObj.args.length === 0 || cmdObj.envForced)
21
+ printUsageAndExit(usage);
22
+ const subject = cmdObj.args[0];
23
+ console.log(new InternalToken(subject).generate());
24
+ }
25
+ export default {
26
+ jwt: { oneLiner, keyExamples, run },
27
+ };
@@ -0,0 +1,11 @@
1
+ import { CLICommandParser } from "../../src/cli/common";
2
+ declare function run(cmdObj: CLICommandParser): void;
3
+ declare const _default: {
4
+ namespace: {
5
+ oneLiner: string;
6
+ keyExamples: string;
7
+ run: typeof run;
8
+ };
9
+ };
10
+ export default _default;
11
+ //# sourceMappingURL=namespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../src/cli/namespace.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,sBAAsB,CAAC;AA0DzF,iBAAS,GAAG,CAAC,MAAM,EAAE,gBAAgB,QAapC;;;;;;;;AAED,wBAEE"}
@@ -0,0 +1,70 @@
1
+ import {} from "../libs/k8s-image-config";
2
+ import { CLICommandParser, printUsageAndExit, StrongParams } from "../../src/cli/common";
3
+ import { copySecretHarborToNamespace, patchServiceAccountImagePullSecret, } from "../../src/libs/hetzner/reg-secret";
4
+ import { checkEnvSetup, createEmptyEnvSecret, createNamespace, deleteNamespace, patchBaseSecret } from "../libs/k8s-namespace";
5
+ const oneLiner = "Creates the basic prerequisites for a monorepo";
6
+ const keyExamples = `
7
+ $ devops namespace create --env staging
8
+ $ devops namespace delete --env staging
9
+ $ devops namespace check --env staging
10
+ `.trim();
11
+ const usage = `
12
+ ${oneLiner}
13
+
14
+ GENERAL USAGE
15
+ devops namespcae create|delete|check --env <env>
16
+
17
+ 'create' does the following:
18
+ 1. Creates the namepace
19
+ 2. Creates a secret to hold environment variables (used by devops env) and the base cryptographic secret
20
+ 3. On Hetzner, copies the Harbor secret to the namespace and patches the default service account to use it
21
+
22
+ 'delete' removes the namespace in kubernetes, which deletes all entities within it.
23
+
24
+ 'check' returns exit code 0 if the namespace exists in kubernetes, 1 otherwise.
25
+
26
+ EXAMPLES
27
+ ${keyExamples}
28
+ `;
29
+ const handlers = {
30
+ create(opts) {
31
+ const env = opts.required("env");
32
+ createNamespace(env);
33
+ createEmptyEnvSecret(env);
34
+ patchBaseSecret(env);
35
+ copySecretHarborToNamespace(env);
36
+ patchServiceAccountImagePullSecret(env);
37
+ },
38
+ delete(opts) {
39
+ deleteNamespace(opts.required("env"));
40
+ },
41
+ check(opts) {
42
+ const exists = checkEnvSetup(opts.required("env"));
43
+ if (exists)
44
+ return;
45
+ console.error(`
46
+ The environment does not exist in the cluster.
47
+ In order to create resources for it in the cluster, it must be first set up. This is done to protect from unintentional resource creation.
48
+ To set up the environment, run the following from your dev machine:
49
+ $ devops namespace create --env <env>
50
+ `);
51
+ process.exit(1);
52
+ },
53
+ };
54
+ function run(cmdObj) {
55
+ if (cmdObj.help || cmdObj.args.length < 1)
56
+ printUsageAndExit(usage);
57
+ const [command] = cmdObj.args;
58
+ const handler = handlers[command];
59
+ if (!handler) {
60
+ console.error(`Unknown command: ${command}`);
61
+ printUsageAndExit(usage);
62
+ }
63
+ const params = new StrongParams(usage, {
64
+ env: cmdObj.env,
65
+ });
66
+ handler(params);
67
+ }
68
+ export default {
69
+ namespace: { oneLiner, keyExamples, run },
70
+ };
@@ -0,0 +1,11 @@
1
+ import { CLICommandParser } from "./common";
2
+ declare function run(cmdObj: CLICommandParser): Promise<void>;
3
+ declare const _default: {
4
+ "prep-build": {
5
+ oneLiner: string;
6
+ keyExamples: string;
7
+ run: typeof run;
8
+ };
9
+ };
10
+ export default _default;
11
+ //# sourceMappingURL=prep-build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prep-build.d.ts","sourceRoot":"","sources":["../../src/cli/prep-build.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,UAAU,CAAC;AAqB/D,iBAAe,GAAG,CAAC,MAAM,EAAE,gBAAgB,iBAmE1C;;;;;;;;AAED,wBAEE"}