@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.
@@ -350753,17 +350753,312 @@ exports.readConfigSync = readConfigSync;
350753
350753
 
350754
350754
  exports.__esModule = true;
350755
350755
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
350756
- exports.PIPELINE_IMAGE_TAG = "main-5bc1bdb9" || 0;
350756
+ exports.PIPELINE_IMAGE_TAG = "main-a4e913e3" || 0;
350757
350757
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
350758
350758
 
350759
350759
  /***/ }),
350760
350760
 
350761
+ /***/ 25706:
350762
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
350763
+
350764
+ "use strict";
350765
+
350766
+
350767
+ exports.__esModule = true;
350768
+ exports.getEnvConfig = void 0;
350769
+
350770
+ var utils_1 = __nccwpck_require__(37461);
350771
+
350772
+ var getEnvConfig = function (config, componentName, env) {
350773
+ var _a, _b;
350774
+
350775
+ var defaultConfig = config.components[componentName];
350776
+
350777
+ if (!defaultConfig) {
350778
+ throw new Error("unknown component " + componentName);
350779
+ }
350780
+
350781
+ var envCustomizations = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
350782
+
350783
+ if (envCustomizations === false) {
350784
+ throw new Error("env is disabled: " + env);
350785
+ }
350786
+
350787
+ return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
350788
+ };
350789
+
350790
+ exports.getEnvConfig = getEnvConfig;
350791
+
350792
+ /***/ }),
350793
+
350794
+ /***/ 94811:
350795
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
350796
+
350797
+ "use strict";
350798
+
350799
+
350800
+ exports.__esModule = true;
350801
+ exports.getEnvType = void 0;
350802
+
350803
+ var types_1 = __nccwpck_require__(71753);
350804
+
350805
+ var getEnvType = function (env, envConfig) {
350806
+ if (envConfig.type) return envConfig.type;
350807
+
350808
+ if ((0, types_1.isKnowEnvType)(env)) {
350809
+ return env;
350810
+ }
350811
+
350812
+ throw new Error("unknown env type: " + env);
350813
+ };
350814
+
350815
+ exports.getEnvType = getEnvType;
350816
+
350817
+ /***/ }),
350818
+
350761
350819
  /***/ 60740:
350762
350820
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
350763
350821
 
350764
350822
  "use strict";
350765
350823
 
350766
350824
 
