@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
@@ -0,0 +1,49 @@
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 __importDefault = this && this.__importDefault || function (mod) {
18
+ return mod && mod.__esModule ? mod : {
19
+ "default": mod
20
+ };
21
+ };
22
+
23
+ exports.__esModule = true;
24
+ exports.getLabels = void 0;
25
+
26
+ var slugify_1 = __importDefault(require("slugify"));
27
+
28
+ var sanitize = function (value) {
29
+ if (!value) return value; //"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."
30
+ // slugify should do the job
31
+
32
+ return (0, slugify_1["default"])(value).toLowerCase();
33
+ };
34
+
35
+ var getLabels = function (context) {
36
+ var _a, _b, _c;
37
+
38
+ var labels = __assign({
39
+ "customer-name": sanitize(context.fullConfig.customerName),
40
+ "app-name": sanitize(context.fullConfig.appName),
41
+ "env-type": sanitize(context.environment.envType),
42
+ "env-name": sanitize(context.environment.shortName),
43
+ "build-type": sanitize((_a = context.componentConfig.build) === null || _a === void 0 ? void 0 : _a.type)
44
+ }, (_c = (_b = context.fullConfig.meta) === null || _b === void 0 ? void 0 : _b.labels) !== null && _c !== void 0 ? _c : {});
45
+
46
+ return labels;
47
+ };
48
+
49
+ 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>;
@@ -1,224 +1,219 @@
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
+ });
15
+
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);
18
+ };
10
19
 
11
- return t;
12
- };
20
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
21
+ function adopt(value) {
22
+ return value instanceof P ? value : new P(function (resolve) {
23
+ resolve(value);
24
+ });
25
+ }
13
26
 
14
- return __assign.apply(this, arguments);
15
- };
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) {
29
+ try {
30
+ step(generator.next(value));
31
+ } catch (e) {
32
+ reject(e);
33
+ }
34
+ }
16
35
 
17
- var __read = this && this.__read || function (o, n) {
18
- var m = typeof Symbol === "function" && o[Symbol.iterator];
19
- if (!m) return o;
20
- var i = m.call(o),
21
- r,
22
- ar = [],
23
- e;
24
-
25
- try {
26
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
27
- } catch (error) {
28
- e = {
29
- error: error
30
- };
31
- } finally {
32
- try {
33
- if (r && !r.done && (m = i["return"])) m.call(i);
34
- } finally {
35
- if (e) throw e.error;
36
+ function rejected(value) {
37
+ try {
38
+ step(generator["throw"](value));
39
+ } catch (e) {
40
+ reject(e);
41
+ }
36
42
  }
37
- }
38
43
 
39
- return ar;
40
- };
44
+ function step(result) {
45
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
46
+ }
41
47
 
42
- var __importDefault = this && this.__importDefault || function (mod) {
43
- return mod && mod.__esModule ? mod : {
44
- "default": mod
45
- };
48
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
49
+ });
46
50
  };
47
51
 
48
- exports.__esModule = true;
49
- exports.createContext = exports.getEnvironment = exports.getSecretVarNameForContext = exports.getSecretVarName = void 0;
52
+ var __generator = this && this.__generator || function (thisArg, body) {
53
+ var _ = {
54
+ label: 0,
55
+ sent: function () {
56
+ if (t[0] & 1) throw t[1];
57
+ return t[1];
58
+ },
59
+ trys: [],
60
+ ops: []
61
+ },
62
+ f,
63
+ y,
64
+ t,
65
+ g;
66
+ return g = {
67
+ next: verb(0),
68
+ "throw": verb(1),
69
+ "return": verb(2)
70
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
71
+ return this;
72
+ }), g;
73
+
74
+ function verb(n) {
75
+ return function (v) {
76
+ return step([n, v]);
77
+ };
78
+ }
50
79
 
