@catladder/pipeline 0.0.0-next-9a3feef4 → 0.0.0-next-e2e4f00a

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 (97) hide show
  1. package/dist/build/base/createAppBuildJob.js +3 -3
  2. package/dist/build/custom/testJob.js +12 -12
  3. package/dist/build/node/testJob.js +11 -11
  4. package/dist/build/rails/build.js +1 -1
  5. package/dist/build/rails/test.js +8 -8
  6. package/dist/build/types.d.ts +10 -0
  7. package/dist/bundles/catladder-gitlab/index.js +150 -71
  8. package/dist/constants.js +1 -1
  9. package/dist/context/__tests__/resolveReferences.test.js +22 -0
  10. package/dist/context/createComponentContext.js +1 -0
  11. package/dist/context/getEnvironment.js +2 -1
  12. package/dist/context/getEnvironmentVariables.d.ts +5 -2
  13. package/dist/context/getEnvironmentVariables.js +24 -17
  14. package/dist/context/resolveReferences.d.ts +4 -1
  15. package/dist/context/resolveReferences.js +16 -2
  16. package/dist/deploy/base/deploy.js +3 -3
  17. package/dist/deploy/cloudRun/index.js +2 -2
  18. package/dist/deploy/kubernetes/cloudSql/index.js +14 -3
  19. package/dist/deploy/kubernetes/deployJob.js +3 -1
  20. package/dist/deploy/kubernetes/index.js +2 -2
  21. package/dist/deploy/kubernetes/kubeValues.d.ts +2 -1
  22. package/dist/deploy/kubernetes/kubeValues.js +3 -2
  23. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +85 -0
  24. package/dist/deploy/kubernetes/processSecretsAsFiles.js +33 -0
  25. package/dist/deploy/types/base.d.ts +6 -0
  26. package/dist/deploy/types/kubernetes.d.ts +34 -1
  27. package/dist/pipeline/gitlab/createGitlabJobs.js +5 -3
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/dist/types/config.d.ts +8 -0
  30. package/dist/types/context.d.ts +8 -0
  31. package/dist/types/jobs.d.ts +8 -0
  32. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +52 -36
  33. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +52 -36
  34. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +52 -36
  35. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +52 -36
  36. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +52 -36
  37. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +52 -36
  38. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +52 -36
  39. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +52 -36
  40. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +52 -36
  41. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +52 -36
  42. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +52 -36
  43. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +52 -36
  44. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +104 -72
  45. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +68 -48
  46. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +52 -36
  47. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +52 -36
  48. package/examples/__snapshots__/custom-build-job.test.ts.snap +52 -36
  49. package/examples/__snapshots__/custom-deploy.test.ts.snap +32 -24
  50. package/examples/__snapshots__/custom-envs.test.ts.snap +24 -18
  51. package/examples/__snapshots__/custom-sbom-java.test.ts.snap +52 -36
  52. package/examples/__snapshots__/git-submodule.test.ts.snap +52 -36
  53. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +96 -60
  54. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.test.ts.snap +1791 -0
  55. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +96 -60
  56. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +192 -120
  57. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +96 -60
  58. package/examples/__snapshots__/local-dot-env.test.ts.snap +52 -36
  59. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +96 -60
  60. package/examples/__snapshots__/multiline-var.test.ts.snap +148 -96
  61. package/examples/__snapshots__/native-app.test.ts.snap +100 -72
  62. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +52 -36
  63. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +52 -36
  64. package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +80 -48
  65. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +80 -48
  66. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +64 -48
  67. package/examples/__snapshots__/workspace-api-www-custom-cache.test.ts.snap +104 -72
  68. package/examples/__snapshots__/workspace-api-www.test.ts.snap +104 -72
  69. package/examples/kubernetes-with-cloud-sql-legacy.test.ts +11 -0
  70. package/examples/kubernetes-with-cloud-sql-legacy.ts +35 -0
  71. package/examples/native-app.ts +6 -10
  72. package/examples/rails-k8s-with-worker.ts +1 -5
  73. package/package.json +1 -1
  74. package/src/build/base/createAppBuildJob.ts +1 -0
  75. package/src/build/custom/testJob.ts +1 -0
  76. package/src/build/node/testJob.ts +1 -0
  77. package/src/build/rails/build.ts +1 -0
  78. package/src/build/rails/test.ts +1 -0
  79. package/src/build/types.ts +13 -0
  80. package/src/context/__tests__/resolveReferences.test.ts +27 -1
  81. package/src/context/createComponentContext.ts +1 -0
  82. package/src/context/getEnvironment.ts +1 -1
  83. package/src/context/getEnvironmentVariables.ts +34 -13
  84. package/src/context/resolveReferences.ts +13 -0
  85. package/src/deploy/base/deploy.ts +1 -1
  86. package/src/deploy/cloudRun/index.ts +2 -2
  87. package/src/deploy/kubernetes/cloudSql/index.ts +15 -1
  88. package/src/deploy/kubernetes/deployJob.ts +2 -0
  89. package/src/deploy/kubernetes/index.ts +2 -2
  90. package/src/deploy/kubernetes/kubeValues.ts +8 -5
  91. package/src/deploy/kubernetes/processSecretsAsFiles.ts +35 -0
  92. package/src/deploy/types/base.ts +6 -0
  93. package/src/deploy/types/kubernetes.ts +36 -1
  94. package/src/pipeline/gitlab/createGitlabJobs.ts +4 -1
  95. package/src/types/config.ts +8 -0
  96. package/src/types/context.ts +8 -1
  97. package/src/types/jobs.ts +8 -0
