@catladder/cli 0.0.0-main-5bc1bdb9 → 0.0.0-main-a4e913e3

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.
@@ -39882,17 +39882,312 @@ exports.readConfigSync = readConfigSync;
39882
39882
 
39883
39883
  exports.__esModule = true;
39884
39884
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
39885
- exports.PIPELINE_IMAGE_TAG = "main-5bc1bdb9" || 0;
39885
+ exports.PIPELINE_IMAGE_TAG = "main-a4e913e3" || 0;
39886
39886
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
39887
39887
 
39888
39888
  /***/ }),
39889
39889
 
39890
+ /***/ 5706:
39891
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
39892
+
39893
+ "use strict";
39894
+
39895
+
39896
+ exports.__esModule = true;
39897
+ exports.getEnvConfig = void 0;
39898
+
39899
+ var utils_1 = __nccwpck_require__(7461);
39900
+
39901
+ var getEnvConfig = function (config, componentName, env) {
39902
+ var _a, _b;
39903
+
39904
+ var defaultConfig = config.components[componentName];
39905
+
39906
+ if (!defaultConfig) {
39907
+ throw new Error("unknown component " + componentName);
39908
+ }
39909
+
39910
+ var envCustomizations = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
39911
+
39912
+ if (envCustomizations === false) {
39913
+ throw new Error("env is disabled: " + env);
39914
+ }
39915
+
39916
+ return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
39917
+ };
39918
+
39919
+ exports.getEnvConfig = getEnvConfig;
39920
+
39921
+ /***/ }),
39922
+
39923
+ /***/ 4811:
39924
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
39925
+
39926
+ "use strict";
39927
+
39928
+
39929
+ exports.__esModule = true;
39930
+ exports.getEnvType = void 0;
39931
+
39932
+ var types_1 = __nccwpck_require__(1753);
39933
+
39934
+ var getEnvType = function (env, envConfig) {
39935
+ if (envConfig.type) return envConfig.type;
39936
+
39937
+ if ((0, types_1.isKnowEnvType)(env)) {
39938
+ return env;
39939
+ }
39940
+
39941
+ throw new Error("unknown env type: " + env);
39942
+ };
39943
+
39944
+ exports.getEnvType = getEnvType;
39945
+
39946
+ /***/ }),
39947
+
39890
39948
  /***/ 740:
39891
39949
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
39892
39950
 
39893
39951
  "use strict";
39894
39952
 
39895
39953
 