51
- var lodash_1 = require("lodash");
80
+ function step(op) {
81
+ if (f) throw new TypeError("Generator is already executing.");
52
82
 
53
- var slugify_1 = __importDefault(require("slugify"));
83
+ while (_) try {
84
+ 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;
85
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
86
 
55
- var build_1 = require("../build");
87
+ switch (op[0]) {
88
+ case 0:
89
+ case 1:
90
+ t = op;
91
+ break;
56
92
 
57
- var deploy_1 = require("../deploy");
93
+ case 4:
94
+ _.label++;
95
+ return {
96
+ value: op[1],
97
+ done: false
98
+ };
58
99
 
59
- var config_1 = require("../types/config");
100
+ case 5:
101
+ _.label++;
102
+ y = op[1];
103
+ op = [0];
104
+ continue;
60
105
 
61
- var utils_1 = require("../utils");
106
+ case 7:
107
+ op = _.ops.pop();
62
108
 
63
- var resolveReferences_1 = require("./resolveReferences");
109
+ _.trys.pop();
64
110
 
65
- var sanitizeForEnVar = function (s) {
66
- return s.replace(/-/g, "_");
67
- };
111
+ continue;
68
112
 
69
- var getSecretVarName = function (env, componentName, key) {
70
- return "CL_".concat(sanitizeForEnVar(env), "_").concat(sanitizeForEnVar(componentName), "_").concat(key);
71
- }; // remove dash from component name
113
+ default:
114
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
115
+ _ = 0;
116
+ continue;
117
+ }
72
118
 
119
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
120
+ _.label = op[1];
121
+ break;
122
+ }
73
123
 
74
- exports.getSecretVarName = getSecretVarName;
124
+ if (op[0] === 6 && _.label < t[1]) {
125
+ _.label = t[1];
126
+ t = op;
127
+ break;
128
+ }
75
129
 
76
- var getSecretVarNameForContext = function (context, key) {
77
- return (0, exports.getSecretVarName)(context.environment.shortName, context.componentName, key);
78
- };
130
+ if (t && _.label < t[2]) {
131
+ _.label = t[2];
79
132
 
80
- exports.getSecretVarNameForContext = getSecretVarNameForContext;
133
+ _.ops.push(op);
81
134
 
82
- var getEnvironment = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
83
- ) {
84
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
135
+ break;
136
+ }
85
137
 
86
- if (alreadyVisited === void 0) {
87
- alreadyVisited = {};
88
- }
138
+ if (t[2]) _.ops.pop();
89
139
 
90
- var componentConfig = config.components[componentName];
140
+ _.trys.pop();
91
141
 
92
- if (!componentConfig) {
93
- throw new Error("unknown component " + componentName);
94
- }
142
+ continue;
143
+ }
95
144
 
96
- var defaultConfig = componentConfig;
97
- var envConfig = (_b = (_a = componentConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
145
+ op = body.call(thisArg, _);
146
+ } catch (e) {
147
+ op = [6, e];
148
+ y = 0;
149
+ } finally {
150
+ f = t = 0;
151
+ }
98
152
 
99
- if (envConfig === false) {
100
- throw new Error("env is disabled: " + env);
153
+ if (op[0] & 5) throw op[1];
154
+ return {
155
+ value: op[0] ? op[1] : void 0,
156
+ done: true
157
+ };
101
158
  }
159
+ };
102
160
 
103
- var mergedConfig = (0, utils_1.mergeWithMergingArrays)(defaultConfig, envConfig); // env type: if its set manually, use that, otherwise use the known env types
161
+ exports.__esModule = true;
162
+ exports.createContext = void 0;
104
163
 
105
- var envType = (_c = envConfig === null || envConfig === void 0 ? void 0 : envConfig.type) !== null && _c !== void 0 ? _c : (0, config_1.isKnowEnvType)(env) ? env : null;
164
+ var build_1 = require("../build");
106
165
 