350825
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
350826
+ function adopt(value) {
350827
+ return value instanceof P ? value : new P(function (resolve) {
350828
+ resolve(value);
350829
+ });
350830
+ }
350831
+
350832
+ return new (P || (P = Promise))(function (resolve, reject) {
350833
+ function fulfilled(value) {
350834
+ try {
350835
+ step(generator.next(value));
350836
+ } catch (e) {
350837
+ reject(e);
350838
+ }
350839
+ }
350840
+
350841
+ function rejected(value) {
350842
+ try {
350843
+ step(generator["throw"](value));
350844
+ } catch (e) {
350845
+ reject(e);
350846
+ }
350847
+ }
350848
+
350849
+ function step(result) {
350850
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
350851
+ }
350852
+
350853
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
350854
+ });
350855
+ };
350856
+
350857
+ var __generator = this && this.__generator || function (thisArg, body) {
350858
+ var _ = {
350859
+ label: 0,
350860
+ sent: function () {
350861
+ if (t[0] & 1) throw t[1];
350862
+ return t[1];
350863
+ },
350864
+ trys: [],
350865
+ ops: []
350866
+ },
350867
+ f,
350868
+ y,
350869
+ t,
350870
+ g;
350871
+ return g = {
350872
+ next: verb(0),
350873
+ "throw": verb(1),
350874
+ "return": verb(2)
350875
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
350876
+ return this;
350877
+ }), g;
350878
+
350879
+ function verb(n) {
350880
+ return function (v) {
350881
+ return step([n, v]);
350882
+ };
350883
+ }
350884
+
350885
+ function step(op) {
350886
+ if (f) throw new TypeError("Generator is already executing.");
350887
+
350888
+ while (_) try {
350889
+ 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;
350890
+ if (y = 0, t) op = [op[0] & 2, t.value];
350891
+
350892
+ switch (op[0]) {
350893
+ case 0:
350894
+ case 1:
350895
+ t = op;
350896
+ break;
350897
+
350898
+ case 4:
350899
+ _.label++;
350900
+ return {
350901
+ value: op[1],
350902
+ done: false
350903
+ };
350904
+
350905
+ case 5:
350906
+ _.label++;
350907
+ y = op[1];
350908
+ op = [0];
350909
+ continue;
350910
+
350911
+ case 7:
350912
+ op = _.ops.pop();
350913
+
350914
+ _.trys.pop();
350915
+
350916
+ continue;
350917
+
350918
+ default:
350919
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
350920
+ _ = 0;
350921
+ continue;
350922
+ }
350923
+
350924
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
350925
+ _.label = op[1];
350926
+ break;
350927
+ }
350928
+
350929
+ if (op[0] === 6 && _.label < t[1]) {
350930
+ _.label = t[1];
350931
+ t = op;
350932
+ break;
350933
+ }
350934
+
350935
+ if (t && _.label < t[2]) {
350936
+ _.label = t[2];
350937
+
350938
+ _.ops.push(op);
350939
+
350940
+ break;
350941
+ }
350942
+
350943
+ if (t[2]) _.ops.pop();
350944
+
350945
+ _.trys.pop();
350946
+
350947
+ continue;
350948
+ }
350949
+
350950
+ op = body.call(thisArg, _);
350951
+ } catch (e) {
350952
+ op = [6, e];
350953
+ y = 0;
350954
+ } finally {
350955
+ f = t = 0;
350956
+ }
350957
+
350958
+ if (op[0] & 5) throw op[1];
350959
+ return {
350960
+ value: op[0] ? op[1] : void 0,
350961
+ done: true
350962
+ };
350963
+ }
350964
+ };
350965
+
350966
+ exports.__esModule = true;
350967
+ exports.getEnvironment = void 0;
350968
+
350969
+ var getEnvironmentContext_1 = __nccwpck_require__(95141);
350970
+
350971
+ var getEnvironmentVariables_1 = __nccwpck_require__(76602);
350972
+
350973
+ var getEnvironment = function (config, componentName, env, commitInfo) {
350974
+ return __awaiter(void 0, void 0, void 0, function () {
350975
+ var _a, envVars, secretEnvVarKeys, host, url, envContext, envType;
350976
+
350977
+ return __generator(this, function (_b) {
350978
+ switch (_b.label) {
350979
+ case 0:
350980
+ return [4
350981
+ /*yield*/
350982
+ , (0, getEnvironmentVariables_1.getEnvironmentVariables)(config, componentName, env, commitInfo)];
350983
+
350984
+ case 1:
350985
+ _a = _b.sent(), envVars = _a.envVars, secretEnvVarKeys = _a.secretEnvVarKeys, host = _a.host, url = _a.url;
350986
+ envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
350987
+ envType = envContext.envType;
350988
+ return [2
350989
+ /*return*/
350990
+ , {
350991
+ envType: envType,
350992
+ host: host,
350993
+ url: url,
350994
+ gitlabEnvironment: {
350995
+ name: envContext.gitlabEnvironmentName,
350996
+ url: url
350997
+ },
350998
+ fullName: envContext.fullName,
350999
+ slug: envContext.environmentSlug,
351000
+ shortName: env,
351001
+ envVars: envVars,
351002
+ secretEnvVarKeys: secretEnvVarKeys
351003
+ }];
351004
+ }
351005
+ });
351006
+ });
351007
+ };
351008
+
351009
+ exports.getEnvironment = getEnvironment;
351010
+
351011
+ /***/ }),
351012
+
351013
+ /***/ 95141:
351014
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
351015
+
351016
+ "use strict";
351017
+
351018
+
351019
+ exports.__esModule = true;
351020
+ exports.getEnvironmentContext = void 0;
351021
+
351022
+ var getEnvConfig_1 = __nccwpck_require__(25706);
351023
+
351024
+ var getEnvType_1 = __nccwpck_require__(94811);
351025
+
351026
+ var getEnvironmentSlug = function (envConfig, env, componentName, commitInfo) {
351027
+ var envType = (0, getEnvType_1.getEnvType)(env, envConfig);
351028
+ return envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
351029
+ };
351030
+
351031
+ var getEnvironmentContext = function (config, env, componentName, commitInfo) {
351032
+ var envConfigRaw = (0, getEnvConfig_1.getEnvConfig)(config, componentName, env);
351033
+ var envType = (0, getEnvType_1.getEnvType)(env, envConfigRaw);
351034
+ var environmentSlug = getEnvironmentSlug(envConfigRaw, env, componentName, commitInfo);
351035
+ var gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
351036
+ var fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
351037
+ return {
351038
+ envConfigRaw: envConfigRaw,
351039
+ deployConfigRaw: envConfigRaw.deploy,
351040
+ buildConfigRaw: envConfigRaw.build,
351041
+ environmentSlug: environmentSlug,
351042
+ gitlabEnvironmentName: gitlabEnvironmentName,
351043
+ fullName: fullName,
351044
+ envType: envType,
351045
+ commitInfo: commitInfo,
351046
+ componentName: componentName,
351047
+ env: env,
351048
+ fullConfig: config
351049
+ };
351050
+ };
351051
+
351052
+ exports.getEnvironmentContext = getEnvironmentContext;
351053
+
351054
+ /***/ }),
351055
+
351056
+ /***/ 76602:
351057
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
351058
+
351059
+ "use strict";
351060
+
351061
+
350767
351062
  var __assign = this && this.__assign || function () {
350768
351063
  __assign = Object.assign || function (t) {
350769
351064
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -350955,60 +351250,41 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
350955
351250
  };
350956
351251
 
350957
351252
  exports.__esModule = true;
350958
- exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironment = void 0;
351253
+ exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironmentVariables = void 0;
350959
351254
 
350960
351255
  var lodash_1 = __nccwpck_require__(23255);
350961
351256
 
350962
351257
  var deploy_1 = __nccwpck_require__(90223);
350963
351258
 
350964
- var config_1 = __nccwpck_require__(19997);
350965
-
350966
- var utils_1 = __nccwpck_require__(37461);
351259
+ var getEnvironmentContext_1 = __nccwpck_require__(95141);
350967
351260
 
350968
351261
  var resolveReferences_1 = __nccwpck_require__(80928);
350969
351262
 
350970
- var getEnvironment = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
351263
+ var getEnvironmentVariables = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
350971
351264
  ) {
350972
351265
  if (alreadyVisited === void 0) {
350973
351266
  alreadyVisited = {};
350974
351267
  }
350975
351268
 
350976
351269
  return __awaiter(void 0, void 0, void 0, function () {
350977
- var envConfig, envType, basePredefinedVariables, gitlabEnvironmentName, environmentSlug, predefinedVariables, host, url, fullName, envVarContext, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
351270
+ var environmentContext, envConfigRaw, deployConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
350978
351271
 
350979
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
351272
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
350980
351273
 
350981
- return __generator(this, function (_l) {
350982
- switch (_l.label) {
351274
+ return __generator(this, function (_k) {
351275
+ switch (_k.label) {
350983
351276
  case 0:
350984
- envConfig = getEnvConfig(config, componentName, env);
350985
- envType = (_a = envConfig === null || envConfig === void 0 ? void 0 : envConfig.type) !== null && _a !== void 0 ? _a : (0, config_1.isKnowEnvType)(env) ? env : null;
350986
-
350987
- if (!envType) {
350988
- throw new Error("Missing type in environment " + env + " in component " + componentName);
350989
- }
350990
-
351277
+ environmentContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
351278
+ envConfigRaw = environmentContext.envConfigRaw, deployConfigRaw = environmentContext.deployConfigRaw, envType = environmentContext.envType;
350991
351279
  basePredefinedVariables = {
350992
351280
  ENV_SHORT: env,
350993
- APP_DIR: envConfig.dir,
351281
+ APP_DIR: envConfigRaw.dir,
350994
351282
  ENV_TYPE: envType
350995
351283
  };
350996
- gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
350997
- environmentSlug = envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
350998
- fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
350999
- envVarContext = {
351000
- deployConfig: envConfig.deploy,
351001
- fullName: fullName,
351002
- envType: envType,
351003
- commitInfo: commitInfo,
351004
- componentName: componentName,
351005
- env: env,
351006
- fullConfig: config
351007
- };
351008
351284
 
351009
351285
  if (envType === "local") {
351010
- devLocalConfig = envConfig;
351011
- port = (_b = devLocalConfig.port) !== null && _b !== void 0 ? _b : 3000;
351286
+ devLocalConfig = envConfigRaw;
351287
+ port = (_a = devLocalConfig.port) !== null && _a !== void 0 ? _a : 3000;
351012
351288
  host = "localhost:" + port;
351013
351289
  url = "http://" + host;
351014
351290
  predefinedVariables = {
@@ -351017,8 +351293,8 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
351017
351293
  PORT: port.toString()
351018
351294
  };
351019
351295
  } else {
351020
- additionalEnvVars = envConfig.deploy ? deploy_1.DEPLOY_TYPES[envConfig.deploy.type].getAdditionalEnvVars(envVarContext) : {};
351021
- 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";
351296
+ additionalEnvVars = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext) : {};
351297
+ 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";
351022
351298
  url = "https://".concat(host);
351023
351299
  predefinedVariables = __assign(__assign(__assign({}, basePredefinedVariables), {
351024
351300
  HOST: host,
@@ -351026,13 +351302,13 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
351026
351302
  }), additionalEnvVars);
351027
351303
  }
351028
351304
 
351029
- publicEnvVarsRaw = (_f = (_e = envConfig.vars) === null || _e === void 0 ? void 0 : _e.public) !== null && _f !== void 0 ? _f : {};
351030
- additionalSecretKeys = envConfig.deploy ? deploy_1.DEPLOY_TYPES[envConfig.deploy.type].additionalSecretKeys(envVarContext) : [];
351031
- 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);
351305
+ publicEnvVarsRaw = (_e = (_d = envConfigRaw.vars) === null || _d === void 0 ? void 0 : _d.public) !== null && _e !== void 0 ? _e : {};
351306
+ additionalSecretKeys = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(environmentContext) : [];
351307
+ 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);
351032
351308
  secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (key) {
351033
351309
  return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
351034
351310
  }));
351035
- legacyFromComponents = (_k = (_j = envConfig.vars) === null || _j === void 0 ? void 0 : _j.fromComponents) !== null && _k !== void 0 ? _k : {};
351311
+ legacyFromComponents = (_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.fromComponents) !== null && _j !== void 0 ? _j : {};
351036
351312
  publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
351037
351313
  publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
351038
351314
  var _b = __read(_a, 2),
@@ -351044,50 +351320,42 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
351044
351320
  envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
351045
351321
  return [4
351046
351322
  /*yield*/
351047
- , (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (componentName, variableName, alreadyVisited) {
351323
+ , (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, variableName, alreadyVisited) {
351048
351324
  return __awaiter(void 0, void 0, void 0, function () {
351049
- var envVars;
351325
+ var otherEnvVars;
351050
351326
  return __generator(this, function (_a) {
351051
351327
  switch (_a.label) {
351052
351328
  case 0:
351053
351329
  return [4
351054
351330
  /*yield*/
351055
- , (0, exports.getEnvironment)(config, componentName, env, commitInfo, alreadyVisited)];
351331
+ , (0, exports.getEnvironmentVariables)(config, otherComponentName, env, commitInfo, alreadyVisited)];
351056
351332
 
351057
351333
  case 1:
351058
- envVars = _a.sent().envVars;
351334
+ otherEnvVars = _a.sent().envVars;
351059
351335
  return [2
351060
351336
  /*return*/
351061
- , envVars[variableName]];
351337
+ , otherEnvVars[variableName]];
351062
351338
  }
351063
351339
  });
351064
351340
  });
351065
351341
  }, alreadyVisited)];
351066
351342
 
351067
351343
  case 1:
351068
- envVars = _l.sent();
351344
+ envVars = _k.sent();
351069
351345
  return [2
351070
351346
  /*return*/
351071
351347
  , {
351072
- envType: envType,
351073
- host: host,
351074
- url: url,
351075
- gitlabEnvironment: {
351076
- name: gitlabEnvironmentName,
351077
- url: url
351078
- },
351079
- fullName: fullName,
351080
- slug: environmentSlug,
351081
- shortName: env,
351082
351348
  envVars: envVars,
351083
- secretEnvVarKeys: secretEnvVarKeys
351349
+ secretEnvVarKeys: secretEnvVarKeys,
351350
+ host: host,
351351
+ url: url
351084
351352
  }];
351085
351353
  }
351086
351354
  });