39954
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
39955
+ function adopt(value) {
39956
+ return value instanceof P ? value : new P(function (resolve) {
39957
+ resolve(value);
39958
+ });
39959
+ }
39960
+
39961
+ return new (P || (P = Promise))(function (resolve, reject) {
39962
+ function fulfilled(value) {
39963
+ try {
39964
+ step(generator.next(value));
39965
+ } catch (e) {
39966
+ reject(e);
39967
+ }
39968
+ }
39969
+
39970
+ function rejected(value) {
39971
+ try {
39972
+ step(generator["throw"](value));
39973
+ } catch (e) {
39974
+ reject(e);
39975
+ }
39976
+ }
39977
+
39978
+ function step(result) {
39979
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
39980
+ }
39981
+
39982
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
39983
+ });
39984
+ };
39985
+
39986
+ var __generator = this && this.__generator || function (thisArg, body) {
39987
+ var _ = {
39988
+ label: 0,
39989
+ sent: function () {
39990
+ if (t[0] & 1) throw t[1];
39991
+ return t[1];
39992
+ },
39993
+ trys: [],
39994
+ ops: []
39995
+ },
39996
+ f,
39997
+ y,
39998
+ t,
39999
+ g;
40000
+ return g = {
40001
+ next: verb(0),
40002
+ "throw": verb(1),
40003
+ "return": verb(2)
40004
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
40005
+ return this;
40006
+ }), g;
40007
+
40008
+ function verb(n) {
40009
+ return function (v) {
40010
+ return step([n, v]);
40011
+ };
40012
+ }
40013
+
40014
+ function step(op) {
40015
+ if (f) throw new TypeError("Generator is already executing.");
40016
+
40017
+ while (_) try {
40018
+ 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;
40019
+ if (y = 0, t) op = [op[0] & 2, t.value];
40020
+
40021
+ switch (op[0]) {
40022
+ case 0:
40023
+ case 1:
40024
+ t = op;
40025
+ break;
40026
+
40027
+ case 4:
40028
+ _.label++;
40029
+ return {
40030
+ value: op[1],
40031
+ done: false
40032
+ };
40033
+
40034
+ case 5:
40035
+ _.label++;
40036
+ y = op[1];
40037
+ op = [0];
40038
+ continue;
40039
+
40040
+ case 7:
40041
+ op = _.ops.pop();
40042
+
40043
+ _.trys.pop();
40044
+
40045
+ continue;
40046
+
40047
+ default:
40048
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
40049
+ _ = 0;
40050
+ continue;
40051
+ }
40052
+
40053
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
40054
+ _.label = op[1];
40055
+ break;
40056
+ }
40057
+
40058
+ if (op[0] === 6 && _.label < t[1]) {
40059
+ _.label = t[1];
40060
+ t = op;
40061
+ break;
40062
+ }
40063
+
40064
+ if (t && _.label < t[2]) {
40065
+ _.label = t[2];
40066
+
40067
+ _.ops.push(op);
40068
+
40069
+ break;
40070
+ }
40071
+
40072
+ if (t[2]) _.ops.pop();
40073
+
40074
+ _.trys.pop();
40075
+
40076
+ continue;
40077
+ }
40078
+
40079
+ op = body.call(thisArg, _);
40080
+ } catch (e) {
40081
+ op = [6, e];
40082
+ y = 0;
40083
+ } finally {
40084
+ f = t = 0;
40085
+ }
40086
+
40087
+ if (op[0] & 5) throw op[1];
40088
+ return {
40089
+ value: op[0] ? op[1] : void 0,
40090
+ done: true
40091
+ };
40092
+ }
40093
+ };
40094
+
40095
+ exports.__esModule = true;
40096
+ exports.getEnvironment = void 0;
40097
+
40098
+ var getEnvironmentContext_1 = __nccwpck_require__(4650);
40099
+
40100
+ var getEnvironmentVariables_1 = __nccwpck_require__(6602);
40101
+
40102
+ var getEnvironment = function (config, componentName, env, commitInfo) {
40103
+ return __awaiter(void 0, void 0, void 0, function () {
40104
+ var _a, envVars, secretEnvVarKeys, host, url, envContext, envType;
40105
+
40106
+ return __generator(this, function (_b) {
40107
+ switch (_b.label) {
40108
+ case 0:
40109
+ return [4
40110
+ /*yield*/
40111
+ , (0, getEnvironmentVariables_1.getEnvironmentVariables)(config, componentName, env, commitInfo)];
40112
+
40113
+ case 1:
40114
+ _a = _b.sent(), envVars = _a.envVars, secretEnvVarKeys = _a.secretEnvVarKeys, host = _a.host, url = _a.url;
40115
+ envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
40116
+ envType = envContext.envType;
40117
+ return [2
40118
+ /*return*/
40119
+ , {
40120
+ envType: envType,
40121
+ host: host,
40122
+ url: url,
40123
+ gitlabEnvironment: {
40124
+ name: envContext.gitlabEnvironmentName,
40125
+ url: url
40126
+ },
40127
+ fullName: envContext.fullName,
40128
+ slug: envContext.environmentSlug,
40129
+ shortName: env,
40130
+ envVars: envVars,
40131
+ secretEnvVarKeys: secretEnvVarKeys
40132
+ }];
40133
+ }
40134
+ });
40135
+ });
40136
+ };
40137
+
40138
+ exports.getEnvironment = getEnvironment;
40139
+
40140
+ /***/ }),
40141
+
40142
+ /***/ 4650:
40143
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
40144
+
40145
+ "use strict";
40146
+
40147
+
40148
+ exports.__esModule = true;
40149
+ exports.getEnvironmentContext = void 0;
40150
+
40151
+ var getEnvConfig_1 = __nccwpck_require__(5706);
40152
+
40153
+ var getEnvType_1 = __nccwpck_require__(4811);
40154
+
40155
+ var getEnvironmentSlug = function (envConfig, env, componentName, commitInfo) {
40156
+ var envType = (0, getEnvType_1.getEnvType)(env, envConfig);
40157
+ return envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
40158
+ };
40159
+
40160
+ var getEnvironmentContext = function (config, env, componentName, commitInfo) {
40161
+ var envConfigRaw = (0, getEnvConfig_1.getEnvConfig)(config, componentName, env);
40162
+ var envType = (0, getEnvType_1.getEnvType)(env, envConfigRaw);
40163
+ var environmentSlug = getEnvironmentSlug(envConfigRaw, env, componentName, commitInfo);
40164
+ var gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
40165
+ var fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
40166
+ return {
40167
+ envConfigRaw: envConfigRaw,
40168
+ deployConfigRaw: envConfigRaw.deploy,
40169
+ buildConfigRaw: envConfigRaw.build,
40170
+ environmentSlug: environmentSlug,
40171
+ gitlabEnvironmentName: gitlabEnvironmentName,
40172
+ fullName: fullName,
40173
+ envType: envType,
40174
+ commitInfo: commitInfo,
40175
+ componentName: componentName,
40176
+ env: env,
40177
+ fullConfig: config
40178
+ };
40179
+ };
40180
+
40181
+ exports.getEnvironmentContext = getEnvironmentContext;
40182
+
40183
+ /***/ }),
40184
+
40185
+ /***/ 6602:
40186
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
40187
+
40188
+ "use strict";
40189
+
40190
+
39896
40191
  var __assign = this && this.__assign || function () {
39897
40192
  __assign = Object.assign || function (t) {
39898
40193
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -40084,60 +40379,41 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
40084
40379
  };
40085
40380
 
40086
40381
  exports.__esModule = true;
40087
- exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironment = void 0;
40382
+ exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironmentVariables = void 0;
40088
40383
 
40089
40384
  var lodash_1 = __nccwpck_require__(3255);
40090
40385
 
40091
40386
  var deploy_1 = __nccwpck_require__(223);
40092
40387
 
40093
- var config_1 = __nccwpck_require__(9997);
40094
-
40095
- var utils_1 = __nccwpck_require__(7461);
40388
+ var getEnvironmentContext_1 = __nccwpck_require__(4650);
40096
40389
 
40097
40390
  var resolveReferences_1 = __nccwpck_require__(928);
40098
40391
 
40099
- var getEnvironment = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
40392
+ var getEnvironmentVariables = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
40100
40393
  ) {
40101
40394
  if (alreadyVisited === void 0) {
40102
40395
  alreadyVisited = {};
40103
40396
  }
40104
40397
 
40105
40398
  return __awaiter(void 0, void 0, void 0, function () {
40106
- var envConfig, envType, basePredefinedVariables, gitlabEnvironmentName, environmentSlug, predefinedVariables, host, url, fullName, envVarContext, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
40399
+ var environmentContext, envConfigRaw, deployConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
40107
40400
 
40108
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
40401
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
40109
40402
 
40110
- return __generator(this, function (_l) {
40111
- switch (_l.label) {
40403
+ return __generator(this, function (_k) {
40404
+ switch (_k.label) {
40112
40405
  case 0:
40113
- envConfig = getEnvConfig(config, componentName, env);
40114
- envType = (_a = envConfig === null || envConfig === void 0 ? void 0 : envConfig.type) !== null && _a !== void 0 ? _a : (0, config_1.isKnowEnvType)(env) ? env : null;
40115
-
40116
- if (!envType) {
40117
- throw new Error("Missing type in environment " + env + " in component " + componentName);
40118
- }
40119
-
40406
+ environmentContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
40407
+ envConfigRaw = environmentContext.envConfigRaw, deployConfigRaw = environmentContext.deployConfigRaw, envType = environmentContext.envType;
40120
40408
  basePredefinedVariables = {
40121
40409
  ENV_SHORT: env,
40122
- APP_DIR: envConfig.dir,
40410
+ APP_DIR: envConfigRaw.dir,
40123
40411
  ENV_TYPE: envType
40124
40412
  };
40125
- gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
40126
- environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
40127
- fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
40128
- envVarContext = {
40129
- deployConfig: envConfig.deploy,
40130
- fullName: fullName,
40131
- envType: envType,
40132
- commitInfo: commitInfo,
40133
- componentName: componentName,
40134
- env: env,
40135
- fullConfig: config
40136
- };
40137
40413
 
40138
40414
  if (envType === "local") {
40139
- devLocalConfig = envConfig;
40140
- port = (_b = devLocalConfig.port) !== null && _b !== void 0 ? _b : 3000;
40415
+ devLocalConfig = envConfigRaw;
40416
+ port = (_a = devLocalConfig.port) !== null && _a !== void 0 ? _a : 3000;
40141
40417
  host = "localhost:" + port;
40142
40418
  url = "http://" + host;
40143
40419
  predefinedVariables = {
@@ -40146,8 +40422,8 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
40146
40422
  PORT: port.toString()
40147
40423
  };
40148
40424
  } else {
40149
- additionalEnvVars = envConfig.deploy ? deploy_1.DEPLOY_TYPES[envConfig.deploy.type].getAdditionalEnvVars(envVarContext) : {};
40150
- host = (_d = (_c = envConfig === null || envConfig === void 0 ? void 0 : envConfig.host) !== null && _c !== void 0 ? _c : additionalEnvVars.HOST_CANONICAL) !== null && _d !== void 0 ? _d : "unknown-host.example.com";
40425
+ additionalEnvVars = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext) : {};
40426
+ host = (_c = (_b = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _b !== void 0 ? _b : additionalEnvVars.HOST_CANONICAL) !== null && _c !== void 0 ? _c : "unknown-host.example.com";
40151
40427
  url = "https://".concat(host);
40152
40428
  predefinedVariables = __assign(__assign(__assign({}, basePredefinedVariables), {
40153
40429
  HOST: host,
@@ -40155,13 +40431,13 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
40155
40431
  }), additionalEnvVars);
40156
40432
  }
40157
40433
 
40158
- publicEnvVarsRaw = (_f = (_e = envConfig.vars) === null || _e === void 0 ? void 0 : _e.public) !== null && _f !== void 0 ? _f : {};
40159
- additionalSecretKeys = envConfig.deploy ? deploy_1.DEPLOY_TYPES[envConfig.deploy.type].additionalSecretKeys(envVarContext) : [];
40160
- secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_h = (_g = envConfig.vars) === null || _g === void 0 ? void 0 : _g.secret) !== null && _h !== void 0 ? _h : []), false), __read(additionalSecretKeys), false);
40434
+ publicEnvVarsRaw = (_e = (_d = envConfigRaw.vars) === null || _d === void 0 ? void 0 : _d.public) !== null && _e !== void 0 ? _e : {};
40435
+ additionalSecretKeys = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(environmentContext) : [];
40436
+ secretEnvVarKeys = __spreadArray(__spreadArray([], __read((_g = (_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.secret) !== null && _g !== void 0 ? _g : []), false), __read(additionalSecretKeys), false);
40161
40437
  secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
40162
40438
  return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
40163
40439
  }));
40164
- legacyFromComponents = (_k = (_j = envConfig.vars) === null || _j === void 0 ? void 0 : _j.fromComponents) !== null && _k !== void 0 ? _k : {};
40440
+ legacyFromComponents = (_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.fromComponents) !== null && _j !== void 0 ? _j : {};
40165
40441
  publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
40166
40442
  publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
40167
40443
  var _b = __read(_a, 2),
@@ -40173,50 +40449,42 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
40173
40449
  envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
40174
40450
  return [4
40175
40451
  /*yield*/
40176
- , (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (componentName, variableName, alreadyVisited) {
40452
+ , (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, variableName, alreadyVisited) {
40177
40453
  return __awaiter(void 0, void 0, void 0, function () {
40178
- var envVars;
40454
+ var otherEnvVars;
40179
40455
  return __generator(this, function (_a) {
40180
40456
  switch (_a.label) {
40181
40457
  case 0:
40182
40458
  return [4
40183
40459
  /*yield*/
40184
- , (0, exports.getEnvironment)(config, componentName, env, commitInfo, alreadyVisited)];
40460
+ , (0, exports.getEnvironmentVariables)(config, otherComponentName, env, commitInfo, alreadyVisited)];
40185
40461
 
40186
40462
  case 1:
40187
- envVars = _a.sent().envVars;
40463
+ otherEnvVars = _a.sent().envVars;
40188
40464
  return [2
40189
40465
  /*return*/
40190
- , envVars[variableName]];
40466
+ , otherEnvVars[variableName]];
40191
40467
  }
40192
40468
  });
40193
40469
  });
40194
40470
  }, alreadyVisited)];
40195
40471
 
40196
40472
  case 1:
40197
- envVars = _l.sent();
40473
+ envVars = _k.sent();
40198
40474
  return [2
40199
40475
  /*return*/
40200
40476
  , {
40201
- envType: envType,
40202
- host: host,
40203
- url: url,
40204
- gitlabEnvironment: {
40205
- name: gitlabEnvironmentName,
40206
- url: url
40207
- },
40208
- fullName: fullName,
40209
- slug: environmentSlug,
40210
- shortName: env,
40211
40477
  envVars: envVars,
40212
- secretEnvVarKeys: secretEnvVarKeys
40478
+ secretEnvVarKeys: secretEnvVarKeys,
40479
+ host: host,
40480
+ url: url
40213
40481
  }];
40214
40482
  }
40215
40483
  });