@@ -160,6 +160,7 @@ Object.defineProperty(exports, "__esModule", {
160
160
  value: true
161
161
  });
162
162
  exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironmentVariables = void 0;
163
+ var lodash_1 = require("lodash");
163
164
  var deploy_1 = require("../deploy");
164
165
  var BashExpression_1 = require("../bash/BashExpression");
165
166
  var types_1 = require("../build/types");
@@ -181,14 +182,14 @@ var getEnvironmentVariables = function (ctx_1) {
181
182
  args_1[_i - 1] = arguments[_i];
182
183
  }
183
184
  return __awaiter(void 0, __spreadArray([ctx_1], __read(args_1), false), void 0, function (ctx, alreadyVisited) {
184
- var environmentContext, config, env, componentName, envConfigRaw, deployConfigRaw, buildConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, HOSTNAME_INTERNAL, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, publicEnvVarsRawSanitized, envVarsRaw, envVars;
185
+ var environmentContext, config, env, componentName, envConfigRaw, deployConfigRaw, buildConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, HOST_INTERNAL, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegacyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
185
186
  var _a, _b;
186
- var _c, _d, _e, _f, _g, _h, _j;
187
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l;
187
188
  if (alreadyVisited === void 0) {
188
189
  alreadyVisited = {};
189
190
  }
190
- return __generator(this, function (_k) {
191
- switch (_k.label) {
191
+ return __generator(this, function (_m) {
192
+ switch (_m.label) {
192
193
  case 0:
193
194
  environmentContext = (0, getEnvironmentContext_1.getEnvironmentContext)(ctx);
194
195
  config = ctx.config, env = ctx.env, componentName = ctx.componentName;
@@ -199,32 +200,38 @@ var getEnvironmentVariables = function (ctx_1) {
199
200
  port = (_c = devLocalConfig.port) !== null && _c !== void 0 ? _c : 3000;
200
201
  host = "localhost:" + port.toString();
201
202
  url = "http://" + host;
202
- predefinedVariables = __assign(__assign({}, basePredefinedVariables), {
203
+ predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), {
203
204
  ENV_SHORT: "local",
204
- ROOT_URL: url,
205
- HOSTNAME: host,
206
- HOSTNAME_INTERNAL: host,
205
+ ROOT_URL: url
206
+ }), (0, types_1.isStandaloneBuildConfig)(buildConfigRaw) && buildConfigRaw.type === "rails" ? {} : {
207
+ HOST: host
208
+ }), {
209
+ HOST_INTERNAL: host,
207
210
  ROOT_URL_INTERNAL: "http://" + host,
208
211
  PORT: port.toString()
209
212
  });
210
213
  } else {
211
214
  additionalEnvVars = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext) : {};
212
- HOSTNAME_INTERNAL = (_d = additionalEnvVars.HOSTNAME_INTERNAL) !== null && _d !== void 0 ? _d : "unknown-host.example.com";
213
- host = (_e = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _e !== void 0 ? _e : HOSTNAME_INTERNAL;
215
+ HOST_INTERNAL = (_d = additionalEnvVars.HOST_INTERNAL) !== null && _d !== void 0 ? _d : "unknown-host.example.com";
216
+ host = (_e = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _e !== void 0 ? _e : HOST_INTERNAL;
214
217
  url = (0, BashExpression_1.joinBashExpressions)(["https://", host]);
215
218
  predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), (0, types_1.isStandaloneBuildConfig)(buildConfigRaw) && buildConfigRaw.type === "rails" ? {} : {
216
- HOSTNAME: host
219
+ HOST: host
217
220
  }), {
218
221
  ROOT_URL: url,
219
- HOSTNAME_INTERNAL: HOSTNAME_INTERNAL,
220
- ROOT_URL_INTERNAL: (0, BashExpression_1.joinBashExpressions)(["https://", HOSTNAME_INTERNAL])
222
+ HOST_INTERNAL: HOST_INTERNAL,
223
+ /**@deprecated */
224
+ HOST_CANONICAL: HOST_INTERNAL,
225
+ ROOT_URL_INTERNAL: (0, BashExpression_1.joinBashExpressions)(["https://", HOST_INTERNAL])
221
226
  }), additionalEnvVars);
222
227
  }
223
228
  publicEnvVarsRaw = (_g = (_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.public) !== null && _g !== void 0 ? _g : {};
224
229
  additionalSecretKeys = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(environmentContext) : [];
225
230
  secretEnvVarKeys = __spreadArray(__spreadArray([], __read((0, envVars_1.stringListToSecreteEnvVarList)((_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.secret) !== null && _j !== void 0 ? _j : [])), false), __read(additionalSecretKeys), false);
226
231
  secretEnvVars = (0, envVars_1.makeSecretEnvVarMapping)(env, componentName, secretEnvVarKeys);
227
- publicEnvVarsRawSanitized = (0, envVars_1.stringifyValues)(publicEnvVarsRaw);
232
+ legacyFromComponents = (_l = (_k = envConfigRaw.vars) === null || _k === void 0 ? void 0 : _k.fromComponents) !== null && _l !== void 0 ? _l : {};
233
+ publicEnvVarsRawWithLegacyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
234
+ publicEnvVarsRawSanitized = (0, envVars_1.stringifyValues)(publicEnvVarsRawWithLegacyFromComponents);
228
235
  envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
229
236
  return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, alreadyVisited) {
230
237
  return __awaiter(void 0, void 0, void 0, function () {
@@ -243,7 +250,7 @@ var getEnvironmentVariables = function (ctx_1) {
243
250
  });
244
251
  }, alreadyVisited)];
245
252
  case 1:
246
- envVars = _k.sent();
253
+ envVars = _m.sent();
247
254
  _a = {
248
255
  envVars: envVars,
249
256
  secretEnvVarKeys: secretEnvVarKeys
@@ -251,10 +258,10 @@ var getEnvironmentVariables = function (ctx_1) {
251
258
  _b = {};
252
259
  return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, buildConfigRaw && (0, types_1.isStandaloneBuildConfig)(buildConfigRaw) && buildConfigRaw.jobVars || null)];
253
260
  case 2:
254
- _b.build = _k.sent();
261
+ _b.build = _m.sent();
255
262
  return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, deployConfigRaw && deployConfigRaw.jobVars || null)];
