@catladder/pipeline 0.0.0-node16-ddfae617 → 0.0.0-refactor-env-context-9e652b63

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 (175) hide show
  1. package/bin/catladder-gitlab.js +1 -1
  2. package/dist/build/base/createBuildJob.d.ts +2 -2
  3. package/dist/build/base/getBuildInfo.d.ts +1 -1
  4. package/dist/build/docker.d.ts +44 -6
  5. package/dist/build/docker.js +45 -19
  6. package/dist/build/index.d.ts +6 -5
  7. package/dist/build/node/buildJob.d.ts +2 -2
  8. package/dist/build/node/cache.d.ts +2 -2
  9. package/dist/build/node/index.d.ts +1 -1
  10. package/dist/build/node/meteor.d.ts +1 -1
  11. package/dist/build/node/meteor.js +6 -0
  12. package/dist/build/node/testJob.d.ts +2 -2
  13. package/dist/build/node/testJob.js +3 -0
  14. package/dist/build/node/yarn.d.ts +1 -1
  15. package/dist/build/node/yarn.js +13 -1
  16. package/dist/build/types.d.ts +10 -0
  17. package/dist/bundles/catladder-gitlab/index.js +32457 -0
  18. package/dist/catladder-gitlab.js +1 -2
  19. package/dist/config/configruedEnvs.d.ts +1 -1
  20. package/dist/config/readConfig.d.ts +1 -1
  21. package/dist/constants.js +1 -1
  22. package/dist/context/getEnvConfig.d.ts +9 -0
  23. package/dist/context/getEnvConfig.js +26 -0
  24. package/dist/context/getEnvType.d.ts +4 -0
  25. package/dist/context/getEnvType.js +18 -0
  26. package/dist/context/getEnvironment.d.ts +3 -0
  27. package/dist/context/getEnvironment.js +187 -0
  28. package/dist/context/getEnvironmentContext.d.ts +4 -0
  29. package/dist/context/getEnvironmentContext.js +36 -0
  30. package/dist/context/getEnvironmentVariables.d.ts +10 -0
  31. package/dist/context/getEnvironmentVariables.js +322 -0
  32. package/dist/context/getLabels.d.ts +8 -0
  33. package/dist/context/getLabels.js +49 -0
  34. package/dist/context/index.d.ts +5 -6
  35. package/dist/context/index.js +176 -181
  36. package/dist/context/resolveReferences.d.ts +1 -3
  37. package/dist/context/resolveReferences.js +275 -26
  38. package/dist/context/resolveReferences.test.js +332 -81
  39. package/dist/defaults/index.d.ts +1 -1
  40. package/dist/deploy/base.d.ts +4 -2
  41. package/dist/deploy/base.js +37 -17
  42. package/dist/deploy/cloudRun/deployJob.d.ts +3 -0
  43. package/dist/deploy/cloudRun/deployJob.js +139 -0
  44. package/dist/deploy/cloudRun/index.d.ts +9 -0
  45. package/dist/deploy/cloudRun/index.js +56 -0
  46. package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -0
  47. package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +14 -0
  48. package/dist/deploy/cloudSql/index.d.ts +8 -0
  49. package/dist/deploy/cloudSql/index.js +30 -0
  50. package/dist/deploy/custom/deployJob.d.ts +2 -2
  51. package/dist/deploy/custom/deployJob.js +4 -1
  52. package/dist/deploy/custom/index.d.ts +2 -1
  53. package/dist/deploy/custom/index.js +15 -18
  54. package/dist/deploy/dockerTag/deployJob.d.ts +3 -0
  55. package/dist/deploy/dockerTag/deployJob.js +33 -0
  56. package/dist/deploy/dockerTag/index.d.ts +2 -0
  57. package/dist/deploy/dockerTag/index.js +19 -0
  58. package/dist/deploy/index.d.ts +12 -8
  59. package/dist/deploy/index.js +27 -14
  60. package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +4 -0
  61. package/dist/deploy/kubernetes/additionalSecretKeys.js +33 -0
  62. package/dist/deploy/kubernetes/cloudsql.d.ts +1 -1
  63. package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
  64. package/dist/deploy/kubernetes/deployJob.js +13 -66
  65. package/dist/deploy/kubernetes/index.d.ts +2 -1
  66. package/dist/deploy/kubernetes/index.js +45 -16
  67. package/dist/deploy/kubernetes/kubeEnv.d.ts +10 -0
  68. package/dist/deploy/kubernetes/kubeEnv.js +90 -0
  69. package/dist/deploy/kubernetes/kubeValues.d.ts +90 -0
  70. package/dist/deploy/kubernetes/kubeValues.js +96 -0
  71. package/dist/deploy/kubernetes/mongodb.d.ts +18 -5
  72. package/dist/deploy/kubernetes/mongodb.js +118 -8
  73. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +21 -21
  74. package/dist/deploy/types/base.d.ts +15 -0
  75. package/dist/deploy/types/base.js +3 -0
  76. package/dist/deploy/types/custom.d.ts +27 -0
  77. package/dist/deploy/types/custom.js +3 -0
  78. package/dist/deploy/types/dockerTag.d.ts +10 -0
  79. package/dist/deploy/types/dockerTag.js +3 -0
  80. package/dist/deploy/types/googleCloudRun.d.ts +39 -0
  81. package/dist/deploy/types/googleCloudRun.js +3 -0
  82. package/dist/deploy/types/index.d.ts +24 -0
  83. package/dist/deploy/types/index.js +41 -0
  84. package/dist/deploy/{types.d.ts → types/kubernetes.d.ts} +128 -36
  85. package/dist/deploy/types/kubernetes.js +3 -0
  86. package/dist/deploy/utils.d.ts +2 -2
  87. package/dist/deploy/utils.js +4 -0
  88. package/dist/pipeline/createChildPipeline.d.ts +2 -2
  89. package/dist/pipeline/createChildPipeline.js +3 -3
  90. package/dist/pipeline/createJobs.d.ts +2 -2
  91. package/dist/pipeline/createJobs.js +63 -25
  92. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +3 -2
  93. package/dist/pipeline/gitlab/makeGitlabJob.js +2 -1
  94. package/dist/pipeline/packageManager.d.ts +1 -1
  95. package/dist/rules/index.d.ts +1 -1
  96. package/dist/runner/index.d.ts +2 -3
  97. package/dist/tsconfig.tsbuildinfo +1 -1
  98. package/dist/types/config.d.ts +7 -6
  99. package/dist/types/config.js +1 -1
  100. package/dist/types/context.d.ts +10 -2
  101. package/dist/types/environmentContext.d.ts +22 -0
  102. package/dist/types/environmentContext.js +3 -0
  103. package/dist/types/gitlab-types.d.ts +1 -1
  104. package/dist/types/jobs.d.ts +8 -3
  105. package/dist/types/jobs.js +1 -1
  106. package/dist/types/pipeline.d.ts +1 -1
  107. package/package.json +15 -11
  108. package/scripts/bundle +2 -0
  109. package/src/build/base/createBuildJob.ts +3 -2
  110. package/src/build/base/getBuildInfo.ts +1 -1
  111. package/src/build/docker.ts +47 -29
  112. package/src/build/index.ts +8 -5
  113. package/src/build/node/buildJob.ts +2 -2
  114. package/src/build/node/cache.ts +2 -2
  115. package/src/build/node/index.ts +1 -1
  116. package/src/build/node/meteor.ts +8 -2
  117. package/src/build/node/testJob.ts +4 -2
  118. package/src/build/node/yarn.ts +21 -10
  119. package/src/build/tests/storybook.test.ts +1 -1
  120. package/src/build/types.ts +13 -1
  121. package/src/catladder-gitlab.ts +4 -2
  122. package/src/config/configruedEnvs.test.ts +2 -2
  123. package/src/config/configruedEnvs.ts +5 -4
  124. package/src/config/readConfig.ts +1 -1
  125. package/src/context/getEnvConfig.ts +21 -0
  126. package/src/context/getEnvType.ts +17 -0
  127. package/src/context/getEnvironment.ts +40 -0
  128. package/src/context/getEnvironmentContext.ts +57 -0
  129. package/src/context/getEnvironmentVariables.ts +152 -0
  130. package/src/context/getLabels.ts +20 -0
  131. package/src/context/index.ts +25 -191
  132. package/src/context/resolveReferences.test.ts +15 -15
  133. package/src/context/resolveReferences.ts +37 -30
  134. package/src/defaults/index.ts +1 -1
  135. package/src/deploy/base.ts +43 -19
  136. package/src/deploy/cloudRun/deployJob.ts +104 -0
  137. package/src/deploy/cloudRun/index.ts +48 -0
  138. package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +14 -0
  139. package/src/deploy/cloudSql/index.ts +16 -0
  140. package/src/deploy/custom/deployJob.ts +10 -3
  141. package/src/deploy/custom/index.ts +9 -1
  142. package/src/deploy/dockerTag/deployJob.ts +31 -0
  143. package/src/deploy/dockerTag/index.ts +9 -0
  144. package/src/deploy/index.ts +26 -17
  145. package/src/deploy/kubernetes/additionalSecretKeys.ts +23 -0
  146. package/src/deploy/kubernetes/cloudsql.ts +2 -1
  147. package/src/deploy/kubernetes/deployJob.ts +19 -77
  148. package/src/deploy/kubernetes/index.ts +42 -1
  149. package/src/deploy/kubernetes/kubeEnv.ts +48 -0
  150. package/src/deploy/kubernetes/kubeValues.ts +82 -0
  151. package/src/deploy/kubernetes/mongodb.ts +104 -7
  152. package/src/deploy/kubernetes/processSecretsAsFiles.ts +1 -1
  153. package/src/deploy/types/base.ts +17 -0
  154. package/src/deploy/types/custom.ts +24 -0
  155. package/src/deploy/types/dockerTag.ts +12 -0
  156. package/src/deploy/types/googleCloudRun.ts +79 -0
  157. package/src/deploy/types/index.ts +28 -0
  158. package/src/deploy/types/kubernetes.ts +281 -0
  159. package/src/deploy/utils.ts +6 -2
  160. package/src/pipeline/createChildPipeline.test.ts +1 -1
  161. package/src/pipeline/createChildPipeline.ts +4 -4
  162. package/src/pipeline/createJobs.ts +32 -21
  163. package/src/pipeline/gitlab/makeGitlabJob.ts +3 -2
  164. package/src/pipeline/packageManager.ts +1 -1
  165. package/src/rules/index.ts +1 -1
  166. package/src/runner/index.ts +2 -1
  167. package/src/types/config.ts +8 -6
  168. package/src/types/context.ts +14 -2
  169. package/src/types/environmentContext.ts +26 -0
  170. package/src/types/gitlab-types.ts +1 -1
  171. package/src/types/jobs.ts +9 -2
  172. package/src/types/pipeline.ts +1 -1
  173. package/tsconfig.json +2 -0
  174. package/dist/deploy/types.js +0 -16
  175. package/src/deploy/types.ts +0 -189