40216
40484
  });
40217
40485
  };
40218
40486
 
40219
- exports.getEnvironment = getEnvironment;
40487
+ exports.getEnvironmentVariables = getEnvironmentVariables;
40220
40488
 
40221
40489
  var sanitizeForEnVar = function (s) {
40222
40490
  return s.replace(/-/g, "_");
@@ -40241,24 +40509,6 @@ var getSecretVarNameForContext = function (context, key) {
40241
40509
 
40242
40510
  exports.getSecretVarNameForContext = getSecretVarNameForContext;
40243
40511
 
40244
- var getEnvConfig = function (config, componentName, env) {
40245
- var _a, _b;
40246
-
40247
- var defaultConfig = config.components[componentName];
40248
-
40249
- if (!defaultConfig) {
40250
- throw new Error("unknown component " + componentName);
40251
- }
40252
-
40253
- var envCustomizations = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
40254
-
40255
- if (envCustomizations === false) {
40256
- throw new Error("env is disabled: " + env);
40257
- }
40258
-
40259
- return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
40260
- };
40261
-
40262
40512
  /***/ }),
40263
40513
 
40264
40514
  /***/ 486:
@@ -40492,34 +40742,30 @@ var utils_1 = __nccwpck_require__(7461);
40492
40742
 
40493
40743
  var getEnvironment_1 = __nccwpck_require__(740);
