@catladder/pipeline 0.0.0-node16-ddfae617 → 0.0.0-prettier-cbceeed9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/bin/catladder-gitlab-dev.js +3 -0
  2. package/bin/catladder-gitlab.js +1 -1
  3. package/dist/build/base/createBuildJob.d.ts +2 -2
  4. package/dist/build/base/createBuildJob.js +15 -30
  5. package/dist/build/base/writeBuildInfo.d.ts +2 -0
  6. package/dist/build/base/{getBuildInfo.js → writeBuildInfo.js} +3 -6
  7. package/dist/build/custom/buildJob.d.ts +3 -0
  8. package/dist/build/custom/buildJob.js +83 -0
  9. package/dist/build/custom/index.d.ts +3 -0
  10. package/dist/build/custom/index.js +40 -0
  11. package/dist/build/docker.d.ts +33 -9
  12. package/dist/build/docker.js +51 -54
  13. package/dist/build/index.d.ts +6 -5
  14. package/dist/build/index.js +20 -6
  15. package/dist/build/node/buildJob.d.ts +2 -2
  16. package/dist/build/node/buildJob.js +3 -25
  17. package/dist/build/node/cache.d.ts +2 -2
  18. package/dist/build/node/cache.js +19 -22
  19. package/dist/build/node/index.d.ts +1 -1
  20. package/dist/build/node/index.js +3 -16
  21. package/dist/build/node/meteor.d.ts +1 -1
  22. package/dist/build/node/meteor.js +9 -20
  23. package/dist/build/node/testJob.d.ts +2 -2
  24. package/dist/build/node/testJob.js +7 -21
  25. package/dist/build/node/yarn.d.ts +1 -1
  26. package/dist/build/node/yarn.js +14 -15
  27. package/dist/build/rails/build.d.ts +3 -0
  28. package/dist/build/rails/build.js +51 -0
  29. package/dist/build/rails/index.d.ts +3 -0
  30. package/dist/build/rails/index.js +41 -0
  31. package/dist/build/rails/test.d.ts +3 -0
  32. package/dist/build/rails/test.js +94 -0
  33. package/dist/build/types.d.ts +84 -9
  34. package/dist/build/types.js +0 -4
  35. package/dist/bundles/catladder-gitlab/index.js +32979 -0
  36. package/dist/catladder-gitlab.js +7 -26
  37. package/dist/config/{configruedEnvs.test.d.ts → __tests__/configruedEnvs.test.d.ts} +0 -0
  38. package/dist/config/{configruedEnvs.test.js → __tests__/configruedEnvs.test.js} +10 -12
  39. package/dist/config/configruedEnvs.d.ts +1 -1
  40. package/dist/config/configruedEnvs.js +7 -22
  41. package/dist/config/index.js +0 -4
  42. package/dist/config/readConfig.d.ts +1 -1
  43. package/dist/config/readConfig.js +2 -13
  44. package/dist/constants.js +1 -1
  45. package/dist/context/{resolveReferences.test.d.ts → __tests__/resolveReferences.test.d.ts} +0 -0
  46. package/dist/context/__tests__/resolveReferences.test.js +336 -0
  47. package/dist/context/getEnvConfig.d.ts +2 -0
  48. package/dist/context/getEnvConfig.js +18 -0
  49. package/dist/context/getEnvType.d.ts +4 -0
  50. package/dist/context/getEnvType.js +13 -0
  51. package/dist/context/getEnvironment.d.ts +3 -0
  52. package/dist/{pipeline/createChildPipeline.test.js → context/getEnvironment.js} +42 -84
  53. package/dist/context/getEnvironmentContext.d.ts +4 -0
  54. package/dist/context/getEnvironmentContext.js +33 -0
  55. package/dist/context/getEnvironmentVariables.d.ts +10 -0
  56. package/dist/context/getEnvironmentVariables.js +260 -0
  57. package/dist/context/getLabels.d.ts +8 -0
  58. package/dist/context/getLabels.js +38 -0
  59. package/dist/context/index.d.ts +5 -6
  60. package/dist/context/index.js +158 -208
  61. package/dist/context/resolveReferences.d.ts +1 -3
  62. package/dist/context/resolveReferences.js +213 -52
  63. package/dist/defaults/index.d.ts +1 -1
  64. package/dist/deploy/base.d.ts +4 -2
  65. package/dist/deploy/base.js +38 -33
  66. package/dist/deploy/cloudRun/deployJob.d.ts +3 -0
  67. package/dist/deploy/cloudRun/deployJob.js +238 -0
  68. package/dist/deploy/cloudRun/index.d.ts +4 -0
  69. package/dist/deploy/cloudRun/index.js +112 -0
  70. package/dist/deploy/cloudRun/utils/createArgsString.d.ts +11 -0
  71. package/dist/deploy/cloudRun/utils/createArgsString.js +55 -0
  72. package/dist/deploy/cloudRun/utils/database.d.ts +4 -0
  73. package/dist/deploy/cloudRun/utils/database.js +64 -0
  74. package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -0
  75. package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +10 -0
  76. package/dist/deploy/cloudRun/utils/jobName.d.ts +1 -0
  77. package/dist/deploy/cloudRun/utils/jobName.js +8 -0
  78. package/dist/deploy/custom/deployJob.d.ts +2 -2
  79. package/dist/deploy/custom/deployJob.js +10 -16
  80. package/dist/deploy/custom/index.d.ts +2 -1
  81. package/dist/deploy/custom/index.js +14 -19
  82. package/dist/deploy/dockerTag/deployJob.d.ts +3 -0
  83. package/dist/deploy/dockerTag/deployJob.js +24 -0
  84. package/dist/deploy/dockerTag/index.d.ts +2 -0
  85. package/dist/deploy/dockerTag/index.js +17 -0
  86. package/dist/deploy/index.d.ts +12 -8
  87. package/dist/deploy/index.js +7 -20
  88. package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +4 -0
  89. package/dist/deploy/kubernetes/additionalSecretKeys.js +24 -0
  90. package/dist/deploy/kubernetes/cloudSql/index.d.ts +13 -0
  91. package/dist/deploy/kubernetes/cloudSql/index.js +30 -0
  92. package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
  93. package/dist/deploy/kubernetes/deployJob.js +17 -91
  94. package/dist/deploy/kubernetes/index.d.ts +3 -1
  95. package/dist/deploy/kubernetes/index.js +42 -4
  96. package/dist/deploy/kubernetes/kubeEnv.d.ts +9 -0
  97. package/dist/deploy/kubernetes/kubeEnv.js +72 -0
  98. package/dist/deploy/kubernetes/kubeValues.d.ts +97 -0
  99. package/dist/deploy/kubernetes/kubeValues.js +124 -0
  100. package/dist/deploy/kubernetes/mongodb.d.ts +18 -5
  101. package/dist/deploy/kubernetes/mongodb.js +96 -10
  102. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +25 -21
  103. package/dist/deploy/kubernetes/processSecretsAsFiles.js +2 -10
  104. package/dist/deploy/types/base.d.ts +14 -0
  105. package/dist/deploy/types/base.js +3 -0
  106. package/dist/deploy/types/custom.d.ts +33 -0
  107. package/dist/deploy/types/custom.js +3 -0
  108. package/dist/deploy/types/dockerTag.d.ts +10 -0
  109. package/dist/deploy/types/dockerTag.js +3 -0
  110. package/dist/deploy/types/googleCloudRun.d.ts +121 -0
  111. package/dist/deploy/types/googleCloudRun.js +3 -0
  112. package/dist/deploy/types/index.d.ts +22 -0
  113. package/dist/deploy/types/index.js +31 -0
  114. package/dist/deploy/types/kubernetes.d.ts +276 -0
  115. package/dist/deploy/types/kubernetes.js +3 -0
  116. package/dist/deploy/utils.d.ts +2 -2
  117. package/dist/deploy/utils.js +3 -10
  118. package/dist/index.js +0 -10
  119. package/dist/pipeline/commitInfo/getBuildId.d.ts +1 -0
  120. package/dist/pipeline/commitInfo/getBuildId.js +135 -0
  121. package/dist/pipeline/commitInfo/getCommitInfo.d.ts +2 -0
  122. package/dist/pipeline/commitInfo/getCommitInfo.js +140 -0
  123. package/dist/pipeline/createAllJobs.d.ts +8 -0
  124. package/dist/{build/tests/storybook.test.js → pipeline/createAllJobs.js} +54 -104
  125. package/dist/pipeline/createChildPipeline.d.ts +2 -2
  126. package/dist/pipeline/createChildPipeline.js +40 -121
  127. package/dist/pipeline/createJobsForComponent.d.ts +3 -0
  128. package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +33 -192
  129. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
  130. package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
  131. package/dist/pipeline/index.d.ts +1 -1
  132. package/dist/pipeline/index.js +1 -5
  133. package/dist/pipeline/packageManager.d.ts +1 -1
  134. package/dist/pipeline/packageManager.js +20 -173
  135. package/dist/pipeline/yarn/yarnUtils.d.ts +4 -0
  136. package/dist/pipeline/yarn/yarnUtils.js +193 -0
  137. package/dist/rules/index.d.ts +3 -1
  138. package/dist/rules/index.js +7 -6
  139. package/dist/runner/index.d.ts +2 -3
  140. package/dist/runner/index.js +0 -3
  141. package/dist/tsconfig.tsbuildinfo +1 -1
  142. package/dist/types/config.d.ts +19 -25
  143. package/dist/types/config.js +6 -16
  144. package/dist/types/context.d.ts +16 -3
  145. package/dist/types/environmentContext.d.ts +28 -0
  146. package/dist/types/environmentContext.js +3 -0
  147. package/dist/types/gitlab-types.d.ts +39 -7
  148. package/dist/types/index.js +0 -6
  149. package/dist/types/jobs.d.ts +25 -17
  150. package/dist/types/jobs.js +1 -1
  151. package/dist/types/pipeline.d.ts +1 -1
  152. package/dist/types/utils.d.ts +1 -0
  153. package/dist/types/utils.js +3 -0
  154. package/dist/utils/gitlab.d.ts +5 -0
  155. package/dist/utils/gitlab.js +48 -0
  156. package/dist/utils/index.js +5 -15
  157. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +1560 -0
  158. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +1560 -0
  159. package/examples/__snapshots__/cloud-run-non-public.ts.snap +1560 -0
  160. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3092 -0
  161. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +3103 -0
  162. package/examples/__snapshots__/custom-build-job.ts.snap +1162 -0
  163. package/examples/__snapshots__/custom-envs.ts.snap +261 -0
  164. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +2280 -0
  165. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +4077 -0
  166. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
  167. package/examples/__snapshots__/wait-for-other-deploy.ts.snap +1626 -0
  168. package/examples/__utils__/helpers.ts +14 -0
  169. package/examples/cloud-run-memory-limit.ts +28 -0
  170. package/examples/cloud-run-no-cpu-throttling.ts +33 -0
  171. package/examples/cloud-run-non-public.ts +27 -0
  172. package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
  173. package/examples/cloud-run-with-sql.ts +61 -0
  174. package/examples/custom-build-job.ts +28 -0
  175. package/examples/custom-envs.ts +31 -0
  176. package/examples/kubernetes-application-customization.ts +57 -0
  177. package/examples/kubernetes-with-jobs.ts +68 -0
  178. package/examples/rails-k8s-with-worker.ts +95 -0
  179. package/examples/wait-for-other-deploy.ts +36 -0
  180. package/package.json +16 -13
  181. package/scripts/bundle +2 -0
  182. package/src/build/base/createBuildJob.ts +12 -5
  183. package/src/build/base/{getBuildInfo.ts → writeBuildInfo.ts} +2 -2
  184. package/src/build/custom/buildJob.ts +64 -0
  185. package/src/build/custom/index.ts +7 -0
  186. package/src/build/docker.ts +58 -33
  187. package/src/build/index.ts +24 -5
  188. package/src/build/node/buildJob.ts +2 -2
  189. package/src/build/node/cache.ts +19 -8
  190. package/src/build/node/index.ts +1 -1
  191. package/src/build/node/meteor.ts +8 -2
  192. package/src/build/node/testJob.ts +4 -2
  193. package/src/build/node/yarn.ts +21 -10
  194. package/src/build/rails/build.ts +38 -0
  195. package/src/build/rails/index.ts +8 -0
  196. package/src/build/rails/test.ts +86 -0
  197. package/src/build/types.ts +97 -2
  198. package/src/catladder-gitlab.ts +4 -2
  199. package/src/config/{configruedEnvs.test.ts → __tests__/configruedEnvs.test.ts} +3 -3
  200. package/src/config/configruedEnvs.ts +2 -7
  201. package/src/config/readConfig.ts +1 -1
  202. package/src/context/{resolveReferences.test.ts → __tests__/resolveReferences.test.ts} +23 -38
  203. package/src/context/getEnvConfig.ts +21 -0
  204. package/src/context/getEnvType.ts +17 -0
  205. package/src/context/getEnvironment.ts +40 -0
  206. package/src/context/getEnvironmentContext.ts +57 -0
  207. package/src/context/getEnvironmentVariables.ts +155 -0
  208. package/src/context/getLabels.ts +20 -0
  209. package/src/context/index.ts +28 -193
  210. package/src/context/resolveReferences.ts +35 -31
  211. package/src/defaults/index.ts +1 -1
  212. package/src/deploy/base.ts +43 -19
  213. package/src/deploy/cloudRun/deployJob.ts +276 -0
  214. package/src/deploy/cloudRun/index.ts +95 -0
  215. package/src/deploy/cloudRun/utils/createArgsString.ts +26 -0
  216. package/src/deploy/cloudRun/utils/database.ts +55 -0
  217. package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +14 -0
  218. package/src/deploy/cloudRun/utils/jobName.ts +2 -0
  219. package/src/deploy/custom/deployJob.ts +13 -3
  220. package/src/deploy/custom/index.ts +9 -1
  221. package/src/deploy/dockerTag/deployJob.ts +31 -0
  222. package/src/deploy/dockerTag/index.ts +9 -0
  223. package/src/deploy/index.ts +26 -17
  224. package/src/deploy/kubernetes/additionalSecretKeys.ts +23 -0
  225. package/src/deploy/kubernetes/cloudSql/index.ts +28 -0
  226. package/src/deploy/kubernetes/deployJob.ts +21 -78
  227. package/src/deploy/kubernetes/index.ts +42 -1
  228. package/src/deploy/kubernetes/kubeEnv.ts +48 -0
  229. package/src/deploy/kubernetes/kubeValues.ts +96 -0
  230. package/src/deploy/kubernetes/mongodb.ts +104 -7
  231. package/src/deploy/kubernetes/processSecretsAsFiles.ts +1 -1
  232. package/src/deploy/types/base.ts +17 -0
  233. package/src/deploy/types/custom.ts +36 -0
  234. package/src/deploy/types/dockerTag.ts +12 -0
  235. package/src/deploy/types/googleCloudRun.ts +179 -0
  236. package/src/deploy/types/index.ts +28 -0
  237. package/src/deploy/types/kubernetes.ts +301 -0
  238. package/src/deploy/utils.ts +6 -2
  239. package/src/pipeline/commitInfo/getBuildId.ts +6 -0
  240. package/src/pipeline/commitInfo/getCommitInfo.ts +12 -0
  241. package/src/pipeline/createAllJobs.ts +38 -0
  242. package/src/pipeline/createChildPipeline.ts +9 -20
  243. package/src/pipeline/createJobsForComponent.ts +64 -0
  244. package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
  245. package/src/pipeline/index.ts +1 -1
  246. package/src/pipeline/packageManager.ts +4 -38
  247. package/src/pipeline/yarn/yarnUtils.ts +37 -0
  248. package/src/rules/index.ts +9 -6
  249. package/src/runner/index.ts +2 -1
  250. package/src/types/config.ts +26 -13
  251. package/src/types/context.ts +23 -2
  252. package/src/types/environmentContext.ts +33 -0
  253. package/src/types/gitlab-types.ts +36 -6
  254. package/src/types/jobs.ts +30 -6
  255. package/src/types/pipeline.ts +1 -1
  256. package/src/types/utils.ts +7 -0
  257. package/src/utils/gitlab.ts +23 -0
  258. package/tsconfig.json +3 -1
  259. package/dist/build/base/getBuildInfo.d.ts +0 -2
  260. package/dist/build/tests/storybook.test.d.ts +0 -1
  261. package/dist/context/resolveReferences.test.js +0 -141
  262. package/dist/deploy/kubernetes/cloudsql.d.ts +0 -6
  263. package/dist/deploy/kubernetes/cloudsql.js +0 -16
  264. package/dist/deploy/types.d.ts +0 -196
  265. package/dist/deploy/types.js +0 -16
  266. package/dist/pipeline/createChildPipeline.test.d.ts +0 -1
  267. package/dist/pipeline/createJobs.d.ts +0 -3
  268. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -8
  269. package/dist/pipeline/gitlab/makeGitlabJob.js +0 -45
  270. package/src/build/tests/storybook.test.ts +0 -54
  271. package/src/deploy/kubernetes/cloudsql.ts +0 -12
  272. package/src/deploy/types.ts +0 -189
  273. package/src/pipeline/createChildPipeline.test.ts +0 -49
  274. package/src/pipeline/createJobs.ts +0 -195
  275. package/src/pipeline/gitlab/makeGitlabJob.ts +0 -16
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = this && this.__rest || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ var __read = this && this.__read || function (o, n) {
22
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
23
+ if (!m) return o;
24
+ var i = m.call(o),
25
+ r,
26
+ ar = [],
27
+ e;
28
+ try {
29
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
+ } catch (error) {
31
+ e = {
32
+ error: error
33
+ };
34
+ } finally {
35
+ try {
36
+ if (r && !r.done && (m = i["return"])) m.call(i);
37
+ } finally {
38
+ if (e) throw e.error;
39
+ }
40
+ }
41
+ return ar;
42
+ };
43
+ exports.__esModule = true;
44
+ exports.createKubeValues = void 0;
45
+ var lodash_1 = require("lodash");
46
+ var utils_1 = require("../../utils");
47
+ var types_1 = require("../types");
48
+ var cloudSql_1 = require("./cloudSql");
49
+ var kubeEnv_1 = require("./kubeEnv");
50
+ var mongodb_1 = require("./mongodb");
51
+ var processSecretsAsFiles_1 = require("./processSecretsAsFiles");
52
+ var createAppConfig = function (context, application) {
53
+ if (application === false) {
54
+ return {
55
+ enabled: false
56
+ };
57
+ }
58
+ var _a = application !== null && application !== void 0 ? application : {},
59
+ healthRoute = _a.healthRoute,
60
+ command = _a.command,
61
+ rest = __rest(_a, ["healthRoute", "command"]);
62
+ return (0, utils_1.mergeWithMergingArrays)({
63
+ host: context.environment.host,
64
+ command: command !== null && command !== void 0 ? command : context.componentConfig.build.startCommand,
65
+ livenessProbe: {
66
+ httpGet: {
67
+ path: healthRoute !== null && healthRoute !== void 0 ? healthRoute : "__health"
68
+ }
69
+ },
70
+ readinessProbe: {
71
+ httpGet: {
72
+ path: healthRoute !== null && healthRoute !== void 0 ? healthRoute : "__health"
73
+ }
74
+ },
75
+ startupProbe: {
76
+ httpGet: {
77
+ path: healthRoute !== null && healthRoute !== void 0 ? healthRoute : "__health"
78
+ }
79
+ }
80
+ },
81
+ // default
82
+ rest // merge rest in
83
+ );
84
+ };
85
+
86
+ var removeFalsy = function (record) {
87
+ if (!record) return undefined;
88
+ return Object.fromEntries(Object.entries(record).filter(function (_a) {
89
+ var _b = __read(_a, 2),
90
+ value = _b[1];
91
+ return value !== false;
92
+ }));
93
+ };
94
+ var createKubeValues = function (context) {
95
+ var _a, _b;
96
+ var deployConfig = context.componentConfig.deploy;
97
+ if (deployConfig === false) {
98
+ return [];
99
+ }
100
+ if (!(0, types_1.isOfDeployType)(deployConfig, "kubernetes")) {
101
+ // should not happen
102
+ throw new Error("deploy config is not kubernetes");
103
+ }
104
+ var values = deployConfig.values;
105
+ // we remove the application config because it can be just the value `false` which is a convenience feature, but not supported in the helm chart
106
+ // we only merge the rest of the values in
107
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
108
+ var _c = values !== null && values !== void 0 ? values : {},
109
+ application = _c.application,
110
+ jobs = _c.jobs,
111
+ cronjobs = _c.cronjobs,
112
+ rest = __rest(_c, ["application", "jobs", "cronjobs"]);
113
+ var env = (0, kubeEnv_1.createKubeEnv)(context);
114
+ var defaultKubeValues = (0, lodash_1.merge)({
115
+ env: env,
116
+ application: createAppConfig(context, application)
117
+ }, (0, cloudSql_1.hasKubernetesCloudSQL)(context) ? (0, cloudSql_1.createCloudsqlBaseConfig)(context) : {}, ((_b = (_a = deployConfig.values) === null || _a === void 0 ? void 0 : _a.mongodb) === null || _b === void 0 ? void 0 : _b.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
118
+ var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, __assign({
119
+ jobs: removeFalsy(jobs),
120
+ cronjobs: removeFalsy(cronjobs)
121
+ }, rest)));
122
+ return kubeValues;
123
+ };
124
+ exports.createKubeValues = createKubeValues;
@@ -1,15 +1,28 @@
1
- import { Context } from "../..";
1
+ import type { Context } from "../..";
2
2
  export declare const createMongodbBaseConfig: (context: Context) => {
3
3
  mongodb: {
4
4
  enabled: boolean;
5
+ auth: {
6
+ enabled: boolean;
7
+ rootPassword: string;
8
+ replicaSetKey: string;
9
+ };
10
+ persistence: {
11
+ storageClass: string;
12
+ };
5
13
  backup: {
6
14
  enabled: boolean;
15
+ hostToBackup: string;
16
+ pvcToBackup: string;
17
+ image: string;
18
+ schedule: string;
19
+ volumeSnapshotClass: string;
7
20
  };
8
21
  };
9
- "mongodb-replicaset": {
10
- replicas: number;
11
- persistentVolume: {
12
- storageClass: string;
22
+ env: {
23
+ secret: {
24
+ MONGO_OPLOG_URL?: string | undefined;
25
+ MONGO_URL: string;
13
26
  };
14
27
  };
15
28
  };
@@ -1,23 +1,109 @@
1
1
  "use strict";
2
2
 
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
3
13
  exports.__esModule = true;
4
14
  exports.createMongodbBaseConfig = void 0;
5
-
15
+ var lodash_1 = require("lodash");
16
+ var __1 = require("../..");
17
+ var getCredentialString = function (context) {
18
+ return "root:$".concat((0, __1.getSecretVarNameForContext)(context, "MONGODB_ROOT_PASSWORD"), "@");
19
+ };
20
+ var getMongodbHost = function (context, name) {
21
+ var namespace = context.environment.envVars.KUBE_NAMESPACE;
22
+ return "".concat(name, ".").concat(namespace, ".svc.cluster.local:27017");
23
+ };
24
+ var getMongodbStandaloneHost = function (context) {
25
+ var fullAppname = context.environment.envVars.KUBE_APP_NAME;
26
+ return getMongodbHost(context, "".concat(fullAppname, "-mongodb"));
27
+ };
28
+ var getMongodbReplicasetHost = function (context, index) {
29
+ var fullAppname = context.environment.envVars.KUBE_APP_NAME;
30
+ return getMongodbHost(context, "".concat(fullAppname, "-mongodb-").concat(index, ".").concat(fullAppname, "-mongodb-headless"));
31
+ };
32
+ var createMongodbUrl = function (context, dbName) {
33
+ var _a, _b;
34
+ if (!(0, __1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
35
+ throw new Error("can only createMongodbUrl on supported deploys");
36
+ }
37
+ var mongodbConfig = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.mongodb;
38
+ var queryParams = undefined;
39
+ var hosts = "";
40
+ if ((mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.architecture) === "replicaset") {
41
+ hosts = (0, lodash_1.range)(0, (_b = mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.replicaCount) !== null && _b !== void 0 ? _b : 2).map(function (i) {
42
+ return getMongodbReplicasetHost(context, i);
43
+ }).join(",");
44
+ queryParams = "replicaSet=rs0&authSource=admin";
45
+ } else {
46
+ hosts = getMongodbStandaloneHost(context);
47
+ queryParams = "authSource=admin";
48
+ }
49
+ return "mongodb://".concat(getCredentialString(context)).concat(hosts, "/").concat(dbName).concat(queryParams ? "?".concat(queryParams) : "");
50
+ };
51
+ var createMongoBackupDefaultConfig = function (context) {
52
+ var _a;
53
+ if (!(0, __1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
54
+ throw new Error("can only create mongodb base config on supported deploys");
55
+ }
56
+ var mongodbConfig = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.mongodb;
57
+ var fullAppName = context.environment.envVars.KUBE_APP_NAME;
58
+ var backupEnabled = ["prod", "stage"].includes(context.environment.envType);
59
+ var hostToBackup;
60
+ var pvcToBackup;
61
+ if ((mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.architecture) === "replicaset") {
62
+ // bit quirky, we need to specify the host and its volume
63
+ // on replicaset its probably best to not use the first one, whcih usually starts as master, so we take the second (last one would also be ok)
64
+ var backupHostIndex = (mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.architecture) === "replicaset" && mongodbConfig.replicaCount && mongodbConfig.replicaCount > 1 ? 1 : 0;
65
+ hostToBackup = getMongodbReplicasetHost(context, backupHostIndex);
66
+ pvcToBackup = "datadir-".concat(fullAppName, "-mongodb-").concat(backupHostIndex);
67
+ } else {
68
+ hostToBackup = getMongodbStandaloneHost(context);
69
+ pvcToBackup = "".concat(fullAppName, "-mongodb");
70
+ }
71
+ return {
72
+ enabled: backupEnabled,
73
+ hostToBackup: hostToBackup,
74
+ pvcToBackup: pvcToBackup,
75
+ image: "mrelite/kubectlmongoshell:v1.0",
76
+ schedule: "0 4 * * *",
77
+ volumeSnapshotClass: "snapshotclass"
78
+ };
79
+ };
6
80
  var createMongodbBaseConfig = function (context) {
81
+ var _a, _b;
82
+ if (!(0, __1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
83
+ throw new Error("can only create mongodb base config on supported deploys");
84
+ }
85
+ var mongodbConfig = (_a = context.componentConfig.deploy.values) === null || _a === void 0 ? void 0 : _a.mongodb;
7
86
  return {
8
87
  mongodb: {
9
88
  enabled: true,
10
- backup: {
11
- enabled: ["prod", "stage"].includes(context.environment.envType)
12
- }
89
+ auth: {
90
+ enabled: true,
91
+ rootPassword: "$" + (0, __1.getSecretVarNameForContext)(context, "MONGODB_ROOT_PASSWORD"),
92
+ replicaSetKey: "$" + (0, __1.getSecretVarNameForContext)(context, "MONGODB_REPLICASET_KEY")
93
+ },
94
+ persistence: {
95
+ storageClass: "standard-rwo"
96
+ },
97
+ backup: createMongoBackupDefaultConfig(context)
13
98
  },
14
- "mongodb-replicaset": {
15
- replicas: 1,
16
- persistentVolume: {
17
- storageClass: "standard"
18
- }
99
+ env: {
100
+ secret: __assign({
101
+ MONGO_URL: createMongodbUrl(context, (_b = mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.dbName) !== null && _b !== void 0 ? _b : "app")
102
+ }, (mongodbConfig === null || mongodbConfig === void 0 ? void 0 : mongodbConfig.architecture) === "replicaset" ? {
103
+ MONGO_OPLOG_URL: createMongodbUrl(context, "local")
104
+ } // oplog only works with replicasets
105
+ : {})
19
106
  }
20
107
  };
21
108
  };
22
-
23
109
  exports.createMongodbBaseConfig = createMongodbBaseConfig;
@@ -9,36 +9,30 @@ export declare const processSecretsAsFiles: <T extends {
9
9
  projectId?: string | undefined;
10
10
  region?: string | undefined;
11
11
  } | undefined;
12
- mongodb?: ({
13
- enabled: boolean;
14
- } & Record<string, unknown>) | undefined;
12
+ mongodb?: import("../types").DeployConfigMongodb | undefined;
15
13
  mailhog?: {
16
14
  enabled: boolean;
17
15
  } | undefined;
18
- jobs?: Record<string, {
16
+ jobs?: Record<string, false | import("../types/base").AllowUnknownProps<{
19
17
  command: string;
20
- } & Record<string, unknown>> | undefined;
21
- cronjobs?: Record<string, {
18
+ hook?: string | undefined;
19
+ }>> | undefined;
20
+ cronjobs?: Record<string, false | import("../types/base").AllowUnknownProps<{
22
21
  schedule: string;
23
22
  command: string;
24
23
  concurrencyPolicy?: "Forbid" | "Allow" | "Replace" | undefined;
25
- } & Record<string, unknown>> | undefined;
26
- application?: ({
27
- redirects?: ({
24
+ }>> | undefined;
25
+ application?: false | import("../types/base").AllowUnknownProps<{
26
+ command?: string | undefined;
27
+ enabled?: boolean | undefined;
28
+ redirects?: import("../types/base").AllowUnknownProps<{
28
29
  host: string;
29
- } & Record<string, unknown>)[] | undefined;
30
+ }>[] | undefined;
31
+ hostAliases?: string[] | undefined;
30
32
  replicas?: number | undefined;
31
33
  autoscale?: import("../types").KubernetesAutoscale | undefined;
32
- resources?: {
33
- limits?: {
34
- cpu?: string | undefined;
35
- memory?: string | undefined;
36
- } | undefined;
37
- requests?: {
38
- cpu?: string | undefined;
39
- memory?: string | undefined;
40
- } | undefined;
41
- } | undefined;
34
+ updateStrategy?: import("../types").KubernetesUpdateStrategy | undefined;
35
+ resources?: import("../types").KubernetesResourcesDef | undefined;
42
36
  healthRoute?: string | undefined;
43
37
  startupProbe?: {
44
38
  httpGet?: {
@@ -82,6 +76,16 @@ export declare const processSecretsAsFiles: <T extends {
82
76
  successThreshold?: number | undefined;
83
77
  } | undefined;
84
78
  } | undefined;
85
- } & Record<string, unknown>) | undefined;
79
+ worker?: import("../types").KubernetesWorkerDef | undefined;
80
+ jobDefaults?: {
81
+ resources: import("../types").KubernetesResourcesDef;
82
+ } | undefined;
83
+ }> | undefined;
84
+ secretsFromOtherComponent?: {
85
+ [envVar: string]: string;
86
+ } | undefined;
87
+ mapServiceUrlToEnv?: {
88
+ [envVar: string]: string;
89
+ } | undefined;
86
90
  secretsAsFile?: string[] | undefined;
87
91
  } & Record<string, unknown>>(values: T) => T;
@@ -4,29 +4,22 @@ var __assign = this && this.__assign || function () {
4
4
  __assign = Object.assign || function (t) {
5
5
  for (var s, i = 1, n = arguments.length; i < n; i++) {
6
6
  s = arguments[i];
7
-
8
7
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9
8
  }
10
-
11
9
  return t;
12
10
  };
13
-
14
11
  return __assign.apply(this, arguments);
15
12
  };
16
-
17
13
  exports.__esModule = true;
18
14
  exports.processSecretsAsFiles = void 0;
19
-
20
15
  var lodash_1 = require("lodash");
21
-
22
16
  var processSecretsAsFiles = function (values) {
23
17
  if (!values.secretsAsFile || values.secretsAsFile.length === 0) {
24
18
  return values;
25
- } // the initial idea was that we "shadow" secrets that we mount as files,
19
+ }
20
+ // the initial idea was that we "shadow" secrets that we mount as files,
26
21
  // but there is a weird kubernetes issue with that (https://github.com/kubernetes/kubernetes/issues/46861),
27
22
  // so instead we rename the secrets and append _content, so that inside kuberentes, we can use the original name to contain the path and name+_content as the actual content
28
-
29
-
30
23
  return __assign(__assign({}, values), {
31
24
  env: __assign(__assign({}, values.env), {
32
25
  secret: __assign(__assign({}, (0, lodash_1.omit)(values.env.secret, values.secretsAsFile)), Object.fromEntries(values.secretsAsFile.map(function (key) {
@@ -35,5 +28,4 @@ var processSecretsAsFiles = function (values) {
35
28
  })
36
29
  });
37
30
  };
38
-
39
31
  exports.processSecretsAsFiles = processSecretsAsFiles;
@@ -0,0 +1,14 @@
1
+ export declare type DeployConfigBase = {
2
+ /**
3
+ * whether to deploy automatically or manual. If not defined, these rules apply:
4
+ * - prod: manual
5
+ * - all other envs: auto
6
+ */
7
+ when?: "manual" | "auto";
8
+ /**
9
+ * EXPERIMENTAL
10
+ * wait for other components to deploy first, before doing this deployment
11
+ */
12
+ waitFor?: string[];
13
+ };
14
+ export declare type AllowUnknownProps<T extends Record<string, unknown>> = T & Record<string, unknown>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
@@ -0,0 +1,33 @@
1
+ import type { GitlabJobImage } from "../../types";
2
+ import type { CatladderJob } from "../../types/jobs";
3
+ import type { DeployConfigBase } from "./base";
4
+ export declare type DeployConfigCustom = {
5
+ /**
6
+ * custom deploy types allow you to specify custom commands to deploy your app
7
+ */
8
+ type: "custom";
9
+ /**
10
+ * whether the deploy script requires a docker image to be built
11
+ */
12
+ requiresDocker: boolean;
13
+ /**
14
+ * whether your custom script requires yarn install
15
+ */
16
+ requiresYarnInstall?: boolean;
17
+ /**
18
+ * your custom script
19
+ */
20
+ script: string[];
21
+ /**
22
+ * script to run to stop the environment
23
+ */
24
+ stopScript?: string[];
25
+ /**
26
+ * image to use
27
+ */
28
+ jobImage?: GitlabJobImage;
29
+ /**
30
+ * customize cache for the job
31
+ */
32
+ jobCache?: CatladderJob["cache"];
33
+ } & DeployConfigBase;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
@@ -0,0 +1,10 @@
1
+ import type { DeployConfigBase } from "./base";
2
+ export declare type DeployConfigDockerTag = {
3
+ /**
4
+ * adds a custom tag on the repo to deploy it.
5
+ *
6
+ * only used in veloplus atm, generally not recommended to use
7
+ */
8
+ type: "dockerTag";
9
+ tag: string;
10
+ } & DeployConfigBase;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
@@ -0,0 +1,121 @@
1
+ import type { DeployConfigBase } from "./base";
2
+ export declare type Gcloudregion = "asia-east1" | "asia-northeast1" | "asia-northeast2" | "europe-north1" | "europe-southwest1" | "europe-west1" | "europe-west4" | "europe-west8" | "europe-west9" | "me-west1" | "us-central1" | "us-east1" | "us-east4" | "us-east5" | "us-south1" | "us-west1" | "asia-east2" | "asia-northeast3" | "asia-southeast1" | "asia-southeast2" | "asia-south1" | "asia-south2" | "australia-southeast1" | "australia-southeast2" | "europe-central2" | "europe-west2" | "europe-west3" | "europe-west6" | "northamerica-northeast1" | "northamerica-northeast2" | "southamerica-east1" | "southamerica-west1" | "us-west2" | "us-west3" | "us-west4";
3
+ export declare type DeployConfigCloudRunCloudSql = {
4
+ type: "unmanaged";
5
+ instanceConnectionName: string;
6
+ /**
7
+ * the database username, defaults to "postgres"
8
+ */
9
+ dbUser?: string;
10
+ /**
11
+ * the prefix of the database, the full db name is this plus the environment slug prefix plus the componentName
12
+ *
13
+ * defaults to customerName-appName
14
+ */
15
+ dbNamePrefix?: string | false;
16
+ /**
17
+ * the base name of the db, defaults to the componentName
18
+ */
19
+ dbBaseName?: string;
20
+ /**
21
+ * whether to delete the database if the environment is stopped
22
+ * defaults to true for review envs, to false for every other environment
23
+ */
24
+ deleteDatabaseOnStop?: boolean;
25
+ /**
26
+ * add additional query params to the database connection string
27
+ */
28
+ dbAdditionalQueryParams?: Record<string, string | number> & {
29
+ /**
30
+ * set to 0 for prisma in review or dev apps where you reset the db occasionally without restarting any server
31
+ */
32
+ statement_cache_size?: number;
33
+ };
34
+ };
35
+ declare type Memory = `${number}${"M" | "G" | "Mi" | "Gi"}`;
36
+ export declare type DeployConfigCloudRunService = {
37
+ /**
38
+ * command / entrypoint, fallsback to buildConfig.startcommand
39
+ */
40
+ command?: string;
41
+ /**
42
+ * how many instances to keep around when there are no requests. defaults to 0.
43
+ * Set to 1 for workers
44
+ */
45
+ minInstances?: number;
46
+ /**
47
+ * maximum amount of instances. Defaults to 100
48
+ */
49
+ maxInstances?: number;
50
+ /**
51
+ * set to true to allways allocate cpu, e.g. for workers. Careful that this is expensive!
52
+ */
53
+ noCpuThrottling?: true;
54
+ /**
55
+ * whether to allow public access (defaults to true)
56
+ */
57
+ allowUnauthenticated?: boolean;
58
+ /**
59
+ * memory limit. Defaults to 512MB
60
+ */
61
+ memory?: Memory;
62
+ };
63
+ export declare type DeployConfigCloudRunJobBase = {
64
+ /**
65
+ * command
66
+ */
67
+ command: string;
68
+ /**
69
+ * memory limit of the job, defaults to 51Mi
70
+ */
71
+ memory?: `${number}${"M" | "G" | "Mi" | "Gi"}`;
72
+ };
73
+ declare type Minute = string;
74
+ declare type Hour = string;
75
+ declare type DayOfMonth = string;
76
+ declare type DayOfWeek = string;
77
+ declare type Month = string;
78
+ export declare type DeployConfigCloudRunJobWithSchedule = DeployConfigCloudRunJobBase & {
79
+ when: "schedule";
80
+ schedule: `${Minute} ${Hour} ${DayOfMonth} ${Month} ${DayOfWeek}`;
81
+ };
82
+ export declare type DeployConfigCloudRunJobNormal = DeployConfigCloudRunJobBase & {
83
+ when: "manual" | "preDeploy" | "postDeploy";
84
+ };
85
+ export declare type DeployConfigCloudRunJob = DeployConfigCloudRunJobNormal | DeployConfigCloudRunJobWithSchedule;
86
+ export declare type DeployConfigCloudRun = {
87
+ /**
88
+ * EXPERIMENTAL cloud run deployment.
89
+ *
90
+ * This will deploy a cloud run service.
91
+ *
92
+ * Requires that cloud run is enabled on the project, as well as cloud run api and artifacts registry.
93
+ */
94
+ type: "google-cloudrun";
95
+ /**
96
+ * the google cloud porject id
97
+ */
98
+ projectId: string;
99
+ /**
100
+ * the region. Set to europe-west6 for switzerland
101
+ */
102
+ region: Gcloudregion;
103
+ /**
104
+ * whether to enable the service, defaults to true
105
+ */
106
+ service?: boolean | DeployConfigCloudRunService;
107
+ /**
108
+ * deploy additional services with different entry pointss
109
+ */
110
+ additionalServices?: {
111
+ [name: string]: DeployConfigCloudRunService;
112
+ };
113
+ jobs?: {
114
+ [name: string]: DeployConfigCloudRunJob | false | null;
115
+ };
116
+ /**
117
+ * add cloudSql
118
+ */
119
+ cloudSql?: DeployConfigCloudRunCloudSql | false;
120
+ } & DeployConfigBase;
121
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
@@ -0,0 +1,22 @@
1
+ import type { DeployConfigCustom } from "./custom";
2
+ import type { DeployConfigDockerTag } from "./dockerTag";
3
+ import type { DeployConfigCloudRun } from "./googleCloudRun";
4
+ import type { DeployConfigKubernetes } from "./kubernetes";
5
+ export * from "./custom";
6
+ export * from "./googleCloudRun";
7
+ export * from "./kubernetes";
8
+ export * from "./dockerTag";
9
+ export declare type DeployConfig = DeployConfigKubernetes | DeployConfigCustom | DeployConfigCloudRun | DeployConfigDockerTag;
10
+ export declare type DeployConfigType = DeployConfig["type"];
11
+ export declare type DeployConfigGeneric<T extends DeployConfigType> = Extract<DeployConfig, {
12
+ type: T;
13
+ }>;
14
+ export declare const isOfDeployType: <T extends ("custom" | "dockerTag" | "google-cloudrun" | "kubernetes")[]>(t: DeployConfig | false, ...types: T) => t is Extract<DeployConfigCustom, {
15
+ type: T[number];
16
+ }> | Extract<DeployConfigDockerTag, {
17
+ type: T[number];
18
+ }> | Extract<DeployConfigCloudRun, {
19
+ type: T[number];
20
+ }> | Extract<DeployConfigKubernetes, {
21
+ type: T[number];
22
+ }>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ Object.defineProperty(o, k2, {
6
+ enumerable: true,
7
+ get: function () {
8
+ return m[k];
9
+ }
10
+ });
11
+ } : function (o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ });
15
+ var __exportStar = this && this.__exportStar || function (m, exports) {
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
+ };
18
+ exports.__esModule = true;
19
+ exports.isOfDeployType = void 0;
20
+ __exportStar(require("./custom"), exports);
21
+ __exportStar(require("./googleCloudRun"), exports);
22
+ __exportStar(require("./kubernetes"), exports);
23
+ __exportStar(require("./dockerTag"), exports);
24
+ var isOfDeployType = function (t) {
25
+ var types = [];
26
+ for (var _i = 1; _i < arguments.length; _i++) {
27
+ types[_i - 1] = arguments[_i];
28
+ }
29
+ return t && types.includes(t.type);
30
+ };
31
+ exports.isOfDeployType = isOfDeployType;