351087
351355
  });
351088
351356
  };
351089
351357
 
351090
- exports.getEnvironment = getEnvironment;
351358
+ exports.getEnvironmentVariables = getEnvironmentVariables;
351091
351359
 
351092
351360
  var sanitizeForEnVar = function (s) {
351093
351361
  return s.replace(/-/g, "_");
@@ -351112,24 +351380,6 @@ var getSecretVarNameForContext = function (context, key) {
351112
351380
 
351113
351381
  exports.getSecretVarNameForContext = getSecretVarNameForContext;
351114
351382
 
351115
- var getEnvConfig = function (config, componentName, env) {
351116
- var _a, _b;
351117
-
351118
- var defaultConfig = config.components[componentName];
351119
-
351120
- if (!defaultConfig) {
351121
- throw new Error("unknown component " + componentName);
351122
- }
351123
-
351124
- var envCustomizations = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
351125
-
351126
- if (envCustomizations === false) {
351127
- throw new Error("env is disabled: " + env);
351128
- }
351129
-
351130
- return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
351131
- };
351132
-
351133
351383
  /***/ }),
351134
351384
 
351135
351385
  /***/ 30486:
@@ -351363,34 +351613,30 @@ var utils_1 = __nccwpck_require__(37461);
351363
351613
 
351364
351614
  var getEnvironment_1 = __nccwpck_require__(60740);