40494
40744
 
40745
+ var getEnvironmentContext_1 = __nccwpck_require__(4650);
40746
+
40495
40747
  __exportStar(__nccwpck_require__(740), exports);
40496
40748
 
40749
+ __exportStar(__nccwpck_require__(6602), exports);
40750
+
40497
40751
  var createContext = function (config, componentName, env, commitInfo, packageManagerInfo) {
40498
40752
  return __awaiter(void 0, void 0, void 0, function () {
40499
- var rawConfig, envConfig, componentConfigWithoutDefaults, defaults, componentConfig;
40753
+ var envContext, componentConfigWithoutDefaults, defaults, componentConfig;
40500
40754
 
40501
40755
  var _a;
40502
40756
 
40503
- var _b, _c;
40504
-
40505
- return __generator(this, function (_d) {
40506
- switch (_d.label) {
40757
+ return __generator(this, function (_b) {
40758
+ switch (_b.label) {
40507
40759
  case 0:
40508
40760
  if (!/^[a-z0-9-]+$/.test(componentName)) {
40509
40761
  throw new Error("componentName may only contain lower case letters, numbers and -");
40510
40762
  }
40511
40763
 
40512
- rawConfig = config.components[componentName];
40513
-
40514
- if (!rawConfig) {
40515
- throw new Error("unknown component " + componentName);
40516
- }
40517
-
40518
- envConfig = (_c = (_b = rawConfig.env) === null || _b === void 0 ? void 0 : _b[env]) !== null && _c !== void 0 ? _c : {};
40519
- componentConfigWithoutDefaults = (0, utils_1.mergeWithMergingArrays)(rawConfig, envConfig);
40764
+ envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
40765
+ componentConfigWithoutDefaults = envContext.envConfigRaw;
40520
40766
  defaults = componentConfigWithoutDefaults.deploy ? {
40521
- build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(),
40522
- deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults()
40767
+ build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(envContext),
40768
+ deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults(envContext)
40523
40769
  } : {
40524
40770
  build: {},
40525
40771
  deploy: {}
@@ -40537,7 +40783,7 @@ var createContext = function (config, componentName, env, commitInfo, packageMan
40537
40783
  case 1:
40538
40784
  return [2
40539
40785
  /*return*/
40540
- , (_a.environment = _d.sent(), _a.commitInfo = commitInfo, _a.packageManagerInfo = packageManagerInfo, _a)];
40786
+ , (_a.environment = _b.sent(), _a.commitInfo = commitInfo, _a.packageManagerInfo = packageManagerInfo, _a)];
40541
40787
  }
40542
40788
  });
40543
40789
  });
@@ -41108,13 +41354,15 @@ var types_1 = __nccwpck_require__(3109);
41108
41354
  var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
41109
41355
 
41110
41356
  var createGoogleCloudRunDeployJobs = function (context) {
41357
+ var _a, _b;
41358
+
41111
41359
  var deployConfig = context.componentConfig.deploy;
41112
41360
 
41113
41361
  if (deployConfig === false) {
41114
41362
  return [];
41115
41363
  }
41116
41364
 
41117
- if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun", "google-cloudrun-job")) {
41365
+ if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
41118
41366
  // should not happen
41119
41367
  throw new Error("deploy config is wrong");
41120
41368
  }
@@ -41135,44 +41383,76 @@ var createGoogleCloudRunDeployJobs = function (context) {
41135
41383
  return "".concat(key, "=").concat(value);
41136
41384
  }).join(",");
41137
41385
  var commonArgs = "--project ".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
41386
+ var commonDeployArgs = "--image ".concat(gcloudImageName, " ").concat(commonArgs, " --labels ").concat(labelsString);
41387
+ var serviceName = context.environment.fullName.toLowerCase();
41138
41388
 
41139
- var getDeployCommand = function () {
41389
+ var getServiceDeployScript = function (service) {
41140
41390
  var _a;
41141
41391
 
41142
- var name = context.environment.fullName.toLowerCase();
41143
- var command = (_a = deployConfig.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand;
41392
+ var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
41144
41393
  var commandArg = command ? "--command=\"".concat(command.split(" ").join(","), "\"") : "";
41145
- var commonDeployArgs = "".concat(commandArg, " --image ").concat(gcloudImageName, " ").concat(commonArgs, " --env-vars-file=____envvars.yaml --labels ").concat(labelsString);
41394
+ return "gcloud run deploy ".concat(serviceName, " ").concat(commandArg, " ").concat(commonDeployArgs, " --env-vars-file=____envvars.yaml --allow-unauthenticated");
41395
+ };
41146
41396
 
41147
- if (deployConfig.type === "google-cloudrun") {
41148
- return "gcloud run deploy ".concat(name, " ").concat(commonDeployArgs, " --allow-unauthenticated");
41149
- }
41397
+ var getJobDeployScripts = function (jobName, job) {
41398
+ // due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
41399
+ // lucky, update on the other hand accepts it... so let's just imediatly update it
41400
+ // also we cannot upsert a job, so we have to create it and catch the error and then update
41401
+ var args = "".concat(jobName, " --command=\"").concat(job.command.split(" ").join(","), "\" ").concat(commonDeployArgs);
41402
+ return ["set +e", "gcloud beta run jobs create ".concat(args), "set -e", "gcloud beta run jobs update ".concat(args, " --env-vars-file=____envvars.yaml")];
41403
+ };
41150
41404
 
41151
- if (deployConfig.type === "google-cloudrun-job") {
41152
- return "gcloud beta run jobs create ".concat(name, " ").concat(commonDeployArgs);
41153
- }
41405
+ var getJobRunScript = function (jobName) {
41406
+ return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgs);
41154
41407
  };
41155
41408
 
41156
- var getStopCommand = function () {
41157
- var name = context.environment.fullName.toLowerCase();
41158
- var commonStopArgs = "".concat(commonArgs, " --quiet");
41409
+ var getFullJobName = function (name) {
41410
+ return context.environment.fullName.toLowerCase() + "-" + name;
41411
+ };
41159
41412
 
41160
- if (deployConfig.type === "google-cloudrun") {
41161
- return "gcloud run services delete ".concat(name, " ").concat(commonStopArgs);
41162
- }
41413
+ var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
41414
+ var _b = __read(_a, 2),
41415
+ name = _b[0],
41416
+ job = _b[1];
41163
41417
 
41164
- if (deployConfig.type === "google-cloudrun-job") {
41165
- return "gcloud beta run jobs delete ".concat(name, " ").concat(commonStopArgs);
41166
- }
41167
- };
41418
+ return [getFullJobName(name), job];
41419
+ });
41420
+
41421
+ var cloudRunDeployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml"], __read(jobsWithNames.map(function (_a) {
41422
+ var _b = __read(_a, 2),
41423
+ name = _b[0],
41424
+ job = _b[1];
41425
+
41426
+ return getJobDeployScripts(name, job);
41427
+ }).flat()), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(jobsWithNames.filter(function (_a) {
41428
+ var _b = __read(_a, 2),
41429
+ name = _b[0],
41430
+ job = _b[1];
41431
+
41432
+ return job.when === "postDeploy";
41433
+ }).map(function (_a) {
41434
+ var _b = __read(_a, 2),
41435
+ name = _b[0],
41436
+ job = _b[1];
41437
+
41438
+ return getJobRunScript(name);
41439
+ })), false), ["docker image rm ".concat(gcloudImageName)], false);
41440
+
41441
+ var cloudRunStopScripts = __spreadArray(__spreadArray([], __read(deployConfig.service !== false ? ["gcloud run services delete ".concat(serviceName)] : []), false), __read(Object.entries((_b = deployConfig.jobs) !== null && _b !== void 0 ? _b : {}).map(function (_a) {
41442
+ var _b = __read(_a, 2),
41443
+ jobName = _b[0],
41444
+ job = _b[1];
41445
+
41446
+ return "gcloud beta run jobs delete ".concat(jobName);
41447
+ })), false);
41168
41448
 
