@catladder/pipeline 1.45.0 → 1.47.0

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.
@@ -0,0 +1,374 @@
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
+
8
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ };
16
+
17
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) {
19
+ return value instanceof P ? value : new P(function (resolve) {
20
+ resolve(value);
21
+ });
22
+ }
23
+
24
+ return new (P || (P = Promise))(function (resolve, reject) {
25
+ function fulfilled(value) {
26
+ try {
27
+ step(generator.next(value));
28
+ } catch (e) {
29
+ reject(e);
30
+ }
31
+ }
32
+
33
+ function rejected(value) {
34
+ try {
35
+ step(generator["throw"](value));
36
+ } catch (e) {
37
+ reject(e);
38
+ }
39
+ }
40
+
41
+ function step(result) {
42
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
43
+ }
44
+
45
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
46
+ });
47
+ };
48
+
49
+ var __generator = this && this.__generator || function (thisArg, body) {
50
+ var _ = {
51
+ label: 0,
52
+ sent: function () {
53
+ if (t[0] & 1) throw t[1];
54
+ return t[1];
55
+ },
56
+ trys: [],
57
+ ops: []
58
+ },
59
+ f,
60
+ y,
61
+ t,
62
+ g;
63
+ return g = {
64
+ next: verb(0),
65
+ "throw": verb(1),
66
+ "return": verb(2)
67
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
68
+ return this;
69
+ }), g;
70
+
71
+ function verb(n) {
72
+ return function (v) {
73
+ return step([n, v]);
74
+ };
75
+ }
76
+
77
+ function step(op) {
78
+ if (f) throw new TypeError("Generator is already executing.");
79
+
80
+ while (_) try {
81
+ 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;
82
+ if (y = 0, t) op = [op[0] & 2, t.value];
83
+
84
+ switch (op[0]) {
85
+ case 0:
86
+ case 1:
87
+ t = op;
88
+ break;
89
+
90
+ case 4:
91
+ _.label++;
92
+ return {
93
+ value: op[1],
94
+ done: false
95
+ };
96
+
97
+ case 5:
98
+ _.label++;
99
+ y = op[1];
100
+ op = [0];
101
+ continue;
102
+
103
+ case 7:
104
+ op = _.ops.pop();
105
+
106
+ _.trys.pop();
107
+
108
+ continue;
109
+
110
+ default:
111
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
112
+ _ = 0;
113
+ continue;
114
+ }
115
+
116
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
117
+ _.label = op[1];
118
+ break;
119
+ }
120
+
121
+ if (op[0] === 6 && _.label < t[1]) {
122
+ _.label = t[1];
123
+ t = op;
124
+ break;
125
+ }
126
+
127
+ if (t && _.label < t[2]) {
128
+ _.label = t[2];
129
+
130
+ _.ops.push(op);
131
+
132
+ break;
133
+ }
134
+
135
+ if (t[2]) _.ops.pop();
136
+
137
+ _.trys.pop();
138
+
139
+ continue;
140
+ }
141
+
142
+ op = body.call(thisArg, _);
143
+ } catch (e) {
144
+ op = [6, e];
145
+ y = 0;
146
+ } finally {
147
+ f = t = 0;
148
+ }
149
+
150
+ if (op[0] & 5) throw op[1];
151
+ return {
152
+ value: op[0] ? op[1] : void 0,
153
+ done: true
154
+ };
155
+ }
156
+ };
157
+
158
+ var __read = this && this.__read || function (o, n) {
159
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
160
+ if (!m) return o;
161
+ var i = m.call(o),
162
+ r,
163
+ ar = [],
164
+ e;
165
+
166
+ try {
167
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
168
+ } catch (error) {
169
+ e = {
170
+ error: error
171
+ };
172
+ } finally {
173
+ try {
174
+ if (r && !r.done && (m = i["return"])) m.call(i);
175
+ } finally {
176
+ if (e) throw e.error;
177
+ }
178
+ }
179
+
180
+ return ar;
181
+ };
182
+
183
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
184
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
185
+ if (ar || !(i in from)) {
186
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
187
+ ar[i] = from[i];
188
+ }
189
+ }
190
+ return to.concat(ar || Array.prototype.slice.call(from));
191
+ };
192
+
193
+ var __importDefault = this && this.__importDefault || function (mod) {
194
+ return mod && mod.__esModule ? mod : {
195
+ "default": mod
196
+ };
197
+ };
198
+
199
+ exports.__esModule = true;
200
+ exports.getEnvironment = exports.getSecretVarNameForContext = exports.getSecretVarName = void 0;
201
+
202
+ var lodash_1 = require("lodash");
203
+
204
+ var slugify_1 = __importDefault(require("slugify"));
205
+
206
+ var deploy_1 = require("../deploy");
207
+
208
+ var types_1 = require("../deploy/types");
209
+
210
+ var config_1 = require("../types/config");
211
+
212
+ var utils_1 = require("../utils");
213
+
214
+ var resolveReferences_1 = require("./resolveReferences");
215
+
216
+ var sanitizeForEnVar = function (s) {
217
+ return s.replace(/-/g, "_");
218
+ };
219
+
220
+ var getSecretVarName = function (env, componentName, key) {
221
+ return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
222
+ }; // remove dash from component name
223
+
224
+
225
+ exports.getSecretVarName = getSecretVarName;
226
+
227
+ var addIndexVar = function (vars) {
228
+ return __assign(__assign({}, vars), {
229
+ _ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars))
230
+ });
231
+ };
232
+
233
+ var getSecretVarNameForContext = function (context, key) {
234
+ return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
235
+ };
236
+
237
+ exports.getSecretVarNameForContext = getSecretVarNameForContext;
238
+
239
+ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
240
+ ) {
241
+ if (alreadyVisited === void 0) {
242
+ alreadyVisited = {};
243
+ }
244
+
245
+ return __awaiter(void 0, void 0, void 0, function () {
246
+ var defaultConfig, envConfig, mergedConfig, envType, basePredefinedVariables, gitlabEnvironmentName, environmentSlug, predefinedVariables, host, url, fullName, devLocalConfig, port, componentSlug, envInUrl, domainCanonical, HOST_CANONICAL, KUBE_APP_NAME_PREFIX, KUBE_APP_NAME, KUBE_NAMESPACE, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
247
+
248
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
249
+
250
+ return __generator(this, function (_o) {
251
+ switch (_o.label) {
252
+ case 0:
253
+ defaultConfig = config.components[componentName];
254
+
255
+ if (!defaultConfig) {
256
+ throw new Error("unknown component " + componentName);
257
+ }
258
+
259
+ envConfig = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
260
+
261
+ if (envConfig === false) {
262
+ throw new Error("env is disabled: " + env);
263
+ }
264
+
265
+ mergedConfig = (0, utils_1.mergeWithMergingArrays)(defaultConfig, envConfig);
266
+ envType = (_c = envConfig === null || envConfig === void 0 ? void 0 : envConfig.type) !== null && _c !== void 0 ? _c : (0, config_1.isKnowEnvType)(env) ? env : null;
267
+
268
+ if (!envType) {
269
+ throw new Error("Missing type in environment " + env + " in component " + componentName);
270
+ }
271
+
272
+ basePredefinedVariables = {
273
+ ENV_SHORT: env,
274
+ APP_DIR: mergedConfig.dir,
275
+ ENV_TYPE: envType
276
+ };
277
+ gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
278
+ environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
279
+ fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
280
+
281
+ if (envType === "local") {
282
+ devLocalConfig = mergedConfig;
283
+ port = (_d = devLocalConfig.port) !== null && _d !== void 0 ? _d : 3000;
284
+ host = "localhost:" + port;
285
+ url = "http://" + host;
286
+ predefinedVariables = {
287
+ ENV_SHORT: "local",
288
+ ROOT_URL: url,
289
+ PORT: port.toString()
290
+ };
291
+ } else {
292
+ componentSlug = (0, slugify_1["default"])(componentName);
293
+ envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
294
+ domainCanonical = (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy) && (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy.type) === "kubernetes" && ((_e = mergedConfig.deploy.cluster) === null || _e === void 0 ? void 0 : _e.domainCanonical) || // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
295
+ config.domainCanonical || "panter.cloud";
296
+ HOST_CANONICAL = (0, types_1.isOfDeployType)(mergedConfig.deploy, "kubernetes") ? "".concat(componentSlug, ".").concat(envInUrl, ".").concat(config.appName, ".").concat(config.customerName, ".").concat(domainCanonical) : (0, types_1.isOfDeployType)(mergedConfig.deploy, "google-cloudrun") ? environmentSlug + "-" + process.env[(0, exports.getSecretVarName)(env, componentName, deploy_1.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)] : "";
297
+ host = (_f = mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.host) !== null && _f !== void 0 ? _f : HOST_CANONICAL;
298
+ url = "https://".concat(host);
299
+ KUBE_APP_NAME_PREFIX = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-") : "";
300
+ KUBE_APP_NAME = "".concat(KUBE_APP_NAME_PREFIX).concat(componentName);
301
+ KUBE_NAMESPACE = (0, deploy_1.getKubernetesNamespace)(config, env);
302
+ predefinedVariables = __assign(__assign({}, basePredefinedVariables), {
303
+ HOST_CANONICAL: HOST_CANONICAL,
304
+ HOST: host,
305
+ ROOT_URL: url,
306
+ KUBE_NAMESPACE: KUBE_NAMESPACE,
307
+ KUBE_APP_NAME: KUBE_APP_NAME,
308
+ KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX
309
+ });
310
+ }
311
+
312
+ publicEnvVarsRaw = (_h = (_g = mergedConfig.vars) === null || _g === void 0 ? void 0 : _g.public) !== null && _h !== void 0 ? _h : {};
313
+ additionalSecretKeys = mergedConfig.deploy ? deploy_1.DEPLOY_TYPES[mergedConfig.deploy.type].additionalSecretKeys( // eslint-disable-next-line @typescript-eslint/no-explicit-any
314
+ mergedConfig.deploy) : [];
315
+ secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_k = (_j = mergedConfig.vars) === null || _j === void 0 ? void 0 : _j.secret) !== null && _k !== void 0 ? _k : []), false), __read(additionalSecretKeys), false);
316
+ secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
317
+ return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
318
+ }));
319
+ legacyFromComponents = (_m = (_l = mergedConfig.vars) === null || _l === void 0 ? void 0 : _l.fromComponents) !== null && _m !== void 0 ? _m : {};
320
+ publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
321
+ publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
322
+ var _b = __read(_a, 2),
323
+ key = _b[0],
324
+ value = _b[1];
325
+
326
+ return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
327
+ }));
328
+ envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
329
+ return [4
330
+ /*yield*/
331
+ , (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (componentName, variableName, alreadyVisited) {
332
+ return __awaiter(void 0, void 0, void 0, function () {
333
+ var envVars;
334
+ return __generator(this, function (_a) {
335
+ switch (_a.label) {
336
+ case 0:
337
+ return [4
338
+ /*yield*/
339
+ , (0, exports.getEnvironment)(config, componentName, env, commitInfo, alreadyVisited)];
340
+
341
+ case 1:
342
+ envVars = _a.sent().envVars;
343
+ return [2
344
+ /*return*/
345
+ , envVars[variableName]];
346
+ }
347
+ });
348
+ });
349
+ }, alreadyVisited)];
350
+
351
+ case 1:
352
+ envVars = _o.sent();
353
+ return [2
354
+ /*return*/
355
+ , {
356
+ envType: envType,
357
+ host: host,
358
+ url: url,
359
+ gitlabEnvironment: {
360
+ name: gitlabEnvironmentName,
361
+ url: url
362
+ },
363
+ fullName: fullName,
364
+ slug: environmentSlug,
365
+ shortName: env,
366
+ envVars: envVars,
367
+ secretEnvVarKeys: secretEnvVarKeys
368
+ }];
369
+ }
370
+ });
371
+ });
372
+ };
373
+
374
+ exports.getEnvironment = getEnvironment;
@@ -1,6 +1,4 @@
1
1
  import type { Config } from "../types/config";