351365
351615
 
351616
+ var getEnvironmentContext_1 = __nccwpck_require__(95141);
351617
+
351366
351618
  __exportStar(__nccwpck_require__(60740), exports);
351367
351619
 
351620
+ __exportStar(__nccwpck_require__(76602), exports);
351621
+
351368
351622
  var createContext = function (config, componentName, env, commitInfo, packageManagerInfo) {
351369
351623
  return __awaiter(void 0, void 0, void 0, function () {
351370
- var rawConfig, envConfig, componentConfigWithoutDefaults, defaults, componentConfig;
351624
+ var envContext, componentConfigWithoutDefaults, defaults, componentConfig;
351371
351625
 
351372
351626
  var _a;
351373
351627
 
351374
- var _b, _c;
351375
-
351376
- return __generator(this, function (_d) {
351377
- switch (_d.label) {
351628
+ return __generator(this, function (_b) {
351629
+ switch (_b.label) {
351378
351630
  case 0:
351379
351631
  if (!/^[a-z0-9-]+$/.test(componentName)) {
351380
351632
  throw new Error("componentName may only contain lower case letters, numbers and -");
351381
351633
  }
351382
351634
 
351383
- rawConfig = config.components[componentName];
351384
-
351385
- if (!rawConfig) {
351386
- throw new Error("unknown component " + componentName);
351387
- }
351388
-
351389
- envConfig = (_c = (_b = rawConfig.env) === null || _b === void 0 ? void 0 : _b[env]) !== null && _c !== void 0 ? _c : {};
351390
- componentConfigWithoutDefaults = (0, utils_1.mergeWithMergingArrays)(rawConfig, envConfig);
351635
+ envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
351636
+ componentConfigWithoutDefaults = envContext.envConfigRaw;
351391
351637
  defaults = componentConfigWithoutDefaults.deploy ? {
351392
- build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(),
351393
- deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults()
351638
+ build: build_1.BUILD_TYPES[componentConfigWithoutDefaults.build.type].defaults(envContext),
351639
+ deploy: deploy_1.DEPLOY_TYPES[componentConfigWithoutDefaults.deploy.type].defaults(envContext)
351394
351640
  } : {
351395
351641
  build: {},
351396
351642
  deploy: {}
@@ -351408,7 +351654,7 @@ var createContext = function (config, componentName, env, commitInfo, packageMan
351408
351654
  case 1:
351409
351655
  return [2
351410
351656
  /*return*/
351411
- , (_a.environment = _d.sent(), _a.commitInfo = commitInfo, _a.packageManagerInfo = packageManagerInfo, _a)];
351657
+ , (_a.environment = _b.sent(), _a.commitInfo = commitInfo, _a.packageManagerInfo = packageManagerInfo, _a)];
351412
351658
  }
351413
351659
  });
351414
351660
  });
@@ -351979,13 +352225,15 @@ var types_1 = __nccwpck_require__(63109);
351979
352225
  var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(22607);
351980
352226
 
351981
352227
  var createGoogleCloudRunDeployJobs = function (context) {
352228
+ var _a, _b;
352229
+
351982
352230
  var deployConfig = context.componentConfig.deploy;
351983
352231
 
351984
352232
  if (deployConfig === false) {
351985
352233
  return [];
351986
352234
  }
351987
352235
 
351988
- if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun", "google-cloudrun-job")) {
352236
+ if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
351989
352237
  // should not happen
351990
352238
  throw new Error("deploy config is wrong");
351991
352239
  }
@@ -352006,44 +352254,76 @@ var createGoogleCloudRunDeployJobs = function (context) {
352006
352254
  return "".concat(key, "=").concat(value);
352007
352255
  }).join(",");
352008
352256
  var commonArgs = "--project ".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
352257
+ var commonDeployArgs = "--image ".concat(gcloudImageName, " ").concat(commonArgs, " --labels ").concat(labelsString);
352258
+ var serviceName = context.environment.fullName.toLowerCase();
352009
352259
 
352010
- var getDeployCommand = function () {
352260
+ var getServiceDeployScript = function (service) {
352011
352261
  var _a;
352012
352262
 
352013
- var name = context.environment.fullName.toLowerCase();
352014
- var command = (_a = deployConfig.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand;
352263
+ var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
352015
352264
  var commandArg = command ? "--command=\"".concat(command.split(" ").join(","), "\"") : "";
352016
- var commonDeployArgs = "".concat(commandArg, " --image ").concat(gcloudImageName, " ").concat(commonArgs, " --env-vars-file=____envvars.yaml --labels ").concat(labelsString);
352265
+ return "gcloud run deploy ".concat(serviceName, " ").concat(commandArg, " ").concat(commonDeployArgs, " --env-vars-file=____envvars.yaml --allow-unauthenticated");
352266
+ };
352017
352267
 
352018
- if (deployConfig.type === "google-cloudrun") {
352019
- return "gcloud run deploy ".concat(name, " ").concat(commonDeployArgs, " --allow-unauthenticated");
352020
- }
352268
+ var getJobDeployScripts = function (jobName, job) {
352269
+ // due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
352270
+ // lucky, update on the other hand accepts it... so let's just imediatly update it
352271
+ // also we cannot upsert a job, so we have to create it and catch the error and then update
352272
+ var args = "".concat(jobName, " --command=\"").concat(job.command.split(" ").join(","), "\" ").concat(commonDeployArgs);
352273
+ return ["set +e", "gcloud beta run jobs create ".concat(args), "set -e", "gcloud beta run jobs update ".concat(args, " --env-vars-file=____envvars.yaml")];
352274
+ };
352021
352275
 
352022
- if (deployConfig.type === "google-cloudrun-job") {
352023
- return "gcloud beta run jobs create ".concat(name, " ").concat(commonDeployArgs);
352024
- }
352276
+ var getJobRunScript = function (jobName) {
352277
+ return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgs);
352025
352278
  };
352026
352279
 
352027
- var getStopCommand = function () {
352028
- var name = context.environment.fullName.toLowerCase();
352029
- var commonStopArgs = "".concat(commonArgs, " --quiet");
352280
+ var getFullJobName = function (name) {
352281
+ return context.environment.fullName.toLowerCase() + "-" + name;
352282
+ };
352030
352283
 
352031
- if (deployConfig.type === "google-cloudrun") {
352032
- return "gcloud run services delete ".concat(name, " ").concat(commonStopArgs);
352033
- }
352284
+ var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
352285
+ var _b = __read(_a, 2),
352286
+ name = _b[0],
352287
+ job = _b[1];
352034
352288
 
352035
- if (deployConfig.type === "google-cloudrun-job") {
352036
- return "gcloud beta run jobs delete ".concat(name, " ").concat(commonStopArgs);
352037
- }
352038
- };
352289
+ return [getFullJobName(name), job];
352290
+ });
352291
+
352292
+ var cloudRunDeployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml"], __read(jobsWithNames.map(function (_a) {
352293
+ var _b = __read(_a, 2),
352294
+ name = _b[0],
352295
+ job = _b[1];
352296
+
352297
+ return getJobDeployScripts(name, job);
352298
+ }).flat()), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(jobsWithNames.filter(function (_a) {
352299
+ var _b = __read(_a, 2),
352300
+ name = _b[0],
352301
+ job = _b[1];
352302
+
352303
+ return job.when === "postDeploy";
352304
+ }).map(function (_a) {
352305
+ var _b = __read(_a, 2),
352306
+ name = _b[0],
352307
+ job = _b[1];
352308
+
352309
+ return getJobRunScript(name);
352310
+ })), false), ["docker image rm ".concat(gcloudImageName)], false);
352311
+
352312
+ 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) {
352313
+ var _b = __read(_a, 2),
352314
+ jobName = _b[0],
352315
+ job = _b[1];
352316
+
352317
+ return "gcloud beta run jobs delete ".concat(jobName);
352318
+ })), false);
352039
352319
 