41169
- var cloudRunDeploy = ["echo \"$ENV_VARS\" > ____envvars.yaml", getDeployCommand(), "docker image rm ".concat(gcloudImageName)];
41170
41449
  var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
41171
41450
  return [(0, lodash_1.merge)({}, baseDeploymentJob, (0, docker_1.getDockerJobBaseProps)(context), {
41172
41451
  artifacts: {
41173
41452
  paths: ["____envvars.yaml"]
41174
41453
  },
41175
41454
  variables: {
41455
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
41176
41456
  ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
41177
41457
  lineWidth: -1,
41178
41458
  quotingType: "'",
@@ -41180,10 +41460,13 @@ var createGoogleCloudRunDeployJobs = function (context) {
41180
41460
  })
41181
41461
  },
41182
41462
  image: (0, runner_1.getRunnerImage)("gcloud"),
41183
- script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeploy), false)
41463
+ script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeployScripts), false)
41184
41464
  }), (0, lodash_1.merge)({}, baseStopJob, {
41185
41465
  image: (0, runner_1.getRunnerImage)("gcloud"),
41186
- script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), [getStopCommand()], false)
41466
+ variables: {
41467
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1"
41468
+ },
41469
+ script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(cloudRunStopScripts), false)
41187
41470
  })];
41188
41471
  };