256
263
  case 3:
257
- return [2 /*return*/, (_a.jobOnlyVars = (_b.deploy = _k.sent(), _b), _a.host = host, _a.url = url, _a)];
264
+ return [2 /*return*/, (_a.jobOnlyVars = (_b.deploy = _m.sent(), _b), _a.host = host, _a.url = url, _a)];
258
265
  }
259
266
  });
260
267
  });
@@ -1,3 +1,6 @@
1
1
  import type { BashExpression } from "../bash/BashExpression";
2
2
  import type { UnspecifiedEnvVars } from "..";
3
- export declare const resolveReferences: (vars: Record<string, string | BashExpression | undefined | null>, getOtherVariables?: (componentName: string, alreadyVisited: Record<string, Record<string, boolean>>) => Promise<UnspecifiedEnvVars>, alreadyVisitedBase?: Record<string, Record<string, boolean>>) => Promise<Record<string, BashExpression>>;
3
+ export declare const resolveReferences: (vars: Record<string, string | BashExpression | undefined | null>, getOtherVariables?: (componentName: string, alreadyVisited: Record<string, Record<string, boolean>>) => Promise<UnspecifiedEnvVars>, alreadyVisitedBase?: Record<string, Record<string, boolean>>) => Promise<Record<string, BashExpression>>;
4
+ export declare const translateLegacyFromComponents: (fromComponents: Record<string, Record<string, string>>) => {
5
+ [k: string]: string;
6
+ };
@@ -154,7 +154,7 @@ var __importDefault = this && this.__importDefault || function (mod) {
154
154
  Object.defineProperty(exports, "__esModule", {
155
155
  value: true
156
156
  });
157
- exports.resolveReferences = void 0;
157
+ exports.translateLegacyFromComponents = exports.resolveReferences = void 0;
158
158
  var lodash_1 = require("lodash");
159
159
  var replaceAsync_1 = __importDefault(require("../bash/replaceAsync"));
160
160
  // regex to resolve references in catladder variables
@@ -269,4 +269,18 @@ var resolveReferences = function (vars_1, getOtherVariables_1) {
269
269
  });