107
- if (!envType) {
108
- throw new Error("Missing type in environment " + env + " in component " + componentName);
109
- }
166
+ var deploy_1 = require("../deploy");
110
167
 
111
- var basePredefinedVariables = {
112
- ENV_SHORT: env,
113
- APP_DIR: componentConfig.dir,
114
- ENV_TYPE: envType
115
- };
116
- var environmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
117
- var environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
118
- var predefinedVariables;
119
- var host;
120
- var url;
121
-
122
- if (envType === "local") {
123
- var devLocalConfig = mergedConfig;
124
- var port = (_d = devLocalConfig.port) !== null && _d !== void 0 ? _d : 3000;
125
- host = "localhost:" + port;
126
- url = "http://" + host;
127
- predefinedVariables = {
128
- ENV_SHORT: "local",
129
- ROOT_URL: url,
130
- PORT: port.toString()
131
- };
132
- } else {
133
- var RELEASE_NAME = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
134
- var componentSlug = (0, slugify_1["default"])(componentName);
135
- var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
136
- var 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
137
- config.domainCanonical || "panter.cloud";
138
- var HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(config.appName, ".").concat(config.customerName, ".").concat(domainCanonical);
139
- host = (_f = mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.host) !== null && _f !== void 0 ? _f : HOST_CANONICAL;
140
- var url_1 = "https://".concat(host); // FIXME: move to kube specific jobs
141
-
142
- var KUBE_APP_NAME = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-").concat(componentName) : componentName;
143
- var KUBE_NAMESPACE = (0, deploy_1.getKubernetesNamespace)(config, env);
144
- predefinedVariables = __assign(__assign({}, basePredefinedVariables), {
145
- HOST_CANONICAL: HOST_CANONICAL,
146
- ROOT_URL: url_1,
147
- KUBE_NAMESPACE: KUBE_NAMESPACE,
148
- KUBE_APP_NAME: KUBE_APP_NAME,
149
- RELEASE_NAME: RELEASE_NAME
150
- });
151
- }
168
+ var utils_1 = require("../utils");
152
169
 
153
- var publicEnvVarsRaw = (_h = (_g = mergedConfig.vars) === null || _g === void 0 ? void 0 : _g.public) !== null && _h !== void 0 ? _h : {};
154
- var secretEnvVarKeys = (_k = (_j = mergedConfig.vars) === null || _j === void 0 ? void 0 : _j.secret) !== null && _k !== void 0 ? _k : [];
155
- var secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
156
- return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
157
- })); // this is deprecated, we now support: $componentname:FOO
158
-
159
- var legacyFromComponents = (_m = (_l = mergedConfig.vars) === null || _l === void 0 ? void 0 : _l.fromComponents) !== null && _m !== void 0 ? _m : {};
160
- var publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
161
- var publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
162
- var _b = __read(_a, 2),
163
- key = _b[0],
164
- value = _b[1];
165
-
166
- return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
167
- }));
168
-
169
- var envVarsRaw = __assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized);
170
-
171
- var envVars = (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (componentName, variableName, alreadyVisited) {
172
- var envVars = (0, exports.getEnvironment)(config, componentName, env, commitInfo, alreadyVisited).envVars;
173
- return envVars[variableName];
174
- }, alreadyVisited);
175
- return {
176
- envType: envType,
177
- host: host,
178
- fullName: environmentName,
179
- slug: environmentSlug,
180
- shortName: env,
181
- url: predefinedVariables.ROOT_URL,
182
- envVars: envVars,
183
- secretEnvVarKeys: secretEnvVarKeys
184
- };
185
- };
170
+ var getEnvironment_1 = require("./getEnvironment");
186
171
 
187
- exports.getEnvironment = getEnvironment;
172
+ var getEnvironmentContext_1 = require("./getEnvironmentContext");
188
173
 