41189
41472
 
@@ -41192,13 +41475,52 @@ exports.createGoogleCloudRunDeployJobs = createGoogleCloudRunDeployJobs;
41192
41475
  /***/ }),
41193
41476
 
41194
41477
  /***/ 1344:
41195
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
41478
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
41196
41479
 
41197
41480
  "use strict";
41198
41481
 
41199
41482
 
41483
+ var __assign = this && this.__assign || function () {
41484
+ __assign = Object.assign || function (t) {
41485
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
41486
+ s = arguments[i];
41487
+
41488
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41489
+ }
41490
+
41491
+ return t;
41492
+ };
41493
+
41494
+ return __assign.apply(this, arguments);
41495
+ };
41496
+
41497
+ var __read = this && this.__read || function (o, n) {
41498
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
41499
+ if (!m) return o;
41500
+ var i = m.call(o),
41501
+ r,
41502
+ ar = [],
41503
+ e;
41504
+
41505
+ try {
41506
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
41507
+ } catch (error) {
41508
+ e = {
41509
+ error: error
41510
+ };
41511
+ } finally {
41512
+ try {
41513
+ if (r && !r.done && (m = i["return"])) m.call(i);
41514
+ } finally {
41515
+ if (e) throw e.error;
41516
+ }
41517
+ }
41518
+
41519
+ return ar;
41520
+ };
41521
+
41200
41522
  exports.__esModule = true;
