@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,13 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getEnvType = void 0;
5
+ var types_1 = require("../types");
6
+ var getEnvType = function (env, envConfig) {
7
+ if (envConfig.type) return envConfig.type;
8
+ if ((0, types_1.isKnowEnvType)(env)) {
9
+ return env;
10
+ }
11
+ throw new Error("unknown env type: " + env);
12
+ };
13
+ exports.getEnvType = getEnvType;
@@ -0,0 +1,3 @@
1
+ import type { Config } from "../types/config";
2
+ import type { CommitInfo, Environment } from "../types/context";
3
+ export declare const getEnvironment: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined) => Promise<Environment>;
@@ -6,7 +6,6 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
6
6
  resolve(value);
7
7
  });
8
8
  }
9
-
10
9
  return new (P || (P = Promise))(function (resolve, reject) {
11
10
  function fulfilled(value) {
12
11
  try {
@@ -15,7 +14,6 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
15
14
  reject(e);
16
15
  }
17
16
  }
18
-
19
17
  function rejected(value) {
20
18
  try {
21
19
  step(generator["throw"](value));
@@ -23,29 +21,26 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
23
21
  reject(e);
24
22
  }
25
23
  }
26
-
27
24
  function step(result) {
28
25
  result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29
26
  }
30
-
31
27
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
28
  });
33
29
  };
34
-
35
30
  var __generator = this && this.__generator || function (thisArg, body) {
36
31
  var _ = {
37
- label: 0,
38
- sent: function () {
39
- if (t[0] & 1) throw t[1];
40
- return t[1];
32
+ label: 0,
33
+ sent: function () {
34
+ if (t[0] & 1) throw t[1];
35
+ return t[1];
36
+ },
37
+ trys: [],
38
+ ops: []
41
39
  },
42
- trys: [],
43
- ops: []
44
- },
45
- f,
46
- y,
47
- t,
48
- g;
40
+ f,
41
+ y,
42
+ t,
43
+ g;
49
44
  return g = {
50
45
  next: verb(0),
51
46
  "throw": verb(1),
@@ -53,78 +48,59 @@ var __generator = this && this.__generator || function (thisArg, body) {
53
48
  }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
54
49
  return this;
55
50
  }), g;
56
-
57
51
  function verb(n) {
58
52
  return function (v) {
59
53
  return step([n, v]);
60
54
  };
61
55
  }
62
-
63
56
  function step(op) {
64
57
  if (f) throw new TypeError("Generator is already executing.");
65
-
66
58
  while (_) try {
67
59
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
68
60
  if (y = 0, t) op = [op[0] & 2, t.value];
69
-
70
61
  switch (op[0]) {
71
62
  case 0:
72
63
  case 1:
73
64
  t = op;
74
65
  break;
75
-
76
66
  case 4:
77
67
  _.label++;
78
68
  return {
79
69
  value: op[1],
80
70
  done: false
81
71
  };
82
-
83
72
  case 5:
84
73
  _.label++;
85
74
  y = op[1];
86
75
  op = [0];
87
76
  continue;
88
-
89
77
  case 7:
90
78
  op = _.ops.pop();
91
-
92
79
  _.trys.pop();
93
-
94
80
  continue;
95
-
96
81
  default:
97
82
  if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
98
83
  _ = 0;
99
84
  continue;
100
85
  }
101
-
102
86
  if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
103
87
  _.label = op[1];
104
88
  break;
105
89
  }
106
-
107
90
  if (op[0] === 6 && _.label < t[1]) {
108
91
  _.label = t[1];
109
92
  t = op;
110
93
  break;
111
94
  }
112
-
113
95
  if (t && _.label < t[2]) {
114
96
  _.label = t[2];
115
-
116
97
  _.ops.push(op);
117
-
118
98
  break;
119
99
  }
120
-
121
100
  if (t[2]) _.ops.pop();
122
-
123
101
  _.trys.pop();
124
-
125
102
  continue;
126
103
  }
127
-
128
104
  op = body.call(thisArg, _);