352040
- var cloudRunDeploy = ["echo \"$ENV_VARS\" > ____envvars.yaml", getDeployCommand(), "docker image rm ".concat(gcloudImageName)];
352041
352320
  var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
352042
352321
  return [(0, lodash_1.merge)({}, baseDeploymentJob, (0, docker_1.getDockerJobBaseProps)(context), {
352043
352322
  artifacts: {
352044
352323
  paths: ["____envvars.yaml"]
352045
352324
  },
352046
352325
  variables: {
352326
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
352047
352327
  ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
352048
352328
  lineWidth: -1,
352049
352329
  quotingType: "'",
@@ -352051,10 +352331,13 @@ var createGoogleCloudRunDeployJobs = function (context) {
352051
352331
  })
352052
352332
  },
352053
352333
  image: (0, runner_1.getRunnerImage)("gcloud"),
352054
- script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeploy), false)
352334
+ script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeployScripts), false)
352055
352335
  }), (0, lodash_1.merge)({}, baseStopJob, {
352056
352336
  image: (0, runner_1.getRunnerImage)("gcloud"),
352057
- script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), [getStopCommand()], false)
352337
+ variables: {
352338
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1"
352339
+ },
352340
+ script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(cloudRunStopScripts), false)
352058
352341
  })];
352059
352342
  };