@@ -1,31 +1,194 @@
1
1
  "use strict";
2
2
 
3
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) {
5
+ return value instanceof P ? value : new P(function (resolve) {
6
+ resolve(value);
7
+ });
8
+ }
9
+
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) {
12
+ try {
13
+ step(generator.next(value));
14
+ } catch (e) {
15
+ reject(e);
16
+ }
17
+ }
18
+
19
+ function rejected(value) {
20
+ try {
21
+ step(generator["throw"](value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ }
26
+
27
+ function step(result) {
28
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29
+ }
30
+
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+
35
+ var __generator = this && this.__generator || function (thisArg, body) {
36
+ var _ = {
37
+ label: 0,
38
+ sent: function () {
39
+ if (t[0] & 1) throw t[1];
40
+ return t[1];
41
+ },
42
+ trys: [],
43
+ ops: []
44
+ },
45
+ f,
46
+ y,
47
+ t,
48
+ g;
49
+ return g = {
50
+ next: verb(0),
51
+ "throw": verb(1),
52
+ "return": verb(2)
53
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
54
+ return this;
55
+ }), g;
56
+
57
+ function verb(n) {
58
+ return function (v) {
59
+ return step([n, v]);
60
+ };
61
+ }
62
+
63
+ function step(op) {
64
+ if (f) throw new TypeError("Generator is already executing.");
65
+
66
+ while (_) try {
67
+ 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
+ if (y = 0, t) op = [op[0] & 2, t.value];
69
+
70
+ switch (op[0]) {
71
+ case 0:
72
+ case 1:
73
+ t = op;
74
+ break;
75
+
76
+ case 4:
77
+ _.label++;
78
+ return {
79
+ value: op[1],
80
+ done: false
81
+ };
82
+
83
+ case 5:
84
+ _.label++;
85
+ y = op[1];
86
+ op = [0];
87
+ continue;
88
+
89
+ case 7:
90
+ op = _.ops.pop();
91
+
92
+ _.trys.pop();
93
+
94
+ continue;
95
+
96
+ default:
97
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
98
+ _ = 0;
99
+ continue;
100
+ }
101
+
102
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
103
+ _.label = op[1];
104
+ break;
105
+ }
106
+
107
+ if (op[0] === 6 && _.label < t[1]) {
108
+ _.label = t[1];
109
+ t = op;
110
+ break;
111
+ }
112
+
113
+ if (t && _.label < t[2]) {
114
+ _.label = t[2];
115
+
116
+ _.ops.push(op);
117
+
118
+ break;
119
+ }
120
+
121
+ if (t[2]) _.ops.pop();
122
+
123
+ _.trys.pop();
124
+
125
+ continue;
126
+ }
127
+
128
+ op = body.call(thisArg, _);
129
+ } catch (e) {
130
+ op = [6, e];
131
+ y = 0;
132
+ } finally {
133
+ f = t = 0;
134
+ }
135
+
136
+ if (op[0] & 5) throw op[1];
137
+ return {
138
+ value: op[0] ? op[1] : void 0,
139
+ done: true
140
+ };
141
+ }
142
+ };
143
+
3
144
  exports.__esModule = true;