129
105
  } catch (e) {
130
106
  op = [6, e];
@@ -132,7 +108,6 @@ var __generator = this && this.__generator || function (thisArg, body) {
132
108
  } finally {
133
109
  f = t = 0;
134
110
  }
135
-
136
111
  if (op[0] & 5) throw op[1];
137
112
  return {
138
113
  value: op[0] ? op[1] : void 0,
@@ -140,55 +115,38 @@ var __generator = this && this.__generator || function (thisArg, body) {
140
115
  };
141
116
  }
142
117
  };
143
-
144
118
  exports.__esModule = true;
145
-
146
- var createChildPipeline_1 = require("./createChildPipeline");
147
-
148
- describe("createChildPipeline", function () {
149
- describe("node-app to kuberntes", function () {
150
- var config = {
151
- appName: "test",
152
- customerName: "pan",
153
- components: {
154
- "my-app": {
155
- dir: "myapp",
156
- build: {
157
- type: "node"
158
- },
159
- deploy: {
160
- type: "kubernetes",
161
- cluster: {
162
- type: "gcloud",
163
- name: "mega-cluster",
164
- projectId: "super-google-project",
165
- region: "ch-blabla"
166
- }
167
- }
168
- }
119
+ exports.getEnvironment = void 0;
120
+ var getEnvironmentContext_1 = require("./getEnvironmentContext");
121
+ var getEnvironmentVariables_1 = require("./getEnvironmentVariables");
122
+ var getEnvironment = function (config, componentName, env, commitInfo) {
123
+ return __awaiter(void 0, void 0, void 0, function () {
124
+ var _a, envVars, secretEnvVarKeys, host, url, envContext, envType;
125
+ return __generator(this, function (_b) {
126
+ switch (_b.label) {
127
+ case 0:
128
+ return [4 /*yield*/, (0, getEnvironmentVariables_1.getEnvironmentVariables)(config, componentName, env, commitInfo)];
129
+ case 1:
130
+ _a = _b.sent(), envVars = _a.envVars, secretEnvVarKeys = _a.secretEnvVarKeys, host = _a.host, url = _a.url;
131
+ envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
132
+ envType = envContext.envType;
133
+ return [2 /*return*/, {
134
+ envType: envType,
135
+ host: host,
136
+ url: url,
137
+ gitlabEnvironment: {
138
+ name: envContext.gitlabEnvironmentName,
139
+ url: url
140
+ },
141
+ fullName: envContext.fullName,
142
+ slugPrefix: envContext.environmentSlugPrefix,
143
+ slug: envContext.environmentSlug,
144
+ shortName: env,
145
+ envVars: envVars,
146
+ secretEnvVarKeys: secretEnvVarKeys
147
+ }];
169
148
  }
170
- };
171
- it("creates a pipeline for a single app on the main branch", function () {
172
- return __awaiter(void 0, void 0, void 0, function () {
173
- var _a, image, jobs;
174
-
175
- return __generator(this, function (_b) {
176
- switch (_b.label) {
177
- case 0:
178
- return [4
179
- /*yield*/
180
- , (0, createChildPipeline_1.createChildPipeline)("gitlab", "mainBranch", config)];
181
-
182
- case 1:
183
- _a = _b.sent(), image = _a.image, jobs = _a.jobs;
184
- expect(image).toEqual("git.panter.ch:5001/catladder/catladder/base-pipeline:");
185
- expect(Object.keys(jobs)).toEqual(["my-app audit", "my-app lint", "my-app test", "dev my-app app-build", "dev my-app docker-build", "dev my-app deploy-to-kubernetes", "dev my-app kubernetes-stop"]);
186
- return [2
187
- /*return*/
188
- ];
189
- }
190
- });
191
- });
192
149
  });
193
150
  });
194
- });
151
+ };
152
+ exports.getEnvironment = getEnvironment;
@@ -0,0 +1,4 @@
1
+ import type { Config } from "../types/config";
2
+ import type { CommitInfo } from "../types/context";
3
+ import type { EnvironmentContext } from "../types/environmentContext";
4
+ export declare const getEnvironmentContext: (config: Config, env: string, componentName: string, commitInfo?: CommitInfo | undefined) => EnvironmentContext<any, any>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getEnvironmentContext = void 0;
5
+ var getEnvConfig_1 = require("./getEnvConfig");
6
+ var getEnvType_1 = require("./getEnvType");
7
+ var getEnvironmentSlugPrefix = function (envConfig, env, commitInfo) {
8
+ var envType = (0, getEnvType_1.getEnvType)(env, envConfig);
9
+ return envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug) : "".concat(env);
10
+ };
11
+ var getEnvironmentContext = function (config, env, componentName, commitInfo) {
12
+ var envConfigRaw = (0, getEnvConfig_1.getEnvConfig)(config, componentName, env);
13
+ var envType = (0, getEnvType_1.getEnvType)(env, envConfigRaw);
14
+ var environmentSlugPrefix = getEnvironmentSlugPrefix(envConfigRaw, env, commitInfo);
15
+ var environmentSlug = "".concat(environmentSlugPrefix, "-").concat(componentName);
16
+ var gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
17
+ var fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
18
+ return {
19
+ envConfigRaw: envConfigRaw,
20
+ deployConfigRaw: envConfigRaw.deploy,
21
+ buildConfigRaw: envConfigRaw.build,
22
+ environmentSlugPrefix: environmentSlugPrefix,
23
+ environmentSlug: environmentSlug,
24
+ gitlabEnvironmentName: gitlabEnvironmentName,
25
+ fullName: fullName,
26
+ envType: envType,
27
+ commitInfo: commitInfo,
28
+ componentName: componentName,
29
+ env: env,
30
+ fullConfig: config
31
+ };
32
+ };
33
+ exports.getEnvironmentContext = getEnvironmentContext;
@@ -0,0 +1,10 @@
1
+ import type { CommitInfo, Context } from "../types";
2
+ import type { Config } from "../types/config";
3
+ export declare const getEnvironmentVariables: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, alreadyVisited?: Record<string, Record<string, boolean>>) => Promise<{
4
+ envVars: Record<string, string>;
5
+ secretEnvVarKeys: string[];
6
+ host: string;
7
+ url: string;
8
+ }>;
9
+ export declare const getSecretVarName: (env: string, componentName: string, key: string) => string;
10
+ export declare const getSecretVarNameForContext: (context: Context, key: string) => string;
@@ -0,0 +1,260 @@
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 __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) {
15
+ return value instanceof P ? value : new P(function (resolve) {
16
+ resolve(value);
17
+ });
18
+ }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) {
21
+ try {
22
+ step(generator.next(value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ }
27
+ function rejected(value) {
28
+ try {
29
+ step(generator["throw"](value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ }
34
+ function step(result) {
35
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
36
+ }
37
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
38
+ });
39
+ };
40
+ var __generator = this && this.__generator || function (thisArg, body) {
41
+ var _ = {
42
+ label: 0,
43
+ sent: function () {
44
+ if (t[0] & 1) throw t[1];
45
+ return t[1];
46
+ },
47
+ trys: [],
48
+ ops: []
49
+ },
50
+ f,
51
+ y,
52
+ t,
53
+ g;
54
+ return g = {
55
+ next: verb(0),
56
+ "throw": verb(1),
57
+ "return": verb(2)
58
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
59
+ return this;
60
+ }), g;
61
+ function verb(n) {
62
+ return function (v) {
63
+ return step([n, v]);
64
+ };
65
+ }
66
+ function step(op) {
67
+ if (f) throw new TypeError("Generator is already executing.");
68
+ while (_) try {
69
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
70
+ if (y = 0, t) op = [op[0] & 2, t.value];
71
+ switch (op[0]) {
72
+ case 0:
73
+ case 1:
74
+ t = op;
75
+ break;
76
+ case 4:
77
+ _.label++;
78
+ return {
79
+ value: op[1],
80
+ done: false
81
+ };
82
+ case 5:
83
+ _.label++;
84
+ y = op[1];
85
+ op = [0];
86
+ continue;
87
+ case 7:
88
+ op = _.ops.pop();
89
+ _.trys.pop();
90
+ continue;
91
+ default:
92
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
93
+ _ = 0;
94
+ continue;
95
+ }
96
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
97
+ _.label = op[1];
98
+ break;
99
+ }
100
+ if (op[0] === 6 && _.label < t[1]) {
101
+ _.label = t[1];
102
+ t = op;
103
+ break;
104
+ }
105
+ if (t && _.label < t[2]) {
106
+ _.label = t[2];
107
+ _.ops.push(op);
108
+ break;
109
+ }
110
+ if (t[2]) _.ops.pop();
111
+ _.trys.pop();
112
+ continue;
113
+ }
114
+ op = body.call(thisArg, _);
115
+ } catch (e) {
116
+ op = [6, e];
117
+ y = 0;
118
+ } finally {
119
+ f = t = 0;
120
+ }
121
+ if (op[0] & 5) throw op[1];
122
+ return {
123
+ value: op[0] ? op[1] : void 0,
124
+ done: true
125
+ };
126
+ }
127
+ };
128
+ var __read = this && this.__read || function (o, n) {
129
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
130
+ if (!m) return o;
131
+ var i = m.call(o),
132
+ r,
133
+ ar = [],
134
+ e;
135
+ try {
136
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
137
+ } catch (error) {
138
+ e = {
139
+ error: error
140
+ };
141
+ } finally {
142
+ try {
143
+ if (r && !r.done && (m = i["return"])) m.call(i);
144
+ } finally {
145
+ if (e) throw e.error;
146
+ }
147
+ }
148
+ return ar;
149
+ };
150
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
151
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
152
+ if (ar || !(i in from)) {
153
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
154
+ ar[i] = from[i];
155
+ }
156
+ }
157
+ return to.concat(ar || Array.prototype.slice.call(from));
158
+ };
159
+ exports.__esModule = true;
160
+ exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironmentVariables = void 0;
161
+ var lodash_1 = require("lodash");
162
+ var deploy_1 = require("../deploy");
163
+ var getEnvironmentContext_1 = require("./getEnvironmentContext");
164
+ var resolveReferences_1 = require("./resolveReferences");
165
+ var getEnvironmentVariables = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
166
+ ) {
167
+ if (alreadyVisited === void 0) {
168
+ alreadyVisited = {};
169
+ }
170
+ return __awaiter(void 0, void 0, void 0, function () {
171
+ var environmentContext, envConfigRaw, deployConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
172
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
173
+ return __generator(this, function (_k) {
174
+ switch (_k.label) {
175
+ case 0:
176
+ environmentContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
177
+ envConfigRaw = environmentContext.envConfigRaw, deployConfigRaw = environmentContext.deployConfigRaw, envType = environmentContext.envType;
178
+ basePredefinedVariables = {
179
+ ENV_SHORT: env,
180
+ APP_DIR: envConfigRaw.dir,
181
+ ENV_TYPE: envType
182
+ };
183
+ if (envType === "local") {
184
+ devLocalConfig = envConfigRaw;
185
+ port = (_a = devLocalConfig.port) !== null && _a !== void 0 ? _a : 3000;
186
+ host = "localhost:" + port;
187
+ url = "http://" + host;
188
+ predefinedVariables = {
189
+ ENV_SHORT: "local",
190
+ ROOT_URL: url,
191
+ PORT: port.toString()
192
+ };
193
+ } else {
194
+ additionalEnvVars = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext) : {};
195
+ host = (_c = (_b = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _b !== void 0 ? _b : additionalEnvVars.HOST_CANONICAL) !== null && _c !== void 0 ? _c : "unknown-host.example.com";
196
+ url = "https://".concat(host);
197
+ predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), config.components[componentName].build.type === "rails" ? {} : {
198
+ HOST: host
199
+ }), {
200
+ ROOT_URL: url
201
+ }), additionalEnvVars);
202
+ }
203
+ publicEnvVarsRaw = (_e = (_d = envConfigRaw.vars) === null || _d === void 0 ? void 0 : _d.public) !== null && _e !== void 0 ? _e : {};
204
+ additionalSecretKeys = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(environmentContext) : [];
205
+ secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_g = (_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.secret) !== null && _g !== void 0 ? _g : []), false), __read(additionalSecretKeys), false);
206
+ secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
207
+ return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
208
+ }));
209
+ legacyFromComponents = (_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.fromComponents) !== null && _j !== void 0 ? _j : {};
210
+ publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
211
+ publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
212
+ var _b = __read(_a, 2),
213
+ key = _b[0],
214
+ value = _b[1];
215
+ return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
216
+ }));
217
+ envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
218
+ return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, alreadyVisited) {
219
+ return __awaiter(void 0, void 0, void 0, function () {
220
+ var otherEnvVars;
221
+ return __generator(this, function (_a) {
222
+ switch (_a.label) {
223
+ case 0:
224
+ return [4 /*yield*/, (0, exports.getEnvironmentVariables)(config, otherComponentName, env, commitInfo, alreadyVisited)];
225
+ case 1:
226
+ otherEnvVars = _a.sent().envVars;
227
+ return [2 /*return*/, otherEnvVars];
228
+ }
229
+ });
230
+ });
231
+ }, alreadyVisited)];
232
+ case 1:
233
+ envVars = _k.sent();
234
+ return [2 /*return*/, {
235
+ envVars: envVars,
236
+ secretEnvVarKeys: secretEnvVarKeys,
237
+ host: host,
238
+ url: url
239
+ }];
240
+ }
241
+ });
242
+ });
243
+ };
244
+ exports.getEnvironmentVariables = getEnvironmentVariables;
245
+ var sanitizeForEnVar = function (s) {
246
+ return s.replace(/-/g, "_");
247
+ };
248
+ var getSecretVarName = function (env, componentName, key) {
249
+ return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
250
+ }; // remove dash from component name
251
+ exports.getSecretVarName = getSecretVarName;
252
+ var addIndexVar = function (vars) {
253
+ return __assign(__assign({}, vars), {
254
+ _ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars))
255
+ });
256
+ };
257
+ var getSecretVarNameForContext = function (context, key) {
258
+ return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
259
+ };
260
+ exports.getSecretVarNameForContext = getSecretVarNameForContext;
@@ -0,0 +1,8 @@
1
+ import type { Context } from "../types";
2
+ export declare const getLabels: (context: Context) => {
3
+ "customer-name": string | undefined;
4
+ "app-name": string | undefined;
5
+ "env-type": string | undefined;
6
+ "env-name": string | undefined;
7
+ "build-type": string | undefined;
8
+ };
@@ -0,0 +1,38 @@
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 __importDefault = this && this.__importDefault || function (mod) {
14
+ return mod && mod.__esModule ? mod : {
15
+ "default": mod
16
+ };
17
+ };
18
+ exports.__esModule = true;
19
+ exports.getLabels = void 0;
20
+ var slugify_1 = __importDefault(require("slugify"));
21
+ var sanitize = function (value) {
22
+ if (!value) return value;
23
+ //"The value can only contain lowercase letters, numeric characters, underscores and dashes. The value can be at most 63 characters long. International characters are allowed."
24
+ // slugify should do the job
25
+ return (0, slugify_1["default"])(value).toLowerCase();
26
+ };
27
+ var getLabels = function (context) {
28
+ var _a, _b, _c;
29
+ var labels = __assign({
30
+ "customer-name": sanitize(context.fullConfig.customerName),
31
+ "app-name": sanitize(context.fullConfig.appName),
32
+ "env-type": sanitize(context.environment.envType),
33
+ "env-name": sanitize(context.environment.shortName),
34
+ "build-type": sanitize((_a = context.componentConfig.build) === null || _a === void 0 ? void 0 : _a.type)
35
+ }, (_c = (_b = context.fullConfig.meta) === null || _b === void 0 ? void 0 : _b.labels) !== null && _c !== void 0 ? _c : {});
36
+ return labels;
37
+ };
38
+ exports.getLabels = getLabels;
@@ -1,6 +1,5 @@
1
- import { Config } from "../types/config";
2
- import { CommitInfo, Context, Environment } from "../types/context";
3
- export declare const getSecretVarName: (env: string, componentName: string, key: string) => string;
4
- export declare const getSecretVarNameForContext: (context: Context, key: string) => string;
5
- export declare const getEnvironment: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, alreadyVisited?: Record<string, Record<string, boolean>>) => Environment;
6
- export declare const createContext: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, packageManagerInfo?: import("../types/context").YarnPackageManagerInfo | undefined) => Context;
1
+ import type { Config } from "../types/config";
2
+ import type { CommitInfo, Context } from "../types/context";
3
+ export * from "./getEnvironment";
4
+ export * from "./getEnvironmentVariables";
5
+ export declare const createContext: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, packageManagerInfo?: import("../types/context").YarnPackageManagerInfo | undefined) => Promise<Context>;