2
- import type { 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>>) => Promise<Environment>;
2
+ import type { CommitInfo, Context } from "../types/context";
3
+ export * from "./getEnvironment";
6
4
  export declare const createContext: (config: Config, componentName: string, env: string, commitInfo?: CommitInfo | undefined, packageManagerInfo?: import("../types/context").YarnPackageManagerInfo | undefined) => Promise<Context>;
@@ -1,17 +1,20 @@
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
-
8
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
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
9
  }
10
+ });
11
+ } : function (o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ });
10
15
 
11
- return t;
12
- };
13
-
14
- return __assign.apply(this, arguments);
16
+ var __exportStar = this && this.__exportStar || function (m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
18
  };
16
19
 
17
20
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
@@ -155,222 +158,18 @@ var __generator = this && this.__generator || function (thisArg, body) {
155
158
  }
156
159
  };
157
160
 
158
- var __read = this && this.__read || function (o, n) {
159
- var m = typeof Symbol === "function" && o[Symbol.iterator];
160
- if (!m) return o;
161
- var i = m.call(o),
162
- r,
163
- ar = [],
164
- e;
165
-
166
- try {
167
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
168
- } catch (error) {
169
- e = {
170
- error: error
171
- };
172
- } finally {
173
- try {
174
- if (r && !r.done && (m = i["return"])) m.call(i);
175
- } finally {
176
- if (e) throw e.error;
177
- }
178
- }
179
-
180
- return ar;
181
- };
182
-
183
- var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
184
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
185
- if (ar || !(i in from)) {
186
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
187
- ar[i] = from[i];
188
- }
189
- }
190
- return to.concat(ar || Array.prototype.slice.call(from));
191
- };
192
-
193
- var __importDefault = this && this.__importDefault || function (mod) {
194
- return mod && mod.__esModule ? mod : {
195
- "default": mod
196
- };
197
- };
198
-
199
161
  exports.__esModule = true;