41201
- exports.GCLOUD_RUN_DEPLOY_TYPES = exports.GCLOUD_RUN_JOB_DEPLOY_TYPE = exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
41523
+ exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
41202
41524
 
41203
41525
  var context_1 = __nccwpck_require__(2041);
41204
41526
 
@@ -41217,40 +41539,21 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
41217
41539
  getAdditionalEnvVars: function (_a) {
41218
41540
  var fullName = _a.fullName,
41219
41541
  env = _a.env,
41220
- componentName = _a.componentName;
41542
+ componentName = _a.componentName,
41543
+ deployConfigRaw = _a.deployConfigRaw;
41221
41544
  var HOST_CANONICAL = fullName.toLowerCase() + "-" + process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)];
41222
- return {
41223
- HOST_CANONICAL: HOST_CANONICAL
41224
- };
41225
- }
41226
- };
41227
- exports.GCLOUD_RUN_JOB_DEPLOY_TYPE = {
41228
- jobs: deployJob_1.createGoogleCloudRunDeployJobs,
41229
- defaults: function () {
41230
- return {};
41231
- },
41232
- additionalSecretKeys: function () {
41233
- return [exports.GCLOUD_DEPLOY_CREDENTIALS_KEY];
41234
- },
41235
- getAdditionalEnvVars: function (_a) {
41236
- var deployConfig = _a.deployConfig,
41237
- fullName = _a.fullName;
41238
-
41239
- if (!deployConfig) {
41240
- return {};
41241
- }
41545
+ var jobTriggers = deployConfigRaw && deployConfigRaw.jobs ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(function (_a) {
41546
+ var _b = __read(_a, 2),
41547
+ name = _b[0],
41548
+ job = _b[1];
41242
41549
 
41243
- var jobName = fullName.toLowerCase();
41244
- var CLOUD_RUN_JOB_TRIGGER_URL = "https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(jobName, ":run");
41245
- return {
41246
- CLOUD_RUN_JOB_TRIGGER_URL: CLOUD_RUN_JOB_TRIGGER_URL
41247
- };
41550
+ return ["CLOUD_RUN_JOB_TRIGGER_URL_" + name, "https://".concat(deployConfigRaw.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfigRaw.projectId, "/jobs/").concat(name, ":run")];
41551
+ })) : {};
41552
+ return __assign({
41553
+ HOST_CANONICAL: HOST_CANONICAL
41554
+ }, jobTriggers);
41248
41555
  }
41249
41556
  };
41250
- exports.GCLOUD_RUN_DEPLOY_TYPES = {
41251
- "google-cloudrun": exports.GCLOUD_RUN_DEPLOY_TYPE,
41252
- "google-cloudrun-job": exports.GCLOUD_RUN_JOB_DEPLOY_TYPE
41253
- };
41254
41557
 
41255
41558
  /***/ }),
41256
41559
 