352060
352343
 
@@ -352063,13 +352346,52 @@ exports.createGoogleCloudRunDeployJobs = createGoogleCloudRunDeployJobs;
352063
352346
  /***/ }),
352064
352347
 
352065
352348
  /***/ 81344:
352066
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
352349
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
352067
352350
 
352068
352351
  "use strict";
352069
352352
 
352070
352353
 
352354
+ var __assign = this && this.__assign || function () {
352355
+ __assign = Object.assign || function (t) {
352356
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
352357
+ s = arguments[i];
352358
+
352359
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
352360
+ }
352361
+
352362
+ return t;
352363
+ };
352364
+
352365
+ return __assign.apply(this, arguments);
352366
+ };
352367
+
352368
+ var __read = this && this.__read || function (o, n) {
352369
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
352370
+ if (!m) return o;
352371
+ var i = m.call(o),
352372
+ r,
352373
+ ar = [],
352374
+ e;
352375
+
352376
+ try {
352377
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
352378
+ } catch (error) {
352379
+ e = {
352380
+ error: error
352381
+ };
352382
+ } finally {
352383
+ try {
352384
+ if (r && !r.done && (m = i["return"])) m.call(i);
352385
+ } finally {
352386
+ if (e) throw e.error;
352387
+ }
352388
+ }
352389
+
352390
+ return ar;
352391
+ };
352392
+
352071
352393
  exports.__esModule = true;