200
- exports.createContext = exports.getEnvironment = exports.getSecretVarNameForContext = exports.getSecretVarName = void 0;
201
-
202
- var lodash_1 = require("lodash");
203
-
204
- var slugify_1 = __importDefault(require("slugify"));
162
+ exports.createContext = void 0;
205
163
 
206
164
  var build_1 = require("../build");
207
165
 
208
166
  var deploy_1 = require("../deploy");
209
167
 
210
- var types_1 = require("../deploy/types");
211
-
212
- var config_1 = require("../types/config");
213
-
214
168
  var utils_1 = require("../utils");
215
169
 
216
- var resolveReferences_1 = require("./resolveReferences");
217
-
218
- var sanitizeForEnVar = function (s) {
219
- return s.replace(/-/g, "_");
220
- };
221
-
222
- var getSecretVarName = function (env, componentName, key) {
223
- return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
224
- }; // remove dash from component name
225
-
226
-
227
- exports.getSecretVarName = getSecretVarName;
228
-
229
- var addIndexVar = function (vars) {
230
- return __assign(__assign({}, vars), {
231
- _ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars))
232
- });
233
- };
234
-
235
- var getSecretVarNameForContext = function (context, key) {
236
- return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
237
- };
238
-
239
- exports.getSecretVarNameForContext = getSecretVarNameForContext;
240
-
241
- var getEnvironment = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
242
- ) {
243
- if (alreadyVisited === void 0) {
244
- alreadyVisited = {};
245
- }
246
-
247
- return __awaiter(void 0, void 0, void 0, function () {
248
- var defaultConfig, envConfig, mergedConfig, envType, basePredefinedVariables, environmentName, environmentSlug, predefinedVariables, host, url, devLocalConfig, port, RELEASE_NAME, componentSlug, envInUrl, domainCanonical, HOST_CANONICAL, url_1, KUBE_APP_NAME_PREFIX, KUBE_APP_NAME, KUBE_NAMESPACE, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
249
-
250
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
251
-
252
- return __generator(this, function (_o) {
253
- switch (_o.label) {
254
- case 0:
255
- defaultConfig = config.components[componentName];
256
-
257
- if (!defaultConfig) {
258
- throw new Error("unknown component " + componentName);
259
- }
260
-
261
- envConfig = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
262
-
263
- if (envConfig === false) {
264
- throw new Error("env is disabled: " + env);
265
- }
266
-
267
- mergedConfig = (0, utils_1.mergeWithMergingArrays)(defaultConfig, envConfig);
268
- envType = (_c = envConfig === null || envConfig === void 0 ? void 0 : envConfig.type) !== null && _c !== void 0 ? _c : (0, config_1.isKnowEnvType)(env) ? env : null;
269
-
270
- if (!envType) {
271
- throw new Error("Missing type in environment " + env + " in component " + componentName);
272
- }
273
-
274
- basePredefinedVariables = {
275
- ENV_SHORT: env,
276
- APP_DIR: mergedConfig.dir,
277
- ENV_TYPE: envType
278
- };
279
- environmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
280
- environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
281
-
282
- if (envType === "local") {
283
- devLocalConfig = mergedConfig;
284
- port = (_d = devLocalConfig.port) !== null && _d !== void 0 ? _d : 3000;
285
- host = "localhost:" + port;
286
- url = "http://" + host;
287
- predefinedVariables = {
288
- ENV_SHORT: "local",
289
- ROOT_URL: url,
290
- PORT: port.toString()
291
- };
292
- } else {
293
- RELEASE_NAME = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
294
- componentSlug = (0, slugify_1["default"])(componentName);
295
- envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
296
- domainCanonical = (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy) && (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy.type) === "kubernetes" && ((_e = mergedConfig.deploy.cluster) === null || _e === void 0 ? void 0 : _e.domainCanonical) || // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
297
- config.domainCanonical || "panter.cloud";
298
- HOST_CANONICAL = (0, types_1.isOfDeployType)(mergedConfig.deploy, "kubernetes") ? "".concat(componentSlug, ".").concat(envInUrl, ".").concat(config.appName, ".").concat(config.customerName, ".").concat(domainCanonical) : (0, types_1.isOfDeployType)(mergedConfig.deploy, "google-cloudrun") ? environmentSlug + "-" + process.env[(0, exports.getSecretVarName)(env, componentName, deploy_1.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)] : "";
299
- host = (_f = mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.host) !== null && _f !== void 0 ? _f : HOST_CANONICAL;
300
- url_1 = "https://".concat(host);
301
- KUBE_APP_NAME_PREFIX = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-") : "";
302
- KUBE_APP_NAME = "".concat(KUBE_APP_NAME_PREFIX).concat(componentName);
303
- KUBE_NAMESPACE = (0, deploy_1.getKubernetesNamespace)(config, env);
304
- predefinedVariables = __assign(__assign({}, basePredefinedVariables), {
305
- HOST_CANONICAL: HOST_CANONICAL,
306
- HOST: host,
307
- ROOT_URL: url_1,
308
- KUBE_NAMESPACE: KUBE_NAMESPACE,
309
- KUBE_APP_NAME: KUBE_APP_NAME,
310
- KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX,
311
- RELEASE_NAME: RELEASE_NAME
312
- });
313
- }
314
-
315
- publicEnvVarsRaw = (_h = (_g = mergedConfig.vars) === null || _g === void 0 ? void 0 : _g.public) !== null && _h !== void 0 ? _h : {};
316
- additionalSecretKeys = mergedConfig.deploy ? deploy_1.DEPLOY_TYPES[mergedConfig.deploy.type].additionalSecretKeys( // eslint-disable-next-line @typescript-eslint/no-explicit-any
317
- mergedConfig.deploy) : [];
318
- secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_k = (_j = mergedConfig.vars) === null || _j === void 0 ? void 0 : _j.secret) !== null && _k !== void 0 ? _k : []), false), __read(additionalSecretKeys), false);
319
- secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
320
- return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
321
- }));
322
- legacyFromComponents = (_m = (_l = mergedConfig.vars) === null || _l === void 0 ? void 0 : _l.fromComponents) !== null && _m !== void 0 ? _m : {};
323
- publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
324
- publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
325
- var _b = __read(_a, 2),
326
- key = _b[0],
327
- value = _b[1];
328
-
329
- return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
330
- }));
331
- envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
332
- return [4
333
- /*yield*/
334
- , (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (componentName, variableName, alreadyVisited) {
335
- return __awaiter(void 0, void 0, void 0, function () {
336
- var envVars;
337
- return __generator(this, function (_a) {
338
- switch (_a.label) {
339
- case 0:
340
- return [4
341
- /*yield*/
342
- , (0, exports.getEnvironment)(config, componentName, env, commitInfo, alreadyVisited)];
343
-
344
- case 1:
345
- envVars = _a.sent().envVars;
346
- return [2
347
- /*return*/
348
- , envVars[variableName]];
349
- }
350
- });
351
- });
352
- }, alreadyVisited)];
353
-
354
- case 1:
355
- envVars = _o.sent();
356
- return [2
357
- /*return*/
358
- , {
359
- envType: envType,
360
- host: host,
361
- fullName: environmentName,
362
- slug: environmentSlug,
363
- shortName: env,
364
- url: predefinedVariables.ROOT_URL,
365
- envVars: envVars,
366
- secretEnvVarKeys: secretEnvVarKeys
367
- }];
368
- }
369
- });
370
- });
371
- };
170
+ var getEnvironment_1 = require("./getEnvironment");
372
171
 
373
- exports.getEnvironment = getEnvironment;
172
+ __exportStar(require("./getEnvironment"), exports);
374
173
 
375
174
  var createContext = function (config, componentName, env, commitInfo, packageManagerInfo) {
376
175
  return __awaiter(void 0, void 0, void 0, function () {
@@ -410,7 +209,7 @@ var createContext = function (config, componentName, env, commitInfo, packageMan
410
209
  };
411
210
  return [4
412
211
  /*yield*/
413
- , (0, exports.getEnvironment)(config, componentName, env, commitInfo)];
212
+ , (0, getEnvironment_1.getEnvironment)(config, componentName, env, commitInfo)];
414
213
 
415
214
  case 1:
416
215
  return [2