@@ -41485,20 +41788,6 @@ exports.DOCKER_TAG_DEPLOY_TYPE = {
41485
41788
  "use strict";
41486
41789
 
41487
41790
 
41488
- var __assign = this && this.__assign || function () {
41489
- __assign = Object.assign || function (t) {
41490
- for (var s, i = 1, n = arguments.length; i < n; i++) {
41491
- s = arguments[i];
41492
-
41493
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41494
- }
41495
-
41496
- return t;
41497
- };
41498
-
41499
- return __assign.apply(this, arguments);
41500
- };
41501
-
41502
41791
  var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
41503
41792
  if (k2 === undefined) k2 = k;
41504
41793
  Object.defineProperty(o, k2, {
@@ -41527,21 +41816,22 @@ var dockerTag_1 = __nccwpck_require__(8990);
41527
41816
 
41528
41817
  var kubernetes_1 = __nccwpck_require__(5682);
41529
41818
 
41819
+ __exportStar(__nccwpck_require__(1344), exports);
41820
+
41821
+ __exportStar(__nccwpck_require__(3539), exports);
41822
+
41530
41823
  __exportStar(__nccwpck_require__(5682), exports);
41531
41824
 
41532
41825
  __exportStar(__nccwpck_require__(3109), exports);
41533
41826
 
41534
41827
  __exportStar(__nccwpck_require__(2757), exports);
41535
41828
 
41536
- __exportStar(__nccwpck_require__(3539), exports);
41537
-
41538
- __exportStar(__nccwpck_require__(1344), exports);
41539
-
41540
- exports.DEPLOY_TYPES = __assign({
41829
+ exports.DEPLOY_TYPES = {
41541
41830
  kubernetes: kubernetes_1.KUBERNETES_DEPLOY_TYPE,
41542
41831
  custom: custom_1.CUSTOM_DEPLOY_TYPE,
41543
- dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE
41544
- }, cloudRun_1.GCLOUD_RUN_DEPLOY_TYPES);
41832
+ dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE,
41833
+ "google-cloudrun": cloudRun_1.GCLOUD_RUN_DEPLOY_TYPE
41834
+ };
41545
41835
 
41546
41836
  /***/ }),
41547
41837
 
@@ -41557,23 +41847,23 @@ exports.additionalKubernetesSecretKeys = void 0;
41557
41847
  var additionalKubernetesSecretKeys = function (_a) {
41558
41848
  var _b, _c, _d, _e;
41559
41849
 
41560
- var deployConfig = _a.deployConfig;
41850
+ var deployConfigRaw = _a.deployConfigRaw;
41561
41851
 
41562
- if (!deployConfig) {
41852
+ if (!deployConfigRaw) {
41563
41853
  return [];
41564
41854
  }
41565
41855
 
41566
41856
  var keys = [];
41567
41857
 
41568
- if ((_c = (_b = deployConfig.values) === null || _b === void 0 ? void 0 : _b.mongodb) === null || _c === void 0 ? void 0 : _c.enabled) {
41858
+ if ((_c = (_b = deployConfigRaw.values) === null || _b === void 0 ? void 0 : _b.mongodb) === null || _c === void 0 ? void 0 : _c.enabled) {
41569
41859
  keys.push("MONGODB_ROOT_PASSWORD");
41570
41860
 
41571
- if (deployConfig.values.mongodb.architecture === "replicaset") {
41861
+ if (deployConfigRaw.values.mongodb.architecture === "replicaset") {
41572
41862
  keys.push("MONGODB_REPLICASET_KEY");
41573
41863
  }
41574
41864
  }
41575
41865
 
41576
- if ((_e = (_d = deployConfig.values) === null || _d === void 0 ? void 0 : _d.cloudsql) === null || _e === void 0 ? void 0 : _e.enabled) {
41866
+ if ((_e = (_d = deployConfigRaw.values) === null || _d === void 0 ? void 0 : _d.cloudsql) === null || _e === void 0 ? void 0 : _e.enabled) {
41577
41867
  keys.push("POSTGRESQL_PASSWORD");
41578
41868
  keys.push("cloudsqlProxyCredentials");
41579
41869
  }
@@ -41776,7 +42066,7 @@ exports.KUBERNETES_DEPLOY_TYPE = {
41776
42066
 
41777
42067
  var componentName = _a.componentName,
41778
42068
  fullConfig = _a.fullConfig,
41779
- deployConfig = _a.deployConfig,
42069
+ deployConfigRaw = _a.deployConfigRaw,
41780
42070
  env = _a.env,
41781
42071
  envType = _a.envType,
41782
42072
  commitInfo = _a.commitInfo;
@@ -41785,7 +42075,7 @@ exports.KUBERNETES_DEPLOY_TYPE = {
41785
42075
  var KUBE_NAMESPACE = (0, __1.getKubernetesNamespace)(fullConfig, env);
41786
42076
  var componentSlug = (0, slugify_1["default"])(componentName);
41787
42077
  var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
41788
- var domainCanonical = deployConfig && ((_b = deployConfig.cluster) === null || _b === void 0 ? void 0 : _b.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
42078
+ var domainCanonical = deployConfigRaw && ((_b = deployConfigRaw.cluster) === null || _b === void 0 ? void 0 : _b.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
41789
42079
  fullConfig.domainCanonical || "panter.cloud";
41790
42080
  var HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(fullConfig.appName, ".").concat(fullConfig.customerName, ".").concat(domainCanonical); // default for kubernetes and rest
41791
42081