352072
- 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;
352394
+ exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
352073
352395
 
352074
352396
  var context_1 = __nccwpck_require__(22041);
352075
352397
 
@@ -352088,40 +352410,21 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
352088
352410
  getAdditionalEnvVars: function (_a) {
352089
352411
  var fullName = _a.fullName,
352090
352412
  env = _a.env,
352091
- componentName = _a.componentName;
352413
+ componentName = _a.componentName,
352414
+ deployConfigRaw = _a.deployConfigRaw;
352092
352415
  var HOST_CANONICAL = fullName.toLowerCase() + "-" + process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)];
352093
- return {
352094
- HOST_CANONICAL: HOST_CANONICAL
352095
- };
352096
- }
352097
- };
352098
- exports.GCLOUD_RUN_JOB_DEPLOY_TYPE = {
352099
- jobs: deployJob_1.createGoogleCloudRunDeployJobs,
352100
- defaults: function () {
352101
- return {};
352102
- },
352103
- additionalSecretKeys: function () {
352104
- return [exports.GCLOUD_DEPLOY_CREDENTIALS_KEY];
352105
- },
352106
- getAdditionalEnvVars: function (_a) {
352107
- var deployConfig = _a.deployConfig,
352108
- fullName = _a.fullName;
352109
-
352110
- if (!deployConfig) {
352111
- return {};
352112
- }
352416
+ var jobTriggers = deployConfigRaw && deployConfigRaw.jobs ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(function (_a) {
352417
+ var _b = __read(_a, 2),
352418
+ name = _b[0],
352419
+ job = _b[1];
352113
352420
 
352114
- var jobName = fullName.toLowerCase();
352115
- 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");
352116
- return {
352117
- CLOUD_RUN_JOB_TRIGGER_URL: CLOUD_RUN_JOB_TRIGGER_URL
352118
- };
352421
+ 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")];
352422
+ })) : {};
352423
+ return __assign({
352424
+ HOST_CANONICAL: HOST_CANONICAL
352425
+ }, jobTriggers);
352119
352426
  }
352120
352427
  };
352121
- exports.GCLOUD_RUN_DEPLOY_TYPES = {
352122
- "google-cloudrun": exports.GCLOUD_RUN_DEPLOY_TYPE,
352123
- "google-cloudrun-job": exports.GCLOUD_RUN_JOB_DEPLOY_TYPE
352124
- };
352125
352428
 
352126
352429
  /***/ }),
352127
352430
 