189
- var createContext = function (config, componentName, env, commitInfo, packageManagerInfo) {
190
- var _a, _b;
174
+ __exportStar(require("./getEnvironment"), exports);
191
175
 
192
- if (!/^[a-z0-9-]+$/.test(componentName)) {
193
- throw new Error("componentName may only contain lower case letters, numbers and -");
194
- }
176
+ __exportStar(require("./getEnvironmentVariables"), exports);
195
177
 
196
- var rawConfig = config.components[componentName];
197
-
198
- if (!rawConfig) {
199
- throw new Error("unknown component " + componentName);
200
- } // envs can override the config
201
-
202
-
203
- var envConfig = (_b = (_a = rawConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
204
- var componentConfigWithoutDefaults = (0, utils_1.mergeWithMergingArrays)(rawConfig, envConfig); // fill in defaults of build and deploy
205
-
206
- var defaults = componentConfigWithoutDefaults.deploy ? {
207
- build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(),
208
- deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults()
209
- } : {
210
- build: {},
211
- deploy: {}
212
- };
213
- var componentConfig = (0, utils_1.mergeWithMergingArrays)(defaults, componentConfigWithoutDefaults);
214
- return {
215
- fullConfig: config,
216
- componentConfig: componentConfig,
217
- componentName: componentName,
218
- environment: (0, exports.getEnvironment)(config, componentName, env, commitInfo),
219
- commitInfo: commitInfo,
220
- packageManagerInfo: packageManagerInfo
221
- };
178
+ var createContext = function (config, componentName, env, commitInfo, packageManagerInfo) {
179
+ return __awaiter(void 0, void 0, void 0, function () {
180
+ var envContext, componentConfigWithoutDefaults, defaults, componentConfig;
181
+
182
+ var _a;
183
+
184
+ return __generator(this, function (_b) {
185
+ switch (_b.label) {
186
+ case 0:
187
+ if (!/^[a-z0-9-]+$/.test(componentName)) {
188
+ throw new Error("componentName may only contain lower case letters, numbers and -");
189
+ }
190
+
191
+ envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
192
+ componentConfigWithoutDefaults = envContext.envConfigRaw;
193
+ defaults = componentConfigWithoutDefaults.deploy ? {
194
+ build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(envContext),
195
+ deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults(envContext)
196
+ } : {
197
+ build: {},
198
+ deploy: {}
199
+ };
200
+ componentConfig = (0, utils_1.mergeWithMergingArrays)(defaults, componentConfigWithoutDefaults);
201
+ _a = {
202
+ fullConfig: config,
203
+ componentConfig: componentConfig,
204
+ componentName: componentName
205
+ };
206
+ return [4
207
+ /*yield*/
208
+ , (0, getEnvironment_1.getEnvironment)(config, componentName, env, commitInfo)];
209
+
210
+ case 1:
211
+ return [2
212
+ /*return*/
213
+ , (_a.environment = _b.sent(), _a.commitInfo = commitInfo, _a.packageManagerInfo = packageManagerInfo, _a)];
214
+ }
215
+ });
216
+ });
222
217
  };
223
218
 
224
219
  exports.createContext = createContext;
@@ -1,6 +1,4 @@
1
- export declare const resolveReferences: (vars: Record<string, string>, getOtherVariables?: ((componentName: string, variableName: string, alreadyVisited: Record<string, Record<string, boolean>>) => string | null) | undefined, alreadyVisitedBase?: Record<string, Record<string, boolean>>) => {
2
- [k: string]: string;
3
- };
1
+ export declare const resolveReferences: (vars: Record<string, string>, getOtherVariables?: ((componentName: string, variableName: string, alreadyVisited: Record<string, Record<string, boolean>>) => Promise<string | null>) | undefined, alreadyVisitedBase?: Record<string, Record<string, boolean>>) => Promise<Record<string, string>>;
4
2
  export declare const translateLegacyFromComponents: (fromComponents: Record<string, Record<string, string>>) => {
5
3
  [k: string]: string;
6
4
  };