4
145
 
5
146
  var resolveReferences_1 = require("./resolveReferences");
6
147
 
7
148
  describe("resolveReferences", function () {
8
149
  it("replaces occurences of ${componentName:VARIABLE_NAME}", function () {
9
- var variables = {
10
- a: "hello world",
11
- b: "a replaced value looks like this: '${api:FOO}', nice!"
12
- };
13
- var otherVariables = {
14
- api: {
15
- FOO: "foo from api"
16
- },
17
- frontend: {
18
- FOO: "foo from frontend"
19
- }
20
- };
21
- var result = (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
22
- var _a;
150
+ return __awaiter(void 0, void 0, void 0, function () {
151
+ var variables, otherVariables, result;
152
+ return __generator(this, function (_a) {
153
+ switch (_a.label) {
154
+ case 0:
155
+ variables = {
156
+ a: "hello world",
157
+ b: "a replaced value looks like this: '${api:FOO}', nice!"
158
+ };
159
+ otherVariables = {
160
+ api: {
161
+ FOO: "foo from api"
162
+ },
163
+ frontend: {
164
+ FOO: "foo from frontend"
165
+ }
166
+ };
167
+ return [4
168
+ /*yield*/
169
+ , (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
170
+ return __awaiter(void 0, void 0, void 0, function () {
171
+ var _a;
23
172
 
24
- return (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName];
25
- });
26
- expect(result).toEqual({
27
- a: "hello world",
28
- b: "a replaced value looks like this: 'foo from api', nice!"
173
+ return __generator(this, function (_b) {
174
+ return [2
175
+ /*return*/
176
+ , (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
177
+ });
178
+ });
179
+ })];
180
+
181
+ case 1:
182
+ result = _a.sent();
183
+ expect(result).toEqual({
184
+ a: "hello world",
185
+ b: "a replaced value looks like this: 'foo from api', nice!"
186
+ });
187
+ return [2
188
+ /*return*/
189
+ ];
190
+ }
191
+ });
29
192
  });
30
193
  });
31
194
  it("replaces self references with structure ${VARIABLE_NAME}", function () {
@@ -40,81 +203,169 @@ describe("resolveReferences", function () {
40
203
  });
41
204
  });
42
205
  it("replaces self references mixed with other vars", function () {
43
- var variables = {
44
- FOO: "hello from ${api:FOO}",
45
- BAR: "this: ${FOO}!"
46
- };
47
- var otherVariables = {
48
- api: {
49
- FOO: "foo from api"
50
- }
51
- };
52
- var result = (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
53
- var _a;
206
+ return __awaiter(void 0, void 0, void 0, function () {
207
+ var variables, otherVariables, result;
208
+ return __generator(this, function (_a) {
209
+ switch (_a.label) {
210
+ case 0:
211
+ variables = {
212
+ FOO: "hello from ${api:FOO}",
213
+ BAR: "this: ${FOO}!"
214
+ };
215
+ otherVariables = {
216
+ api: {
217
+ FOO: "foo from api"
218
+ }
219
+ };
220
+ return [4
221
+ /*yield*/
222
+ , (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
223
+ return __awaiter(void 0, void 0, void 0, function () {
224
+ var _a;
54
225
 
55
- return (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName];
56
- });
57
- expect(result).toEqual({
58
- FOO: "hello from foo from api",
59
- BAR: "this: hello from foo from api!"
226
+ return __generator(this, function (_b) {
227
+ return [2
228
+ /*return*/
229
+ , (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
230
+ });
231
+ });
232
+ })];
233
+
234
+ case 1:
235
+ result = _a.sent();
236
+ expect(result).toEqual({
237
+ FOO: "hello from foo from api",
238
+ BAR: "this: hello from foo from api!"
239
+ });
240
+ return [2
241
+ /*return*/
242
+ ];
243
+ }
244
+ });
60
245
  });
61
246
  });
62
247
  it("keeps variables as is if not found (when null is returned)", function () {
63
- var variables = {
64
- a: "hello world",
65
- b: "a not found value looks like this: '${api:FOO}'"
66
- };
67
- var otherVariables = {};
68
- var result = (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
69
- var _a;
248
+ return __awaiter(void 0, void 0, void 0, function () {
249
+ var variables, otherVariables, result;
250
+ return __generator(this, function (_a) {
251
+ switch (_a.label) {
252
+ case 0:
253
+ variables = {
254
+ a: "hello world",
255
+ b: "a not found value looks like this: '${api:FOO}'"
256
+ };
257
+ otherVariables = {};
258
+ return [4
259
+ /*yield*/
260
+ , (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
261
+ return __awaiter(void 0, void 0, void 0, function () {
262
+ var _a;
70
263
 
71
- return (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName];
72
- });
73
- expect(result).toEqual({
74
- a: "hello world",
75
- b: "a not found value looks like this: '${api:FOO}'"
264
+ return __generator(this, function (_b) {
265
+ return [2
266
+ /*return*/
267
+ , (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
268
+ });
269
+ });
270
+ })];
271
+
272
+ case 1:
273
+ result = _a.sent();
274
+ expect(result).toEqual({
275
+ a: "hello world",
276
+ b: "a not found value looks like this: '${api:FOO}'"
277
+ });
278
+ return [2
279
+ /*return*/
280
+ ];
281
+ }
282
+ });
76
283
  });
77
284
  });
78
285
  it("replaces mulitple levels deep", function () {
79
- var variables = {
80
- a: "value is ${frontend:FOO}!"
81
- };
82
- var otherVariables = {
83
- api: {
84
- FOO: "foo from api"
85
- },
86
- frontend: {
87
- FOO: "hi, ${api:FOO}"
88
- }
89
- };
90
- var result = (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
91
- var _a, _b;
286
+ return __awaiter(void 0, void 0, void 0, function () {
287
+ var variables, otherVariables, result;
288
+ return __generator(this, function (_a) {
289
+ switch (_a.label) {
290
+ case 0:
291
+ variables = {
292
+ a: "value is ${frontend:FOO}!"
293
+ };
294
+ otherVariables = {
295
+ api: {
296
+ FOO: "foo from api"
297
+ },
298
+ frontend: {
299
+ FOO: "hi, ${api:FOO}"
300
+ }
301
+ };
302
+ return [4
303
+ /*yield*/
304
+ , (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
305
+ return __awaiter(void 0, void 0, void 0, function () {
306
+ var _a, _b;
92
307
 
93
- return (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : "";
94
- });
95
- expect(result).toEqual({
96
- a: "value is hi, foo from api!"
308
+ return __generator(this, function (_c) {
309
+ return [2
310
+ /*return*/
311
+ , (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : ""];
312
+ });
313
+ });
314
+ })];
315
+
316
+ case 1:
317
+ result = _a.sent();
318
+ expect(result).toEqual({
319
+ a: "value is hi, foo from api!"
320
+ });
321
+ return [2
322
+ /*return*/
323
+ ];
324
+ }
325
+ });
97
326
  });
98
327
  });
99
328
  it("prevents endless loops", function () {
100
- var variables = {
101
- a: "value is ${frontend:FOO}!"
102
- };
103
- var otherVariables = {
104
- api: {
105
- FOO: "api ${frontend:FOO}"
106
- },
107
- frontend: {
108
- FOO: "frontend ${api:FOO}"
109
- }
110
- };
111
- var result = (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
112
- var _a, _b;
329
+ return __awaiter(void 0, void 0, void 0, function () {
330
+ var variables, otherVariables, result;
331
+ return __generator(this, function (_a) {
332
+ switch (_a.label) {
333
+ case 0:
334
+ variables = {
335
+ a: "value is ${frontend:FOO}!"
336
+ };
337
+ otherVariables = {
338
+ api: {
339
+ FOO: "api ${frontend:FOO}"
340
+ },
341
+ frontend: {
342
+ FOO: "frontend ${api:FOO}"
343
+ }
344
+ };
345
+ return [4
346
+ /*yield*/
347
+ , (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
348
+ return __awaiter(void 0, void 0, void 0, function () {
349
+ var _a, _b;
113
350
 
114
- return (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : "";
115
- });
116
- expect(result).toEqual({
117
- a: "value is frontend api ${frontend:FOO}!"
351
+ return __generator(this, function (_c) {
352
+ return [2
353
+ /*return*/
354
+ , (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : ""];
355
+ });
356
+ });
357
+ })];
358
+
359
+ case 1:
360
+ result = _a.sent();
361
+ expect(result).toEqual({
362
+ a: "value is frontend api ${frontend:FOO}!"
363
+ });
364
+ return [2
365
+ /*return*/
366
+ ];
367
+ }
368
+ });
118
369
  });
119
370
  });
120
371
  });
@@ -1,2 +1,2 @@
1
- import { Retry } from "../types";
1
+ import type { Retry } from "../types";
2
2
  export declare const BASE_RETRY: Retry;
@@ -1,8 +1,10 @@
1
- import { Context } from "../types";
2
- import { CatladderJob } from "../types/jobs";
1
+ import type { Context } from "../types";
2
+ import type { CatladderJob } from "../types/jobs";
3
3
  export declare const DEPLOY_JOB_NAME = "\uD83D\uDE80 Deploy";
4
4
  export declare const STOP_JOB_NAME = "\uD83D\uDED1 Stop \u26A0\uFE0F";
5
+ export declare const ROLLBACK_JOB_NAME = "\u21A9\uFE0F Rollback \u26A0\uFE0F";
5
6
  declare type JobWithoutScript = Omit<CatladderJob, "script">;
6
7
  export declare const getBaseDeploymentJob: (context: Context) => JobWithoutScript;
7
8
  export declare const getBaseDeploymentStopJob: (context: Context) => JobWithoutScript;
9
+ export declare const getBaseRollbackJob: (context: Context) => JobWithoutScript;
8
10
  export {};
@@ -15,7 +15,7 @@ var __assign = this && this.__assign || function () {
15
15
  };
16
16
 
17
17
  exports.__esModule = true;
18
- exports.getBaseDeploymentStopJob = exports.getBaseDeploymentJob = exports.STOP_JOB_NAME = exports.DEPLOY_JOB_NAME = void 0;
18
+ exports.getBaseRollbackJob = exports.getBaseDeploymentStopJob = exports.getBaseDeploymentJob = exports.ROLLBACK_JOB_NAME = exports.STOP_JOB_NAME = exports.DEPLOY_JOB_NAME = void 0;
19
19
 
20
20
  var docker_1 = require("../build/docker");
21
21
 
@@ -23,6 +23,7 @@ var utils_1 = require("./utils");
23
23
 
24
24
  exports.DEPLOY_JOB_NAME = "🚀 Deploy";
25
25
  exports.STOP_JOB_NAME = "🛑 Stop âš ī¸";
26
+ exports.ROLLBACK_JOB_NAME = "â†Šī¸ Rollback âš ī¸";
26
27
  var DEPLOY_RUNNER_VARIABLES = {
27
28
  KUBERNETES_CPU_REQUEST: "0.5",
28
29
  KUBERNETES_CPU_LIMIT: "1",
@@ -31,16 +32,11 @@ var DEPLOY_RUNNER_VARIABLES = {
31
32
  };
32
33
 
33
34
  var getBaseDeploymentJob = function (context) {
34
- var _a;
35
+ var _a, _b, _c;
35
36
 
36
- var environment = {
37
- name: context.environment.fullName,
38
- url: context.environment.url
39
- };
40
37
  var hasDocker = (0, docker_1.requiresDockerBuild)(context);
41
38
  var isStoppable = (0, utils_1.contextIsStoppable)(context);
42
- var autoStop = context.environment.envType === "review" ? "3 days" // auto stop is not working properly when branch is merged, so we do
43
- : context.environment.envType === "dev" ? "3 weeks" : undefined; // if auto or manual is configured explicitly, use that
39
+ var autoStop = context.environment.envType === "review" ? "2 week" : context.environment.envType === "dev" ? "4 weeks" : undefined; // if auto or manual is configured explicitly, use that
44
40
 
45
41
  var whenDeployDefined = context.componentConfig.deploy && context.componentConfig.deploy.when ? context.componentConfig.deploy.when : undefined; // otherwise auto deploy if env is not prod. If its prod, deploy automatically if stage is disabled
46
42
 
@@ -52,6 +48,13 @@ var getBaseDeploymentJob = function (context) {
52
48
  return {
53
49
  name: exports.DEPLOY_JOB_NAME,
54
50
  envMode: "stagePerEnv",
51
+ needsOtherComponent: context.componentConfig.deploy ? (_c = (_b = context.componentConfig.deploy.waitFor) === null || _b === void 0 ? void 0 : _b.map(function (c) {
52
+ return {
53
+ componentName: c,
54
+ job: exports.DEPLOY_JOB_NAME,
55
+ artifacts: false
56
+ };
57
+ })) !== null && _c !== void 0 ? _c : undefined : undefined,
55
58
  // we don't want to deploy when there is a broken test
56
59
  needsStages: [{
57
60
  stage: "build",
@@ -67,8 +70,8 @@ var getBaseDeploymentJob = function (context) {
67
70
  }],
68
71
  allow_failure: whenDeploy === "manual" ? true : false,
69
72
  stage: "deploy",
70
- variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.envVars),
71
- environment: __assign(__assign({}, environment), isStoppable ? {
73
+ variables: __assign(__assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.envVars), hasDocker ? (0, docker_1.getDockerImageVariables)(context) : {}),
74
+ environment: __assign(__assign({}, context.environment.gitlabEnvironment), isStoppable ? {
72
75
  on_stop: exports.STOP_JOB_NAME,
73
76
  auto_stop_in: autoStop
74
77
  } : {})
@@ -78,14 +81,10 @@ var getBaseDeploymentJob = function (context) {
78
81
  exports.getBaseDeploymentJob = getBaseDeploymentJob;
79
82
 
80
83
  var getBaseDeploymentStopJob = function (context) {
81
- var environment = {
82
- name: context.environment.fullName,
83
- url: context.environment.url
84
- };
85
84
  return {
86
85
  name: exports.STOP_JOB_NAME,
87
86
  envMode: "stagePerEnv",
88
- needs: [exports.DEPLOY_JOB_NAME],
87
+ needs: [],
89
88
  rules: [{
90
89
  "if": "$CI_COMMIT_BRANCH =~ /^[0-9]+\\.([0-9]+|x)\\.x$/",
91
90
  when: "on_success",
@@ -98,10 +97,31 @@ var getBaseDeploymentStopJob = function (context) {
98
97
  GIT_STRATEGY: "none"
99
98
  }),
100
99
  stage: "stop",
101
- environment: __assign(__assign({}, environment), {
100
+ environment: __assign(__assign({}, context.environment.gitlabEnvironment), {
102
101
  action: "stop"
103
102
  })
104
103
  };
105
104
  };
106
105
 
107
- exports.getBaseDeploymentStopJob = getBaseDeploymentStopJob;
106
+ exports.getBaseDeploymentStopJob = getBaseDeploymentStopJob;
107
+
108
+ var getBaseRollbackJob = function (context) {
109
+ return {
110
+ name: exports.ROLLBACK_JOB_NAME,
111
+ envMode: "stagePerEnv",
112
+ needs: [],
113
+ rules: [{
114
+ when: "manual",
115
+ allow_failure: true
116
+ }],
117
+ variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), {
118
+ GIT_STRATEGY: "none"
119
+ }),
120
+ stage: "rollback",
121
+ environment: __assign(__assign({}, context.environment.gitlabEnvironment), {
122
+ action: "access"
123
+ })
124
+ };
125
+ };
126
+
127
+ exports.getBaseRollbackJob = getBaseRollbackJob;
@@ -0,0 +1,3 @@
1
+ import type { Context } from "../../types/context";
2
+ import type { CatladderJob } from "../../types/jobs";
3
+ export declare const createGoogleCloudRunDeployJobs: (context: Context) => CatladderJob[];