@@ -352356,20 +352659,6 @@ exports.DOCKER_TAG_DEPLOY_TYPE = {
352356
352659
  "use strict";
352357
352660
 
352358
352661
 
352359
- var __assign = this && this.__assign || function () {
352360
- __assign = Object.assign || function (t) {
352361
- for (var s, i = 1, n = arguments.length; i < n; i++) {
352362
- s = arguments[i];
352363
-
352364
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
352365
- }
352366
-
352367
- return t;
352368
- };
352369
-
352370
- return __assign.apply(this, arguments);
352371
- };
352372
-
352373
352662
  var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
352374
352663
  if (k2 === undefined) k2 = k;
352375
352664
  Object.defineProperty(o, k2, {
@@ -352398,21 +352687,22 @@ var dockerTag_1 = __nccwpck_require__(18990);
352398
352687
 
352399
352688
  var kubernetes_1 = __nccwpck_require__(95682);
352400
352689
 
352690
+ __exportStar(__nccwpck_require__(81344), exports);
352691
+
352692
+ __exportStar(__nccwpck_require__(13539), exports);
352693
+
352401
352694
  __exportStar(__nccwpck_require__(95682), exports);
352402
352695
 
352403
352696
  __exportStar(__nccwpck_require__(63109), exports);
352404
352697
 
352405
352698
  __exportStar(__nccwpck_require__(92757), exports);
352406
352699
 
352407
- __exportStar(__nccwpck_require__(13539), exports);
352408
-
352409
- __exportStar(__nccwpck_require__(81344), exports);
352410
-
352411
- exports.DEPLOY_TYPES = __assign({
352700
+ exports.DEPLOY_TYPES = {
352412
352701
  kubernetes: kubernetes_1.KUBERNETES_DEPLOY_TYPE,
352413
352702
  custom: custom_1.CUSTOM_DEPLOY_TYPE,
352414
- dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE
352415
- }, cloudRun_1.GCLOUD_RUN_DEPLOY_TYPES);
352703
+ dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE,
352704
+ "google-cloudrun": cloudRun_1.GCLOUD_RUN_DEPLOY_TYPE
352705
+ };
352416
352706
 
352417
352707
  /***/ }),
352418
352708
 
@@ -352428,23 +352718,23 @@ exports.additionalKubernetesSecretKeys = void 0;
352428
352718
  var additionalKubernetesSecretKeys = function (_a) {
352429
352719
  var _b, _c, _d, _e;
352430
352720
 
352431
- var deployConfig = _a.deployConfig;
352721
+ var deployConfigRaw = _a.deployConfigRaw;
352432
352722
 
352433
- if (!deployConfig) {
352723
+ if (!deployConfigRaw) {
352434
352724
  return [];
352435
352725
  }
352436
352726
 
352437
352727
  var keys = [];
352438
352728
 
352439
- if ((_c = (_b = deployConfig.values) === null || _b === void 0 ? void 0 : _b.mongodb) === null || _c === void 0 ? void 0 : _c.enabled) {
352729
+ if ((_c = (_b = deployConfigRaw.values) === null || _b === void 0 ? void 0 : _b.mongodb) === null || _c === void 0 ? void 0 : _c.enabled) {
352440
352730
  keys.push("MONGODB_ROOT_PASSWORD");
352441
352731
 
352442
- if (deployConfig.values.mongodb.architecture === "replicaset") {
352732
+ if (deployConfigRaw.values.mongodb.architecture === "replicaset") {
352443
352733
  keys.push("MONGODB_REPLICASET_KEY");
352444
352734
  }
352445
352735
  }
352446
352736
 
352447
- if ((_e = (_d = deployConfig.values) === null || _d === void 0 ? void 0 : _d.cloudsql) === null || _e === void 0 ? void 0 : _e.enabled) {
352737
+ if ((_e = (_d = deployConfigRaw.values) === null || _d === void 0 ? void 0 : _d.cloudsql) === null || _e === void 0 ? void 0 : _e.enabled) {
352448
352738
  keys.push("POSTGRESQL_PASSWORD");
352449
352739
  keys.push("cloudsqlProxyCredentials");
352450
352740
  }
@@ -352647,7 +352937,7 @@ exports.KUBERNETES_DEPLOY_TYPE = {
352647
352937
 
352648
352938
  var componentName = _a.componentName,
352649
352939
  fullConfig = _a.fullConfig,
352650
- deployConfig = _a.deployConfig,
352940
+ deployConfigRaw = _a.deployConfigRaw,
352651
352941
  env = _a.env,
352652
352942
  envType = _a.envType,
352653
352943
  commitInfo = _a.commitInfo;
@@ -352656,7 +352946,7 @@ exports.KUBERNETES_DEPLOY_TYPE = {
352656
352946
  var KUBE_NAMESPACE = (0, __1.getKubernetesNamespace)(fullConfig, env);
352657
352947
  var componentSlug = (0, slugify_1["default"])(componentName);
352658
352948
  var envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
352659
- 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
352949
+ 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
352660
352950
  fullConfig.domainCanonical || "panter.cloud";
352661
352951
  var HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(fullConfig.appName, ".").concat(fullConfig.customerName, ".").concat(domainCanonical); // default for kubernetes and rest
352662
352952