270
270
  });
271
271
  };
272
- exports.resolveReferences = resolveReferences;
272
+ exports.resolveReferences = resolveReferences;
273
+ var translateLegacyFromComponents = function (fromComponents) {
274
+ return Object.fromEntries(Object.entries(fromComponents).flatMap(function (_a) {
275
+ var _b = __read(_a, 2),
276
+ componentName = _b[0],
277
+ variables = _b[1];
278
+ return Object.entries(variables).map(function (_a) {
279
+ var _b = __read(_a, 2),
280
+ ourName = _b[0],
281
+ otherName = _b[1];
282
+ return [ourName, "${" + componentName + ":" + otherName + "}"];
283
+ });
284
+ }));
285
+ };
286
+ exports.translateLegacyFromComponents = translateLegacyFromComponents;
@@ -54,7 +54,7 @@ var stop_1 = require("./stop");
54
54
  var variables_1 = require("./variables");
55
55
  exports.DEPLOY_JOB_NAME = "🚀 Deploy";
56
56
  var createDeployJob = function (context, jobDefinition) {
57
- var _a, _b, _c, _d, _e, _f;
57
+ var _a, _b, _c, _d, _e, _f, _g;
58
58
  var hasDocker = (0, docker_1.requiresDockerBuild)(context);
59
59
  var isStoppable = (0, utils_1.contextIsStoppable)(context);
60
60
  var autoStop = context.environment.envType === "review" ? "1 week" : context.environment.envType === "dev" ? "4 weeks" : undefined;
@@ -109,8 +109,8 @@ var createDeployJob = function (context, jobDefinition) {
109
109
  when: whenDeploy === "auto" ? "on_success" : "manual",
110
110
  allow_failure: whenDeploy === "manual" ? true : false,
111
111
  stage: "deploy",
112
- variables: __assign(__assign(__assign(__assign({}, context.environment.envVars), hasDocker ? (0, docker_1.getDockerImageVariables)(context) : {}), context.environment.jobOnlyVars.deploy.envVars), jobDefinition.variables),
113
- runnerVariables: __assign(__assign(__assign({}, variables_1.DEPLOY_RUNNER_VARIABLES), (_e = jobDefinition.runnerVariables) !== null && _e !== void 0 ? _e : {}), deployConfig ? (_f = deployConfig.runnerVariables) !== null && _f !== void 0 ? _f : {} : {}),
112
+ variables: __assign(__assign(__assign(__assign(__assign({}, context.environment.envVars), hasDocker ? (0, docker_1.getDockerImageVariables)(context) : {}), context.environment.jobOnlyVars.deploy.envVars), deployConfig ? (_e = deployConfig.extraVars) !== null && _e !== void 0 ? _e : {} : {}), jobDefinition.variables),
113
+ runnerVariables: __assign(__assign(__assign({}, variables_1.DEPLOY_RUNNER_VARIABLES), (_f = jobDefinition.runnerVariables) !== null && _f !== void 0 ? _f : {}), deployConfig ? (_g = deployConfig.runnerVariables) !== null && _g !== void 0 ? _g : {} : {}),
114
114
  environment: isStoppable ? {
115
115
  on_stop: stop_1.STOP_JOB_NAME,
116
116
  auto_stop_in: autoStop
@@ -111,7 +111,7 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
111
111
  env = ctx.env,
112
112
  componentName = ctx.componentName,
113
113
  deployConfigRaw = ctx.deployConfigRaw;
114
- var HOSTNAME_INTERNAL = (0, BashExpression_1.joinBashExpressions)([fullName, (0, BashExpression_1.getBashVariable)((0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX))], "-").toLowerCase();
114
+ var HOST_INTERNAL = (0, BashExpression_1.joinBashExpressions)([fullName, (0, BashExpression_1.getBashVariable)((0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX))], "-").toLowerCase();
115
115
  var jobTriggers = deployConfigRaw && deployConfigRaw.jobs ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(function (_a) {
116
116
  var _b = __read(_a, 2),
117
117
  name = _b[0],
@@ -119,7 +119,7 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
119
119
  return ["CLOUD_RUN_JOB_TRIGGER_URL_" + (0, gitlab_1.sanitizeForBashVariable)(name), "https://".concat(deployConfigRaw.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfigRaw.projectId, "/jobs/").concat((0, jobName_1.getCloudRunJobName)(fullName, name), ":run")];
120
120
  })) : {};
121
121
  return __assign(__assign(__assign({
122
- HOSTNAME_INTERNAL: HOSTNAME_INTERNAL
122
+ HOST_INTERNAL: HOST_INTERNAL
123
123
  }, getCloudSqlVariables(ctx)), jobTriggers), {
124
124
  DEPLOY_CLOUD_RUN_PROJECT_ID: deployConfigRaw ? deployConfigRaw.projectId : undefined,
125
125
  DEPLOY_CLOUD_RUN_REGION: deployConfigRaw ? deployConfigRaw.region : undefined
@@ -17,7 +17,7 @@ var hasKubernetesCloudSQL = function (context) {
17
17
  };
18
18
  exports.hasKubernetesCloudSQL = hasKubernetesCloudSQL;
19
19
  var createKubernetesCloudsqlBaseValues = function (context) {
20
- var _a, _b, _c;
20
+ var _a, _b, _c, _d, _e, _f, _g;
21
21
  var deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config;
22
22
  if (!(0, types_1.isOfDeployType)(deployConfig, "kubernetes")) {
23
23
  throw new Error("cannot get cloud sql config");
@@ -27,11 +27,22 @@ var createKubernetesCloudsqlBaseValues = function (context) {
27
27
  throw new Error("cannot get cloud sql config");
28
28
  }
29
29
  var proxyCredentials = "$".concat((0, context_1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials"));
30
- if (config.type === "unmanaged") {
30
+ if ((config === null || config === void 0 ? void 0 : config.type) !== "unmanaged") {
31
+ var instanceConnectionName = "".concat((_c = config.projectId) !== null && _c !== void 0 ? _c : "skynet-164509", ":").concat((_d = config.region) !== null && _d !== void 0 ? _d : "europe-west6", ":").concat((_e = config.instanceId) !== null && _e !== void 0 ? _e : context.environment.envVars.KUBE_NAMESPACE);
32
+ return {
33
+ cloudsql: {
34
+ enabled: config.enabled,
35
+ dbUser: "postgres",
36
+ instanceConnectionName: instanceConnectionName,
37
+ proxyCredentials: proxyCredentials,
38
+ fullDbName: (_f = context.environment.envVars.KUBE_APP_NAME) !== null && _f !== void 0 ? _f : ""
39
+ }
40
+ };
41
+ } else if (config.type === "unmanaged") {
31
42
  return {
32
43
  cloudsql: {
33
44
  enabled: config.enabled,
34
- dbUser: (_c = config.dbUser) !== null && _c !== void 0 ? _c : "postgres",
45
+ dbUser: (_g = config.dbUser) !== null && _g !== void 0 ? _g : "postgres",
35
46
  instanceConnectionName: config.instanceConnectionName,
36
47
  proxyCredentials: proxyCredentials,
37
48
  fullDbName: (0, utils_1.getFullDbName)(config, context.fullConfig, context.environment.slugPrefix, context.name)
@@ -77,7 +77,9 @@ var createKubernetesDeployJobs = function (context) {
77
77
  KUBE_DOCKER_IMAGE_PULL_SECRET: "gitlab-registry-".concat(context.name),
78
78
  HELM_GITLAB_CHART_NAME: (_b = deployConfig.chartName) !== null && _b !== void 0 ? _b : "/helm-charts/the-panter-chart",
79
79
  HELM_ARGS: __spreadArray(__spreadArray([], __read(deployConfig.debug ? ["--debug"] : []), false), __read((_c = deployConfig.additionalHelmArgs) !== null && _c !== void 0 ? _c : []), false).join(" "),
80
- COMPONENT_NAME: context.name
80
+ COMPONENT_NAME: context.name,
81
+ /** @deprecated */
82
+ BUILD_ID: context.environment.envVars.BUILD_INFO_BUILD_ID
81
83
  })
82
84
  });
83
85
  var clusterName = "kube-".concat(context.environment.fullName);
@@ -86,12 +86,12 @@ exports.KUBERNETES_DEPLOY_TYPE = {
86
86
  var domainCanonical = deployConfigRaw && ((_b = deployConfigRaw.cluster) === null || _b === void 0 ? void 0 : _b.domainCanonical) ||
87
87
  // 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
88
88
  fullConfig.domainCanonical || "panter.cloud";
89
- var HOSTNAME_INTERNAL = (0, BashExpression_1.joinBashExpressions)(__spreadArray(__spreadArray([componentSlug], __read(envType === "review" && reviewSlug ? [reviewSlug] : []), false), [env, fullConfig.appName, fullConfig.customerName, domainCanonical], false), "."); // default for kubernetes and rest
89
+ var HOST_INTERNAL = (0, BashExpression_1.joinBashExpressions)(__spreadArray(__spreadArray([componentSlug], __read(envType === "review" && reviewSlug ? [reviewSlug] : []), false), [env, fullConfig.appName, fullConfig.customerName, domainCanonical], false), "."); // default for kubernetes and rest
90
90
  return {
91
91
  KUBE_NAMESPACE: KUBE_NAMESPACE,
92
92
  KUBE_APP_NAME: KUBE_APP_NAME,
93
93
  KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX,
94
- HOSTNAME_INTERNAL: HOSTNAME_INTERNAL
94
+ HOST_INTERNAL: HOST_INTERNAL
95
95
  };
96
96
  }
97
97
  };
@@ -62,7 +62,7 @@ export declare const createKubeValues: (context: ComponentContext) => never[] |
62
62
  } | undefined;
63
63
  }> | undefined;
64
64
  } & {
65
- cloudsql?: import("../types").DeployConfigKubernetesValuesCloudSQLUnmanaged | undefined;
65
+ cloudsql?: import("../types").DeployConfigKubernetesValuesCloudSQL | undefined;
66
66
  mongodb?: import("../types").DeployConfigMongodb | undefined;
67
67
  mailhog?: {
68
68
  enabled: boolean;
@@ -73,6 +73,7 @@ export declare const createKubeValues: (context: ComponentContext) => never[] |
73
73
  mapServiceUrlToEnv?: {
74
74
  [envVar: string]: string;
75
75
  } | undefined;
76
+ secretsAsFile?: string[] | undefined;
76
77
  jobs: {
77
78
  [k: string]: false | import("../types/base").AllowUnknownProps<{
78
79
  command: string;
@@ -50,6 +50,7 @@ var types_1 = require("../types");
50
50
  var cloudSql_1 = require("./cloudSql");
51
51
  var kubeEnv_1 = require("./kubeEnv");
52
52
  var mongodb_1 = require("./mongodb");
53
+ var processSecretsAsFiles_1 = require("./processSecretsAsFiles");
53
54
  var createAppConfig = function (context, application) {
54
55
  if (application === false) {
55
56
  return {
@@ -113,10 +114,10 @@ var createKubeValues = function (context) {
113
114
  env: env,
114
115
  application: createAppConfig(context, application)
115
116
  }, (0, cloudSql_1.hasKubernetesCloudSQL)(context) ? (0, cloudSql_1.createKubernetesCloudsqlBaseValues)(context) : {}, ((_c = (_b = deployConfig.values) === null || _b === void 0 ? void 0 : _b.mongodb) === null || _c === void 0 ? void 0 : _c.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
116
- var kubeValues = (0, utils_1.mergeWithMergingArrays)(defaultKubeValues, __assign({
117
+ var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, __assign({
117
118
  jobs: removeFalsy(jobs),
118
119
  cronjobs: removeFalsy(cronjobs)
119
- }, rest));
120
+ }, rest)));
120
121
  return kubeValues;
121
122
  };
122
123
  exports.createKubeValues = createKubeValues;
@@ -0,0 +1,85 @@
1
+ import type { StringOrBashExpression } from "../../bash/BashExpression";
2
+ export declare const processSecretsAsFiles: <T extends {
3
+ env: {
4
+ secret: Record<string, StringOrBashExpression>;
5
+ };
6
+ } & {
7
+ cloudsql?: import("../types").DeployConfigKubernetesValuesCloudSQL | undefined;
8
+ mongodb?: import("../types").DeployConfigMongodb | undefined;
9
+ mailhog?: {
10
+ enabled: boolean;
11
+ } | undefined;
12
+ jobs?: Record<string, false | import("../types/base").AllowUnknownProps<{
13
+ command: string;
14
+ hook?: string | undefined;
15
+ }>> | undefined;
16
+ cronjobs?: Record<string, false | import("../types/base").AllowUnknownProps<{
17
+ schedule: string;
18
+ command: string;
19
+ concurrencyPolicy?: "Forbid" | "Allow" | "Replace" | undefined;
20
+ }>> | undefined;
21
+ application?: false | import("../types/base").AllowUnknownProps<{
22
+ command?: string | undefined;
23
+ enabled?: boolean | undefined;
24
+ redirects?: import("../types").KubernetesRedirect[] | undefined;
25
+ hostAliases?: string[] | undefined;
26
+ replicas?: number | undefined;
27
+ autoscale?: import("../types").KubernetesAutoscale | undefined;
28
+ updateStrategy?: import("../types").KubernetesUpdateStrategy | undefined;
29
+ resources?: import("../types").KubernetesResourcesDef | undefined;
30
+ healthRoute?: string | undefined;
31
+ startupProbe?: {
32
+ httpGet?: {
33
+ path?: string | undefined;
34
+ port?: number | undefined;
35
+ httpHeaders?: {
36
+ name: string;
37
+ value: string;
38
+ }[] | undefined;
39
+ failureThreshold?: number | undefined;
40
+ timeoutSeconds?: number | undefined;
41
+ periodSeconds?: number | undefined;
42
+ successThreshold?: number | undefined;
43
+ } | undefined;
44
+ } | undefined;
45
+ readinessProbe?: {
46
+ httpGet?: {
47
+ path?: string | undefined;
48
+ port?: number | undefined;
49
+ httpHeaders?: {
50
+ name: string;
51
+ value: string;
52
+ }[] | undefined;
53
+ failureThreshold?: number | undefined;
54
+ timeoutSeconds?: number | undefined;
55
+ periodSeconds?: number | undefined;
56
+ successThreshold?: number | undefined;
57
+ } | undefined;
58
+ } | undefined;
59
+ livenessProbe?: {
60
+ httpGet?: {
61
+ path?: string | undefined;
62
+ port?: number | undefined;
63
+ httpHeaders?: {
64
+ name: string;
65
+ value: string;
66
+ }[] | undefined;
67
+ failureThreshold?: number | undefined;
68
+ timeoutSeconds?: number | undefined;
69
+ periodSeconds?: number | undefined;
70
+ successThreshold?: number | undefined;
71
+ } | undefined;
72
+ } | undefined;
73
+ worker?: import("../types").KubernetesWorkerDef | undefined;
74
+ jobDefaults?: {
75
+ resources: import("../types").KubernetesResourcesDef;
76
+ } | undefined;
77
+ }> | undefined;
78
+ secretsFromOtherComponent?: {
79
+ [envVar: string]: string;
80
+ } | undefined;
81
+ mapServiceUrlToEnv?: {
82
+ [envVar: string]: string;
83
+ } | undefined;
84
+ secretsAsFile?: string[] | undefined;
85
+ } & Record<string, unknown>>(values: T) => T;
@@ -0,0 +1,33 @@
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
+ Object.defineProperty(exports, "__esModule", {
14
+ value: true
15
+ });
16
+ exports.processSecretsAsFiles = void 0;
17
+ var lodash_1 = require("lodash");
18
+ var processSecretsAsFiles = function (values) {
19
+ if (!values.secretsAsFile || values.secretsAsFile.length === 0) {
20
+ return values;
21
+ }
22
+ // the initial idea was that we "shadow" secrets that we mount as files,
23
+ // but there is a weird kubernetes issue with that (https://github.com/kubernetes/kubernetes/issues/46861),
24
+ // so instead we rename the secrets and append _content, so that inside kuberentes, we can use the original name to contain the path and name+_content as the actual content
25
+ return __assign(__assign({}, values), {
26
+ env: __assign(__assign({}, values.env), {
27
+ secret: __assign(__assign({}, (0, lodash_1.omit)(values.env.secret, values.secretsAsFile)), Object.fromEntries(values.secretsAsFile.map(function (key) {
28
+ return [key + "_content", values.env.secret[key]];
29
+ })))
30
+ })
31
+ });
32
+ };
33
+ exports.processSecretsAsFiles = processSecretsAsFiles;
@@ -20,6 +20,12 @@ export type DeployConfigBase = {
20
20
  * Can curently not reference other variables from other components
21
21
  */
22
22
  jobVars?: EnvVars;
23
+ /**
24
+ * additional env vars for the deploy job
25
+ *
26
+ * @deprecated use deploy.jobVars for deploy job specific variables
27
+ */
28
+ extraVars?: Record<string, string>;
23
29
  /**
24
30
  * additional vars only for the runner.
25
31
  * Also if you use services: that require env vars, you need to set them here.
@@ -152,6 +152,32 @@ export type DeployConfigMongodbReplicaset = {
152
152
  replicaCount?: number;
153
153
  };
154
154
  export type DeployConfigMongodb = DeployConfigMongodbBase & (DeployConfigMongodbStandalone | DeployConfigMongodbReplicaset);
155
+ /**
156
+ * @deprecated use config with instanceConnectionName
157
+ */
158
+ type DeployConfigKubernetesValuesCloudSQLLegacy = {
159
+ enabled: boolean;
160
+ /**
161
+ * @deprecated use config with instanceConnectionName
162
+ */
163
+ instanceId?: string;
164
+ /**
165
+ * @deprecated use config with instanceConnectionName
166
+ */
167
+ projectId?: string;
168
+ /**
169
+ * @deprecated use config with instanceConnectionName
170
+ */
171
+ region?: string;
172
+ /**
173
+ * @deprecated use type "unmanaged".
174
+ *
175
+ * Be aware that "unmanaged" is not fully backward compatible with "legacy".
176
+ *
177
+ *
178
+ */
179
+ type?: "legacy";
180
+ };
155
181
  export type DeployConfigKubernetesValuesCloudSQLUnmanaged = {
156
182
  enabled: boolean;
157
183
  instanceConnectionName: string;
@@ -178,7 +204,7 @@ export type DeployConfigKubernetesValuesCloudSQLUnmanaged = {
178
204
  */
179
205
  dbBaseName?: string;
180
206
  };
181
- export type DeployConfigKubernetesValuesCloudSQL = DeployConfigKubernetesValuesCloudSQLUnmanaged;
207
+ export type DeployConfigKubernetesValuesCloudSQL = DeployConfigKubernetesValuesCloudSQLLegacy | DeployConfigKubernetesValuesCloudSQLUnmanaged;
182
208
  export type DeployConfigKubernetesValues = AllowUnknownProps<{
183
209
  /**
184
210
  * enable cloudsql db. Currently you have to manually set it up
@@ -297,6 +323,13 @@ export type DeployConfigKubernetesValues = AllowUnknownProps<{
297
323
  mapServiceUrlToEnv?: {
298
324
  [envVar: string]: string;
299
325
  };
326
+ /**
327
+ * Mount secrets as files in the filesystem.
328
+ * These secrets are still available as env vars, but will contain the path of the file instead
329
+ *
330
+ * @deprecated this will be removed in the future, because its very niche and not used
331
+ */
332
+ secretsAsFile?: string[];
300
333
  }>;
301
334
  export type DeployConfigKubernetes = {
302
335
  type: "kubernetes";
@@ -235,6 +235,7 @@ var makeGitlabJob = function (context, job, allJobs, baseRules) {
235
235
  var environment = job.environment,
236
236
  envMode = job.envMode,
237
237
  needsStages = job.needsStages,
238
+ needsOtherComponent = job.needsOtherComponent,
238
239
  name = job.name,
239
240
  needs = job.needs,
240
241
  jobTags = job.jobTags,
@@ -242,7 +243,7 @@ var makeGitlabJob = function (context, job, allJobs, baseRules) {
242
243
  variables = job.variables,
243
244
  runnerVariables = job.runnerVariables,
244
245
  when = job.when,
245
- rest = __rest(job, ["environment", "envMode", "needsStages", "name", "needs", "jobTags", "script", "variables", "runnerVariables", "when"]);
246
+ rest = __rest(job, ["environment", "envMode", "needsStages", "needsOtherComponent", "name", "needs", "jobTags", "script", "variables", "runnerVariables", "when"]);
246
247
  var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(context.env) : job.stage;
247
248
  var deduplicatedGitlabNeeds = getGitlabNeeds(context, job, allJobs);
248
249
  var fullJobName = getFullJobName({
@@ -363,7 +364,8 @@ function deduplicateNeeds(needs) {
363
364
  }
364
365
  function getGitlabNeedsForComponentJob(context, _a, allJobs) {
365
366
  var needsStages = _a.needsStages,
366
- needs = _a.needs;
367
+ needs = _a.needs,
368
+ needsOtherComponent = _a.needsOtherComponent;
367
369
  var needsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
368
370
  var _a, _b, _c, _d, _e, _f, _g, _h;
369
371
  var componentName = context.name;
@@ -405,7 +407,7 @@ function getGitlabNeedsForComponentJob(context, _a, allJobs) {
405
407
  });
406
408
  }
407
409
  });
408
- var cleanedNeeds = __spreadArray(__spreadArray([], __read(needsFromStages !== null && needsFromStages !== void 0 ? needsFromStages : []), false), __read(needs !== null && needs !== void 0 ? needs : []), false);
410
+ var cleanedNeeds = __spreadArray(__spreadArray(__spreadArray([], __read(needsFromStages !== null && needsFromStages !== void 0 ? needsFromStages : []), false), __read(needs !== null && needs !== void 0 ? needs : []), false), __read(needsOtherComponent !== null && needsOtherComponent !== void 0 ? needsOtherComponent : []), false);
409
411
  return cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
410
412
  var _a;
411
413
  return (0, lodash_1.isObject)(n) ? "workspaceName" in n ? {