@catladder/cli 0.0.0-main-b9978361 → 0.0.0-main-24bccda4

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 (32) hide show
  1. package/dist/apps/cli/commands/project/setup/setupCloudRun.d.ts +3 -0
  2. package/dist/apps/cli/commands/project/setup/setupCloudRun.js +92 -0
  3. package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -0
  4. package/dist/apps/cli/commands/project/setup/setupContext.js +12 -5
  5. package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  6. package/dist/apps/cli/commands/shared/index.js.map +1 -1
  7. package/dist/bundles/catenv/index.js +320 -25
  8. package/dist/bundles/cli/index.js +871 -109
  9. package/dist/gcloud/artifactsRegistry.d.ts +5 -0
  10. package/dist/gcloud/artifactsRegistry.js +59 -0
  11. package/dist/gcloud/artifactsRegistry.js.map +1 -0
  12. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.d.ts +2 -0
  13. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +67 -0
  14. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -0
  15. package/dist/gcloud/enableServices.d.ts +3 -0
  16. package/dist/gcloud/enableServices.js +63 -0
  17. package/dist/gcloud/enableServices.js.map +1 -0
  18. package/dist/gcloud/serviceAccounts.d.ts +12 -0
  19. package/dist/gcloud/serviceAccounts.js +144 -0
  20. package/dist/gcloud/serviceAccounts.js.map +1 -0
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/dist/utils/gitlab.js +1 -1
  23. package/dist/utils/gitlab.js.map +1 -1
  24. package/package.json +2 -2
  25. package/src/apps/cli/commands/project/setup/setupCloudRun.ts +69 -0
  26. package/src/apps/cli/commands/project/setup/setupContext.ts +4 -1
  27. package/src/apps/cli/commands/shared/index.ts +0 -4
  28. package/src/gcloud/artifactsRegistry.ts +16 -0
  29. package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +34 -0
  30. package/src/gcloud/enableServices.ts +14 -0
  31. package/src/gcloud/serviceAccounts.ts +101 -0
  32. package/src/utils/gitlab.ts +2 -2
@@ -4033,6 +4033,105 @@ exports.setupAccessTokens = setupAccessTokens;
4033
4033
 
4034
4034
  /***/ }),
4035
4035
 
4036
+ /***/ 89010:
4037
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
4038
+
4039
+ "use strict";
4040
+
4041
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4042
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4043
+ return new (P || (P = Promise))(function (resolve, reject) {
4044
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4045
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4046
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4047
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
4048
+ });
4049
+ };
4050
+ var __generator = (this && this.__generator) || function (thisArg, body) {
4051
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
4052
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4053
+ function verb(n) { return function (v) { return step([n, v]); }; }
4054
+ function step(op) {
4055
+ if (f) throw new TypeError("Generator is already executing.");
4056
+ while (_) try {
4057
+ 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;
4058
+ if (y = 0, t) op = [op[0] & 2, t.value];
4059
+ switch (op[0]) {
4060
+ case 0: case 1: t = op; break;
4061
+ case 4: _.label++; return { value: op[1], done: false };
4062
+ case 5: _.label++; y = op[1]; op = [0]; continue;
4063
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
4064
+ default:
4065
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
4066
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
4067
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
4068
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
4069
+ if (t[2]) _.ops.pop();
4070
+ _.trys.pop(); continue;
4071
+ }
4072
+ op = body.call(thisArg, _);
4073
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4074
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4075
+ }
4076
+ };
4077
+ exports.__esModule = true;
4078
+ exports.setupCloudRun = void 0;
4079
+ var pipeline_1 = __nccwpck_require__(25355);
4080
+ var artifactsRegistry_1 = __nccwpck_require__(78118);
4081
+ var getCloudRunDomainSuffix_1 = __nccwpck_require__(33414);
4082
+ var enableServices_1 = __nccwpck_require__(4895);
4083
+ var serviceAccounts_1 = __nccwpck_require__(79772);
4084
+ var gitlab_1 = __nccwpck_require__(79818);
4085
+ var setupCloudRun = function (instance, context) { return __awaiter(void 0, void 0, void 0, function () {
4086
+ var config, suffix;
4087
+ var _a;
4088
+ return __generator(this, function (_b) {
4089
+ switch (_b.label) {
4090
+ case 0:
4091
+ if (!(0, pipeline_1.isOfDeployType)(context.componentConfig.deploy, "google-cloudrun")) {
4092
+ throw new Error("deploy config is not of type 'google-cloudrun'");
4093
+ }
4094
+ config = context.componentConfig.deploy;
4095
+ // enable services
4096
+ instance.log("enable required servies...");
4097
+ return [4 /*yield*/, (0, enableServices_1.enableGCloudServices)(["run.googleapis.com", "artifactregistry.googleapis.com"], config)];
4098
+ case 1:
4099
+ _b.sent();
4100
+ return [4 /*yield*/, (0, artifactsRegistry_1.upsertGcloudArtifactsRegistry)(config)];
4101
+ case 2:
4102
+ _b.sent();
4103
+ return [4 /*yield*/, (0, serviceAccounts_1.upsertGcloudServiceAccountAndSaveSecret)(instance, context, {
4104
+ projectId: config.projectId,
4105
+ displayName: "Catladder gcloud deploy",
4106
+ description: "This service account deploys to google cloud",
4107
+ name: "cl-d",
4108
+ // TODO: run.admin is a bit much, would be better to follow https://stackoverflow.com/questions/55788714/deploying-to-cloud-run-with-a-custom-service-account-failed-with-iam-serviceacco
4109
+ roles: [
4110
+ "roles/artifactregistry.repoAdmin",
4111
+ "roles/run.admin",
4112
+ "roles/iam.serviceAccountUser",
4113
+ ]
4114
+ }, pipeline_1.GCLOUD_DEPLOY_CREDENTIALS_KEY)];
4115
+ case 3:
4116
+ _b.sent();
4117
+ return [4 /*yield*/, (0, getCloudRunDomainSuffix_1.getCloudRunDomainSuffix)(config)];
4118
+ case 4:
4119
+ suffix = _b.sent();
4120
+ instance.log("domain suffix: " + suffix);
4121
+ return [4 /*yield*/, (0, gitlab_1.upsertAllVariables)(instance, (_a = {},
4122
+ _a[pipeline_1.GCLOUD_RUN_CANONICAL_HOST_SUFFIX] = suffix,
4123
+ _a), context.environment.shortName, context.componentName)];
4124
+ case 5:
4125
+ _b.sent();
4126
+ return [2 /*return*/];
4127
+ }
4128
+ });
4129
+ }); };
4130
+ exports.setupCloudRun = setupCloudRun;
4131
+ //# sourceMappingURL=setupCloudRun.js.map
4132
+
4133
+ /***/ }),
4134
+
4036
4135
  /***/ 63660:
4037
4136
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
4038
4137
 
@@ -4140,6 +4239,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
4140
4239
  exports.__esModule = true;
4141
4240
  exports.setupContext = void 0;
4142
4241
  var pipeline_1 = __nccwpck_require__(25355);
4242
+ var setupCloudRun_1 = __nccwpck_require__(89010);
4143
4243
  var setupCloudSQL_1 = __nccwpck_require__(63660);
4144
4244
  var setupKubernetes_1 = __nccwpck_require__(82308);
4145
4245
  var setupContext = function (instance, context) { return __awaiter(void 0, void 0, void 0, function () {
@@ -4155,19 +4255,25 @@ var setupContext = function (instance, context) { return __awaiter(void 0, void
4155
4255
  context.componentName +
4156
4256
  "...");
4157
4257
  instance.log("");
4158
- if (!(0, pipeline_1.hasCloudSQL)(context)) return [3 /*break*/, 2];
4159
- return [4 /*yield*/, (0, setupCloudSQL_1.setupCloudSQL)(instance, context)];
4258
+ if (!(0, pipeline_1.isOfDeployType)(context.componentConfig.deploy, "google-cloudrun")) return [3 /*break*/, 2];
4259
+ return [4 /*yield*/, (0, setupCloudRun_1.setupCloudRun)(instance, context)];
4160
4260
  case 1:
4161
4261
  _a.sent();
4162
4262
  _a.label = 2;
4163
4263
  case 2:
4164
- deployConfig = context.componentConfig.deploy;
4165
- if (!(0, pipeline_1.isOfDeployType)(deployConfig, "kubernetes")) return [3 /*break*/, 4];
4166
- return [4 /*yield*/, (0, setupKubernetes_1.setupKubernetes)(instance, context)];
4264
+ if (!(0, pipeline_1.hasCloudSQL)(context)) return [3 /*break*/, 4];
4265
+ return [4 /*yield*/, (0, setupCloudSQL_1.setupCloudSQL)(instance, context)];
4167
4266
  case 3:
4168
4267
  _a.sent();
4169
4268
  _a.label = 4;
4170
4269
  case 4:
4270
+ deployConfig = context.componentConfig.deploy;
4271
+ if (!(0, pipeline_1.isOfDeployType)(deployConfig, "kubernetes")) return [3 /*break*/, 6];
4272
+ return [4 /*yield*/, (0, setupKubernetes_1.setupKubernetes)(instance, context)];
4273
+ case 5:
4274
+ _a.sent();
4275
+ _a.label = 6;
4276
+ case 6:
4171
4277
  instance.log("");
4172
4278
  instance.log("✅ " +
4173
4279
  context.environment.shortName +
@@ -5971,43 +6077,73 @@ exports.parseChoice = parseChoice;
5971
6077
 
5972
6078
  /***/ }),
5973
6079
 
5974
- /***/ 54756:
5975
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6080
+ /***/ 78118:
6081
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
5976
6082
 
5977
6083
  "use strict";
5978
6084
 
5979
- exports.__esModule = true;
5980
- exports.getk8sApiBatchBeta = exports.getk8sApiBatch = exports.getk8sApi = void 0;
5981
- var client_node_1 = __nccwpck_require__(15124);
5982
- var getKubeConfig = function () {
5983
- var kc = new client_node_1.KubeConfig();
5984
- kc.loadFromDefault();
5985
- return kc;
5986
- };
5987
- /**
5988
- * get kubernetes client. avoid reusing the instance when context get changed
5989
- * @returns kuberenetes client
5990
- */
5991
- var getk8sApi = function () {
5992
- var kc = getKubeConfig();
5993
- return kc.makeApiClient(client_node_1.CoreV1Api);
5994
- };
5995
- exports.getk8sApi = getk8sApi;
5996
- var getk8sApiBatch = function () {
5997
- var kc = getKubeConfig();
5998
- return kc.makeApiClient(client_node_1.BatchV1Api);
6085
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6086
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6087
+ return new (P || (P = Promise))(function (resolve, reject) {
6088
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6089
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6090
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6091
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
6092
+ });
5999
6093
  };
6000
- exports.getk8sApiBatch = getk8sApiBatch;
6001
- var getk8sApiBatchBeta = function () {
6002
- var kc = getKubeConfig();
6003
- return kc.makeApiClient(client_node_1.BatchV1beta1Api);
6094
+ var __generator = (this && this.__generator) || function (thisArg, body) {
6095
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6096
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6097
+ function verb(n) { return function (v) { return step([n, v]); }; }
6098
+ function step(op) {
6099
+ if (f) throw new TypeError("Generator is already executing.");
6100
+ while (_) try {
6101
+ 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;
6102
+ if (y = 0, t) op = [op[0] & 2, t.value];
6103
+ switch (op[0]) {
6104
+ case 0: case 1: t = op; break;
6105
+ case 4: _.label++; return { value: op[1], done: false };
6106
+ case 5: _.label++; y = op[1]; op = [0]; continue;
6107
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
6108
+ default:
6109
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6110
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6111
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6112
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6113
+ if (t[2]) _.ops.pop();
6114
+ _.trys.pop(); continue;
6115
+ }
6116
+ op = body.call(thisArg, _);
6117
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6118
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6119
+ }
6004
6120
  };
6005
- exports.getk8sApiBatchBeta = getk8sApiBatchBeta;
6006
- //# sourceMappingURL=index.js.map
6121
+ exports.__esModule = true;
6122
+ exports.upsertGcloudArtifactsRegistry = void 0;
6123
+ var child_process_promise_1 = __nccwpck_require__(75763);
6124
+ var upsertGcloudArtifactsRegistry = function (config) { return __awaiter(void 0, void 0, void 0, function () {
6125
+ var e_1;
6126
+ return __generator(this, function (_a) {
6127
+ switch (_a.label) {
6128
+ case 0:
6129
+ _a.trys.push([0, 2, , 3]);
6130
+ return [4 /*yield*/, (0, child_process_promise_1.exec)("gcloud artifacts repositories create catladder-deploy --project=\"".concat(config.projectId, "\" --repository-format=docker --location=").concat(config.region))];
6131
+ case 1:
6132
+ _a.sent();
6133
+ return [3 /*break*/, 3];
6134
+ case 2:
6135
+ e_1 = _a.sent();
6136
+ return [3 /*break*/, 3];
6137
+ case 3: return [2 /*return*/];
6138
+ }
6139
+ });
6140
+ }); };
6141
+ exports.upsertGcloudArtifactsRegistry = upsertGcloudArtifactsRegistry;
6142
+ //# sourceMappingURL=artifactsRegistry.js.map
6007
6143
 
6008
6144
  /***/ }),
6009
6145
 
6010
- /***/ 80606:
6146
+ /***/ 33414:
6011
6147
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
6012
6148
 
6013
6149
  "use strict";
@@ -6049,73 +6185,404 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
6049
6185
  }
6050
6186
  };
6051
6187
  exports.__esModule = true;
6052
- exports.getProjectPodNames = exports.getProjectPvcs = exports.getProjectPods = void 0;
6053
- var parseChoice_1 = __nccwpck_require__(3319);
6054
- var k8sApi_1 = __nccwpck_require__(54756);
6055
- var projects_1 = __nccwpck_require__(41619);
6056
- var getProjectPods = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
6057
- var namespace, k8sApi, res, componentName;
6058
- return __generator(this, function (_a) {
6059
- switch (_a.label) {
6060
- case 0: return [4 /*yield*/, (0, projects_1.getProjectNamespace)(envComponent)];
6061
- case 1:
6062
- namespace = _a.sent();
6063
- k8sApi = (0, k8sApi_1.getk8sApi)();
6064
- return [4 /*yield*/, k8sApi.listNamespacedPod(namespace)];
6065
- case 2:
6066
- res = _a.sent();
6067
- componentName = (0, parseChoice_1.parseChoice)(envComponent).componentName;
6068
- return [2 /*return*/, res.body.items.filter(function (item) { var _a, _b; return componentName ? (_b = (_a = item.metadata) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.includes(componentName + "-") : true; })];
6069
- }
6070
- });
6071
- }); };
6072
- exports.getProjectPods = getProjectPods;
6073
- var getProjectPvcs = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
6074
- var namespace, k8sApi, res;
6188
+ exports.getCloudRunDomainSuffix = void 0;
6189
+ var child_process_promise_1 = __nccwpck_require__(75763);
6190
+ var getSuffixFromService = function (service) {
6191
+ var fullUrl = service.status.url;
6192
+ var name = service.metadata.name;
6193
+ return fullUrl.replace("https://" + name + "-", "");
6194
+ };
6195
+ var getCloudRunDomainSuffix = function (config) { return __awaiter(void 0, void 0, void 0, function () {
6196
+ var dummyServiceName, existingServices, result;
6075
6197
  return __generator(this, function (_a) {
6076
6198
  switch (_a.label) {
6077
- case 0: return [4 /*yield*/, (0, projects_1.getProjectNamespace)(envComponent)];
6199
+ case 0:
6200
+ dummyServiceName = "cl-dummy-service";
6201
+ return [4 /*yield*/, (0, child_process_promise_1.exec)("gcloud run services list --format=json --project=\"".concat(config.projectId, "\" --region=").concat(config.region, " --limit=1")).then(function (r) { return JSON.parse(r.stdout); })];
6078
6202
  case 1:
6079
- namespace = _a.sent();
6080
- k8sApi = (0, k8sApi_1.getk8sApi)();
6081
- return [4 /*yield*/, k8sApi.listNamespacedPersistentVolumeClaim(namespace)];
6203
+ existingServices = _a.sent();
6204
+ if (existingServices.length > 0) {
6205
+ return [2 /*return*/, getSuffixFromService(existingServices[0])];
6206
+ }
6207
+ return [4 /*yield*/, (0, child_process_promise_1.exec)("gcloud run deploy ".concat(dummyServiceName, " --region=").concat(config.region, " --allow-unauthenticated --project ").concat(config.projectId, " --image=us-docker.pkg.dev/cloudrun/container/hello --format=json")).then(function (r) { return JSON.parse(r.stdout); })];
6082
6208
  case 2:
6083
- res = _a.sent();
6084
- return [2 /*return*/, res.body.items];
6085
- }
6086
- });
6087
- }); };
6088
- exports.getProjectPvcs = getProjectPvcs;
6089
- var getProjectPodNames = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
6090
- var pods;
6091
- return __generator(this, function (_a) {
6092
- switch (_a.label) {
6093
- case 0: return [4 /*yield*/, (0, exports.getProjectPods)(envComponent)];
6094
- case 1:
6095
- pods = _a.sent();
6096
- return [2 /*return*/, pods.map(function (n) { return n.metadata.name; })];
6209
+ result = _a.sent();
6210
+ return [4 /*yield*/, getSuffixFromService(result)];
6211
+ case 3: return [2 /*return*/, _a.sent()];
6097
6212
  }
6098
6213
  });
6099
6214
  }); };
6100
- exports.getProjectPodNames = getProjectPodNames;
6101
- //# sourceMappingURL=index.js.map
6215
+ exports.getCloudRunDomainSuffix = getCloudRunDomainSuffix;
6216
+ //# sourceMappingURL=getCloudRunDomainSuffix.js.map
6102
6217
 
6103
6218
  /***/ }),
6104
6219
 
6105
- /***/ 71628:
6106
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6220
+ /***/ 4895:
6221
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
6107
6222
 
6108
6223
  "use strict";
6109
6224
 
6225
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6226
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6227
+ return new (P || (P = Promise))(function (resolve, reject) {
6228
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6229
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6230
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6231
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
6232
+ });
6233
+ };
6234
+ var __generator = (this && this.__generator) || function (thisArg, body) {
6235
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6236
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6237
+ function verb(n) { return function (v) { return step([n, v]); }; }
6238
+ function step(op) {
6239
+ if (f) throw new TypeError("Generator is already executing.");
6240
+ while (_) try {
6241
+ 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;
6242
+ if (y = 0, t) op = [op[0] & 2, t.value];
6243
+ switch (op[0]) {
6244
+ case 0: case 1: t = op; break;
6245
+ case 4: _.label++; return { value: op[1], done: false };
6246
+ case 5: _.label++; y = op[1]; op = [0]; continue;
6247
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
6248
+ default:
6249
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6250
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6251
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6252
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6253
+ if (t[2]) _.ops.pop();
6254
+ _.trys.pop(); continue;
6255
+ }
6256
+ op = body.call(thisArg, _);
6257
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6258
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6259
+ }
6260
+ };
6110
6261
  exports.__esModule = true;
6111
- // eslint-disable-next-line @typescript-eslint/no-var-requires
6112
- var ownPkg = __nccwpck_require__(4147);
6113
- exports["default"] = ownPkg;
6114
- //# sourceMappingURL=packageInfos.js.map
6262
+ exports.enableGCloudServices = void 0;
6263
+ var child_process_promise_1 = __nccwpck_require__(75763);
6264
+ var enableGCloudServices = function (services, config) { return __awaiter(void 0, void 0, void 0, function () {
6265
+ var _i, services_1, service;
6266
+ return __generator(this, function (_a) {
6267
+ switch (_a.label) {
6268
+ case 0:
6269
+ _i = 0, services_1 = services;
6270
+ _a.label = 1;
6271
+ case 1:
6272
+ if (!(_i < services_1.length)) return [3 /*break*/, 4];
6273
+ service = services_1[_i];
6274
+ return [4 /*yield*/, (0, child_process_promise_1.exec)("gcloud services enable ".concat(service, " --project=").concat(config.projectId))];
6275
+ case 2:
6276
+ _a.sent();
6277
+ _a.label = 3;
6278
+ case 3:
6279
+ _i++;
6280
+ return [3 /*break*/, 1];
6281
+ case 4: return [2 /*return*/];
6282
+ }
6283
+ });
6284
+ }); };
6285
+ exports.enableGCloudServices = enableGCloudServices;
6286
+ //# sourceMappingURL=enableServices.js.map
6115
6287
 
6116
6288
  /***/ }),
6117
6289
 
6118
- /***/ 66894:
6290
+ /***/ 79772:
6291
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
6292
+
6293
+ "use strict";
6294
+
6295
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6296
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6297
+ return new (P || (P = Promise))(function (resolve, reject) {
6298
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6299
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6300
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6301
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
6302
+ });
6303
+ };
6304
+ var __generator = (this && this.__generator) || function (thisArg, body) {
6305
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6306
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6307
+ function verb(n) { return function (v) { return step([n, v]); }; }
6308
+ function step(op) {
6309
+ if (f) throw new TypeError("Generator is already executing.");
6310
+ while (_) try {
6311
+ 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;
6312
+ if (y = 0, t) op = [op[0] & 2, t.value];
6313
+ switch (op[0]) {
6314
+ case 0: case 1: t = op; break;
6315
+ case 4: _.label++; return { value: op[1], done: false };
6316
+ case 5: _.label++; y = op[1]; op = [0]; continue;
6317
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
6318
+ default:
6319
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6320
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6321
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6322
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6323
+ if (t[2]) _.ops.pop();
6324
+ _.trys.pop(); continue;
6325
+ }
6326
+ op = body.call(thisArg, _);
6327
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6328
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6329
+ }
6330
+ };
6331
+ exports.__esModule = true;
6332
+ exports.upsertGcloudServiceAccountAndSaveSecret = exports.accountExists = void 0;
6333
+ var child_process_promise_1 = __nccwpck_require__(75763);
6334
+ var crypto_1 = __nccwpck_require__(6113);
6335
+ var gitlab_1 = __nccwpck_require__(79818);
6336
+ var accountExists = function (fullIdentifier) { return __awaiter(void 0, void 0, void 0, function () {
6337
+ var _a;
6338
+ return __generator(this, function (_b) {
6339
+ switch (_b.label) {
6340
+ case 0:
6341
+ _b.trys.push([0, 2, , 3]);
6342
+ return [4 /*yield*/, (0, child_process_promise_1.exec)("gcloud iam service-accounts describe ".concat(fullIdentifier))];
6343
+ case 1:
6344
+ _b.sent();
6345
+ return [2 /*return*/, true];
6346
+ case 2:
6347
+ _a = _b.sent();
6348
+ return [2 /*return*/, false];
6349
+ case 3: return [2 /*return*/];
6350
+ }
6351
+ });
6352
+ }); };
6353
+ exports.accountExists = accountExists;
6354
+ var upsertGcloudServiceAccount = function (context, account) { return __awaiter(void 0, void 0, void 0, function () {
6355
+ var projectId, name, displayName, roles, description, namePrefix, nameSuffix, nameMiddleLength, nameMiddle, middle, fullName, fullDisplayName, fullIdentifier, existing, memberName, _i, roles_1, role, keys, _a, keys_1, key;
6356
+ return __generator(this, function (_b) {
6357
+ switch (_b.label) {
6358
+ case 0:
6359
+ projectId = account.projectId, name = account.name, displayName = account.displayName, roles = account.roles, description = account.description;
6360
+ namePrefix = "".concat(name, "-");
6361
+ nameSuffix = "-".concat(context.environment.shortName, "-").concat(context.componentName);
6362
+ nameMiddleLength = 30 - namePrefix.length - nameSuffix.length;
6363
+ nameMiddle = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
6364
+ middle = hashIfNessecary(nameMiddle, nameMiddleLength);
6365
+ fullName = "".concat(namePrefix).concat(middle).concat(nameSuffix);
6366
+ fullDisplayName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName, " ").concat(context.environment.shortName, ":").concat(context.componentName, " | ").concat(displayName);
6367
+ fullIdentifier = "".concat(fullName, "@").concat(projectId, ".iam.gserviceaccount.com");
6368
+ return [4 /*yield*/, (0, exports.accountExists)(fullIdentifier)];
6369
+ case 1:
6370
+ existing = _b.sent();
6371
+ if (!!existing) return [3 /*break*/, 3];
6372
+ return [4 /*yield*/, (0, child_process_promise_1.exec)("gcloud iam service-accounts create ".concat(fullName, " --display-name=\"").concat(fullDisplayName, "\" --project=\"").concat(projectId, "\" --description=\"").concat(description, "\""))];
6373
+ case 2:
6374
+ _b.sent();
6375
+ _b.label = 3;
6376
+ case 3:
6377
+ memberName = "serviceAccount:".concat(fullIdentifier);
6378
+ _i = 0, roles_1 = roles;
6379
+ _b.label = 4;
6380
+ case 4:
6381
+ if (!(_i < roles_1.length)) return [3 /*break*/, 7];
6382
+ role = roles_1[_i];
6383
+ return [4 /*yield*/, (0, child_process_promise_1.exec)("gcloud projects add-iam-policy-binding ".concat(projectId, " --member=").concat(memberName, " --role=").concat(role, " "))];
6384
+ case 5:
6385
+ _b.sent();
6386
+ _b.label = 6;
6387
+ case 6:
6388
+ _i++;
6389
+ return [3 /*break*/, 4];
6390
+ case 7: return [4 /*yield*/, (0, child_process_promise_1.exec)("gcloud iam service-accounts keys list --iam-account=".concat(fullIdentifier, " --managed-by=user --format=json")).then(function (o) { return JSON.parse(o.stdout); })];
6391
+ case 8:
6392
+ keys = _b.sent();
6393
+ _a = 0, keys_1 = keys;
6394
+ _b.label = 9;
6395
+ case 9:
6396
+ if (!(_a < keys_1.length)) return [3 /*break*/, 12];
6397
+ key = keys_1[_a];
6398
+ return [4 /*yield*/, (0, child_process_promise_1.exec)("gcloud iam service-accounts keys delete ".concat(key.name, " --quiet --iam-account=").concat(fullIdentifier))];
6399
+ case 10:
6400
+ _b.sent();
6401
+ _b.label = 11;
6402
+ case 11:
6403
+ _a++;
6404
+ return [3 /*break*/, 9];
6405
+ case 12: return [4 /*yield*/, (0, child_process_promise_1.exec)("gcloud iam service-accounts keys create /dev/stdout --iam-account=".concat(fullIdentifier)).then(function (o) { return o.stdout; })];
6406
+ case 13: return [2 /*return*/, _b.sent()];
6407
+ }
6408
+ });
6409
+ }); };
6410
+ var upsertGcloudServiceAccountAndSaveSecret = function (instance, context, account, secretName) { return __awaiter(void 0, void 0, void 0, function () {
6411
+ var key;
6412
+ var _a;
6413
+ return __generator(this, function (_b) {
6414
+ switch (_b.label) {
6415
+ case 0:
6416
+ instance.log("upserting service account " + account.name + "...");
6417
+ return [4 /*yield*/, upsertGcloudServiceAccount(context, account)];
6418
+ case 1:
6419
+ key = _b.sent();
6420
+ return [4 /*yield*/, (0, gitlab_1.upsertAllVariables)(instance, (_a = {},
6421
+ _a[secretName] = key,
6422
+ _a), context.environment.shortName, context.componentName)];
6423
+ case 2:
6424
+ _b.sent();
6425
+ instance.log("done!");
6426
+ return [2 /*return*/];
6427
+ }
6428
+ });
6429
+ }); };
6430
+ exports.upsertGcloudServiceAccountAndSaveSecret = upsertGcloudServiceAccountAndSaveSecret;
6431
+ var hashIfNessecary = function (str, maxLength) {
6432
+ return str.length > maxLength ? hash(str, maxLength) : str;
6433
+ };
6434
+ var hash = function (str, length) {
6435
+ return (0, crypto_1.createHmac)("sha256", str).digest("hex").substring(0, length);
6436
+ };
6437
+ //# sourceMappingURL=serviceAccounts.js.map
6438
+
6439
+ /***/ }),
6440
+
6441
+ /***/ 54756:
6442
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6443
+
6444
+ "use strict";
6445
+
6446
+ exports.__esModule = true;
6447
+ exports.getk8sApiBatchBeta = exports.getk8sApiBatch = exports.getk8sApi = void 0;
6448
+ var client_node_1 = __nccwpck_require__(15124);
6449
+ var getKubeConfig = function () {
6450
+ var kc = new client_node_1.KubeConfig();
6451
+ kc.loadFromDefault();
6452
+ return kc;
6453
+ };
6454
+ /**
6455
+ * get kubernetes client. avoid reusing the instance when context get changed
6456
+ * @returns kuberenetes client
6457
+ */
6458
+ var getk8sApi = function () {
6459
+ var kc = getKubeConfig();
6460
+ return kc.makeApiClient(client_node_1.CoreV1Api);
6461
+ };
6462
+ exports.getk8sApi = getk8sApi;
6463
+ var getk8sApiBatch = function () {
6464
+ var kc = getKubeConfig();
6465
+ return kc.makeApiClient(client_node_1.BatchV1Api);
6466
+ };
6467
+ exports.getk8sApiBatch = getk8sApiBatch;
6468
+ var getk8sApiBatchBeta = function () {
6469
+ var kc = getKubeConfig();
6470
+ return kc.makeApiClient(client_node_1.BatchV1beta1Api);
6471
+ };
6472
+ exports.getk8sApiBatchBeta = getk8sApiBatchBeta;
6473
+ //# sourceMappingURL=index.js.map
6474
+
6475
+ /***/ }),
6476
+
6477
+ /***/ 80606:
6478
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
6479
+
6480
+ "use strict";
6481
+
6482
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6483
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6484
+ return new (P || (P = Promise))(function (resolve, reject) {
6485
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6486
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6487
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6488
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
6489
+ });
6490
+ };
6491
+ var __generator = (this && this.__generator) || function (thisArg, body) {
6492
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6493
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6494
+ function verb(n) { return function (v) { return step([n, v]); }; }
6495
+ function step(op) {
6496
+ if (f) throw new TypeError("Generator is already executing.");
6497
+ while (_) try {
6498
+ 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;
6499
+ if (y = 0, t) op = [op[0] & 2, t.value];
6500
+ switch (op[0]) {
6501
+ case 0: case 1: t = op; break;
6502
+ case 4: _.label++; return { value: op[1], done: false };
6503
+ case 5: _.label++; y = op[1]; op = [0]; continue;
6504
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
6505
+ default:
6506
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6507
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6508
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6509
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6510
+ if (t[2]) _.ops.pop();
6511
+ _.trys.pop(); continue;
6512
+ }
6513
+ op = body.call(thisArg, _);
6514
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6515
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6516
+ }
6517
+ };
6518
+ exports.__esModule = true;
6519
+ exports.getProjectPodNames = exports.getProjectPvcs = exports.getProjectPods = void 0;
6520
+ var parseChoice_1 = __nccwpck_require__(3319);
6521
+ var k8sApi_1 = __nccwpck_require__(54756);
6522
+ var projects_1 = __nccwpck_require__(41619);
6523
+ var getProjectPods = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
6524
+ var namespace, k8sApi, res, componentName;
6525
+ return __generator(this, function (_a) {
6526
+ switch (_a.label) {
6527
+ case 0: return [4 /*yield*/, (0, projects_1.getProjectNamespace)(envComponent)];
6528
+ case 1:
6529
+ namespace = _a.sent();
6530
+ k8sApi = (0, k8sApi_1.getk8sApi)();
6531
+ return [4 /*yield*/, k8sApi.listNamespacedPod(namespace)];
6532
+ case 2:
6533
+ res = _a.sent();
6534
+ componentName = (0, parseChoice_1.parseChoice)(envComponent).componentName;
6535
+ return [2 /*return*/, res.body.items.filter(function (item) { var _a, _b; return componentName ? (_b = (_a = item.metadata) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.includes(componentName + "-") : true; })];
6536
+ }
6537
+ });
6538
+ }); };
6539
+ exports.getProjectPods = getProjectPods;
6540
+ var getProjectPvcs = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
6541
+ var namespace, k8sApi, res;
6542
+ return __generator(this, function (_a) {
6543
+ switch (_a.label) {
6544
+ case 0: return [4 /*yield*/, (0, projects_1.getProjectNamespace)(envComponent)];
6545
+ case 1:
6546
+ namespace = _a.sent();
6547
+ k8sApi = (0, k8sApi_1.getk8sApi)();
6548
+ return [4 /*yield*/, k8sApi.listNamespacedPersistentVolumeClaim(namespace)];
6549
+ case 2:
6550
+ res = _a.sent();
6551
+ return [2 /*return*/, res.body.items];
6552
+ }
6553
+ });
6554
+ }); };
6555
+ exports.getProjectPvcs = getProjectPvcs;
6556
+ var getProjectPodNames = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
6557
+ var pods;
6558
+ return __generator(this, function (_a) {
6559
+ switch (_a.label) {
6560
+ case 0: return [4 /*yield*/, (0, exports.getProjectPods)(envComponent)];
6561
+ case 1:
6562
+ pods = _a.sent();
6563
+ return [2 /*return*/, pods.map(function (n) { return n.metadata.name; })];
6564
+ }
6565
+ });
6566
+ }); };
6567
+ exports.getProjectPodNames = getProjectPodNames;
6568
+ //# sourceMappingURL=index.js.map
6569
+
6570
+ /***/ }),
6571
+
6572
+ /***/ 71628:
6573
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6574
+
6575
+ "use strict";
6576
+
6577
+ exports.__esModule = true;
6578
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
6579
+ var ownPkg = __nccwpck_require__(4147);
6580
+ exports["default"] = ownPkg;
6581
+ //# sourceMappingURL=packageInfos.js.map
6582
+
6583
+ /***/ }),
6584
+
6585
+ /***/ 66894:
6119
6586
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
6120
6587
 
6121
6588
  "use strict";
@@ -6515,8 +6982,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6515
6982
  };
6516
6983
  exports.__esModule = true;
6517
6984
  exports.upsertAllVariables = exports.getVariableValueByRawName = exports.getAllVariables = exports.getProjectInfo = exports.doGitlabRequest = exports.getGitlabToken = exports.setupGitlabToken = exports.hasGitlabToken = void 0;
6518
- var child_process_promise_1 = __nccwpck_require__(75763);
6519
6985
  var pipeline_1 = __nccwpck_require__(25355);
6986
+ var child_process_promise_1 = __nccwpck_require__(75763);
6520
6987
  var lodash_1 = __nccwpck_require__(23255);
6521
6988
  var memoizee_1 = __importDefault(__nccwpck_require__(85839));
6522
6989
  var node_fetch_1 = __importDefault(__nccwpck_require__(26372));
@@ -349224,7 +349691,7 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
349224
349691
  };
349225
349692
 
349226
349693
  exports.__esModule = true;
349227
- exports.createDockerBuildJobDefault = exports.createDockerBuildJobBase = exports.DOCKER_BUILD_JOB_NAME = exports.getDockerBuildVariables = exports.requiresDockerBuild = exports.getDockerImageVariables = void 0;
349694
+ exports.createDockerBuildJobDefault = exports.gitlabDockerLogin = exports.createDockerBuildJobBase = exports.getDockerJobBaseProps = exports.DOCKER_BUILD_JOB_NAME = exports.getDockerBuildVariables = exports.requiresDockerBuild = exports.getDockerImageVariables = void 0;
349228
349695
 
349229
349696
  var lodash_1 = __nccwpck_require__(23255);
349230
349697
 
@@ -349259,6 +349726,10 @@ var requiresDockerBuild = function (context) {
349259
349726
  return true;
349260
349727
  }
349261
349728
 
349729
+ if ((0, deploy_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
349730
+ return true;
349731
+ }
349732
+
349262
349733
  if ((0, deploy_1.isOfDeployType)(deployConfig, "custom") && deployConfig.requiresDocker) {
349263
349734
  return true;
349264
349735
  }
@@ -349286,33 +349757,41 @@ var getDockerBuildVariables = function (context) {
349286
349757
  exports.getDockerBuildVariables = getDockerBuildVariables;
349287
349758
  exports.DOCKER_BUILD_JOB_NAME = "🔨 docker";
349288
349759
 
349289
- var createDockerBuildJobBase = function (context, _a) {
349290
- var script = _a.script,
349291
- variables = _a.variables,
349292
- def = __rest(_a, ["script", "variables"]);
349293
-
349294
- return (0, lodash_1.merge)({
349295
- name: exports.DOCKER_BUILD_JOB_NAME,
349296
- envMode: "jobPerEnv",
349297
- stage: "build",
349760
+ var getDockerJobBaseProps = function (context) {
349761
+ return {
349298
349762
  image: (0, runner_1.getRunnerImage)("docker-build"),
349299
349763
  services: [{
349300
349764
  name: "docker:20-dind",
349301
349765
  command: ["--tls=false"]
349302
349766
  }],
349303
- variables: __assign(__assign({}, (0, exports.getDockerBuildVariables)(context)), variables !== null && variables !== void 0 ? variables : {}),
349767
+ variables: (0, exports.getDockerBuildVariables)(context)
349768
+ };
349769
+ };
349770
+
349771
+ exports.getDockerJobBaseProps = getDockerJobBaseProps;
349772
+
349773
+ var createDockerBuildJobBase = function (context, _a) {
349774
+ var script = _a.script,
349775
+ def = __rest(_a, ["script"]);
349776
+
349777
+ return (0, lodash_1.merge)(__assign(__assign({
349778
+ name: exports.DOCKER_BUILD_JOB_NAME,
349779
+ envMode: "jobPerEnv",
349780
+ stage: "build"
349781
+ }, (0, exports.getDockerJobBaseProps)(context)), {
349304
349782
  script: script || []
349305
- }, def);
349783
+ }), def);
349306
349784
  };
349307
349785
 
349308
349786
  exports.createDockerBuildJobBase = createDockerBuildJobBase;
349787
+ exports.gitlabDockerLogin = "docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY";
349309
349788
 
349310
349789
  var createDockerBuildJobDefault = function (context, _a) {
349311
349790
  var script = _a.script,
349312
349791
  def = __rest(_a, ["script"]);
349313
349792
 
349314
349793
  return (0, exports.createDockerBuildJobBase)(context, __assign({
349315
- script: __spreadArray(__spreadArray([], __read(script || []), false), ["docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY", "docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", "docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE", "docker push $DOCKER_CACHE_IMAGE"], false)
349794
+ script: __spreadArray(__spreadArray([], __read(script || []), false), [exports.gitlabDockerLogin, "docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", "docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE", "docker push $DOCKER_CACHE_IMAGE"], false)
349316
349795
  }, def));
349317
349796
  };
349318
349797
 
@@ -350213,11 +350692,67 @@ exports.readConfigSync = readConfigSync;
350213
350692
 
350214
350693
  exports.__esModule = true;
350215
350694
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
350216
- exports.PIPELINE_IMAGE_TAG = "main-b9978361" || 0;
350695
+ exports.PIPELINE_IMAGE_TAG = "main-24bccda4" || 0;
350217
350696
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
350218
350697
 
350219
350698
  /***/ }),
350220
350699
 
350700
+ /***/ 30486:
350701
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
350702
+
350703
+ "use strict";
350704
+
350705
+
350706
+ var __assign = this && this.__assign || function () {
350707
+ __assign = Object.assign || function (t) {
350708
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
350709
+ s = arguments[i];
350710
+
350711
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
350712
+ }
350713
+
350714
+ return t;
350715
+ };
350716
+
350717
+ return __assign.apply(this, arguments);
350718
+ };
350719
+
350720
+ var __importDefault = this && this.__importDefault || function (mod) {
350721
+ return mod && mod.__esModule ? mod : {
350722
+ "default": mod
350723
+ };
350724
+ };
350725
+
350726
+ exports.__esModule = true;
350727
+ exports.getLabels = void 0;
350728
+
350729
+ var slugify_1 = __importDefault(__nccwpck_require__(44035));
350730
+
350731
+ var sanitize = function (value) {
350732
+ if (!value) return value; //"The value can only contain lowercase letters, numeric characters, underscores and dashes. The value can be at most 63 characters long. International characters are allowed."
350733
+ // slugify should do the job
350734
+
350735
+ return (0, slugify_1["default"])(value).toLowerCase();
350736
+ };
350737
+
350738
+ var getLabels = function (context) {
350739
+ var _a, _b, _c;
350740
+
350741
+ var labels = __assign({
350742
+ "customer-name": sanitize(context.fullConfig.customerName),
350743
+ "app-name": sanitize(context.fullConfig.appName),
350744
+ "env-type": sanitize(context.environment.envType),
350745
+ "env-name": sanitize(context.environment.shortName),
350746
+ "build-type": sanitize((_a = context.componentConfig.build) === null || _a === void 0 ? void 0 : _a.type)
350747
+ }, (_c = (_b = context.fullConfig.meta) === null || _b === void 0 ? void 0 : _b.labels) !== null && _c !== void 0 ? _c : {});
350748
+
350749
+ return labels;
350750
+ };
350751
+
350752
+ exports.getLabels = getLabels;
350753
+
350754
+ /***/ }),
350755
+
350221
350756
  /***/ 22041:
350222
350757
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
350223
350758
 
@@ -350431,6 +350966,8 @@ var build_1 = __nccwpck_require__(73760);
350431
350966
 
350432
350967
  var deploy_1 = __nccwpck_require__(90223);
350433
350968
 
350969
+ var types_1 = __nccwpck_require__(63109);
350970
+
350434
350971
  var config_1 = __nccwpck_require__(19997);
350435
350972
 
350436
350973
  var utils_1 = __nccwpck_require__(37461);
@@ -350517,7 +351054,7 @@ var getEnvironment = function (config, componentName, env, commitInfo, alreadyVi
350517
351054
  envInUrl = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, ".").concat(env) : env;
350518
351055
  domainCanonical = (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy) && (mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.deploy.type) === "kubernetes" && ((_e = mergedConfig.deploy.cluster) === null || _e === void 0 ? void 0 : _e.domainCanonical) || // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
350519
351056
  config.domainCanonical || "panter.cloud";
350520
- HOST_CANONICAL = "".concat(componentSlug, ".").concat(envInUrl, ".").concat(config.appName, ".").concat(config.customerName, ".").concat(domainCanonical);
351057
+ HOST_CANONICAL = (0, types_1.isOfDeployType)(mergedConfig.deploy, "kubernetes") ? "".concat(componentSlug, ".").concat(envInUrl, ".").concat(config.appName, ".").concat(config.customerName, ".").concat(domainCanonical) : (0, types_1.isOfDeployType)(mergedConfig.deploy, "google-cloudrun") ? environmentSlug + "-" + process.env[(0, exports.getSecretVarName)(env, componentName, deploy_1.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)] : "";
350521
351058
  host = (_f = mergedConfig === null || mergedConfig === void 0 ? void 0 : mergedConfig.host) !== null && _f !== void 0 ? _f : HOST_CANONICAL;
350522
351059
  url_1 = "https://".concat(host);
350523
351060
  KUBE_APP_NAME_PREFIX = envType === "review" && commitInfo ? "".concat(commitInfo.reviewSlug, "-") : "";
@@ -351158,6 +351695,169 @@ exports.getBaseRollbackJob = getBaseRollbackJob;
351158
351695
 
351159
351696
  /***/ }),
351160
351697
 
351698
+ /***/ 82256:
351699
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
351700
+
351701
+ "use strict";
351702
+
351703
+
351704
+ var __read = this && this.__read || function (o, n) {
351705
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
351706
+ if (!m) return o;
351707
+ var i = m.call(o),
351708
+ r,
351709
+ ar = [],
351710
+ e;
351711
+
351712
+ try {
351713
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
351714
+ } catch (error) {
351715
+ e = {
351716
+ error: error
351717
+ };
351718
+ } finally {
351719
+ try {
351720
+ if (r && !r.done && (m = i["return"])) m.call(i);
351721
+ } finally {
351722
+ if (e) throw e.error;
351723
+ }
351724
+ }
351725
+
351726
+ return ar;
351727
+ };
351728
+
351729
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
351730
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
351731
+ if (ar || !(i in from)) {
351732
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
351733
+ ar[i] = from[i];
351734
+ }
351735
+ }
351736
+ return to.concat(ar || Array.prototype.slice.call(from));
351737
+ };
351738
+
351739
+ exports.__esModule = true;
351740
+ exports.createDeployJob = void 0;
351741
+
351742
+ var js_yaml_1 = __nccwpck_require__(3618);
351743
+
351744
+ var lodash_1 = __nccwpck_require__(23255);
351745
+
351746
+ var _1 = __nccwpck_require__(81344);
351747
+
351748
+ var docker_1 = __nccwpck_require__(33219);
351749
+
351750
+ var getLabels_1 = __nccwpck_require__(30486);
351751
+
351752
+ var runner_1 = __nccwpck_require__(55071);
351753
+
351754
+ var base_1 = __nccwpck_require__(89177);
351755
+
351756
+ var types_1 = __nccwpck_require__(63109);
351757
+
351758
+ var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(22607);
351759
+
351760
+ var createDeployJob = function (context) {
351761
+ var deployConfig = context.componentConfig.deploy;
351762
+
351763
+ if (deployConfig === false) {
351764
+ return [];
351765
+ }
351766
+
351767
+ if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
351768
+ // should not happen
351769
+ throw new Error("deploy config is not custom");
351770
+ }
351771
+
351772
+ var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
351773
+ var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
351774
+ var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
351775
+ var gcloudImageName = "".concat(dockerUrl, "/$DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG");
351776
+
351777
+ var pushImageToArtifactsRegistry = __spreadArray(__spreadArray([docker_1.gitlabDockerLogin], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), ["gcloud auth configure-docker ".concat(deployConfig.region, "-docker.pkg.dev"), "docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG ".concat(gcloudImageName), "docker push ".concat(gcloudImageName)], false);
351778
+
351779
+ var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
351780
+ var serviceName = context.environment.slug;
351781
+ var labelsString = Object.entries((0, getLabels_1.getLabels)(context)).map(function (_a) {
351782
+ var _b = __read(_a, 2),
351783
+ key = _b[0],
351784
+ value = _b[1];
351785
+
351786
+ return "".concat(key, "=").concat(value);
351787
+ }).join(",");
351788
+ var command = context.componentConfig.build.startCommand ? "--command=\"".concat(context.componentConfig.build.startCommand.split(" ").join(","), "\"") : ""; // TODO: split secrets out
351789
+
351790
+ var cloudRunDeploy = ["echo \"$ENV_VARS\" > ____envvars.yaml", "gcloud run deploy ".concat(serviceName, " --image ").concat(gcloudImageName, " --region=").concat(deployConfig.region, " --allow-unauthenticated --project ").concat(deployConfig.projectId, " ").concat(command, " --env-vars-file=____envvars.yaml --labels ").concat(labelsString), "docker image rm ".concat(gcloudImageName)];
351791
+ var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
351792
+ return [(0, lodash_1.merge)({}, baseDeploymentJob, (0, docker_1.getDockerJobBaseProps)(context), {
351793
+ artifacts: {
351794
+ paths: ["____envvars.yaml"]
351795
+ },
351796
+ variables: {
351797
+ ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
351798
+ lineWidth: -1,
351799
+ quotingType: "'",
351800
+ forceQuotes: true
351801
+ })
351802
+ },
351803
+ image: (0, runner_1.getRunnerImage)("gcloud"),
351804
+ script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeploy), false)
351805
+ }), (0, lodash_1.merge)({}, baseStopJob, {
351806
+ image: (0, runner_1.getRunnerImage)("gcloud"),
351807
+ script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), ["gcloud run services delete ".concat(serviceName, " --project ").concat(deployConfig.projectId, " --region=").concat(deployConfig.region, " --quiet")], false)
351808
+ })];
351809
+ };
351810
+
351811
+ exports.createDeployJob = createDeployJob;
351812
+
351813
+ /***/ }),
351814
+
351815
+ /***/ 81344:
351816
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
351817
+
351818
+ "use strict";
351819
+
351820
+
351821
+ exports.__esModule = true;
351822
+ exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
351823
+
351824
+ var deployJob_1 = __nccwpck_require__(82256);
351825
+
351826
+ exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
351827
+ exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
351828
+ exports.GCLOUD_RUN_DEPLOY_TYPE = {
351829
+ jobs: deployJob_1.createDeployJob,
351830
+ defaults: function () {
351831
+ return {};
351832
+ },
351833
+ additionalSecretKeys: function () {
351834
+ return [exports.GCLOUD_DEPLOY_CREDENTIALS_KEY];
351835
+ }
351836
+ };
351837
+
351838
+ /***/ }),
351839
+
351840
+ /***/ 22607:
351841
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
351842
+
351843
+ "use strict";
351844
+
351845
+
351846
+ exports.__esModule = true;
351847
+ exports.gcloudServiceAccountLoginCommands = void 0;
351848
+
351849
+ var __1 = __nccwpck_require__(81344);
351850
+
351851
+ var context_1 = __nccwpck_require__(22041);
351852
+
351853
+ var gcloudServiceAccountLoginCommands = function (context) {
351854
+ return ["echo $".concat((0, context_1.getSecretVarNameForContext)(context, __1.GCLOUD_DEPLOY_CREDENTIALS_KEY), " > ./____keyfile.json\n "), "gcloud auth activate-service-account --key-file=\"./____keyfile.json\""];
351855
+ };
351856
+
351857
+ exports.gcloudServiceAccountLoginCommands = gcloudServiceAccountLoginCommands;
351858
+
351859
+ /***/ }),
351860
+
351161
351861
  /***/ 13539:
351162
351862
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
351163
351863
 
@@ -351167,7 +351867,7 @@ exports.getBaseRollbackJob = getBaseRollbackJob;
351167
351867
  exports.__esModule = true;
351168
351868
  exports.getCloudSQLConfig = exports.hasCloudSQL = void 0;
351169
351869
 
351170
- var types_1 = __nccwpck_require__(49702);
351870
+ var types_1 = __nccwpck_require__(63109);
351171
351871
 
351172
351872
  var hasCloudSQL = function (context) {
351173
351873
  var _a, _b;
@@ -351247,7 +351947,7 @@ var yarn_1 = __nccwpck_require__(10464);
351247
351947
 
351248
351948
  var base_1 = __nccwpck_require__(89177);
351249
351949
 
351250
- var types_1 = __nccwpck_require__(49702);
351950
+ var types_1 = __nccwpck_require__(63109);
351251
351951
 
351252
351952
  var createCustomDeployJobs = function (context) {
351253
351953
  var deployConfig = context.componentConfig.deploy;
@@ -351322,21 +352022,26 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
351322
352022
  exports.__esModule = true;
351323
352023
  exports.DEPLOY_TYPES = void 0;
351324
352024
 
352025
+ var cloudRun_1 = __nccwpck_require__(81344);
352026
+
351325
352027
  var custom_1 = __nccwpck_require__(75599);
351326
352028
 
351327
352029
  var kubernetes_1 = __nccwpck_require__(95682);
351328
352030
 
351329
352031
  __exportStar(__nccwpck_require__(95682), exports);
351330
352032
 
351331
- __exportStar(__nccwpck_require__(49702), exports);
352033
+ __exportStar(__nccwpck_require__(63109), exports);
351332
352034
 
351333
352035
  __exportStar(__nccwpck_require__(92757), exports);
351334
352036
 
351335
352037
  __exportStar(__nccwpck_require__(13539), exports);
351336
352038
 
352039
+ __exportStar(__nccwpck_require__(81344), exports);
352040
+
351337
352041
  exports.DEPLOY_TYPES = {
351338
352042
  kubernetes: kubernetes_1.KUBERNETES_DEPLOY_TYPE,
351339
- custom: custom_1.CUSTOM_DEPLOY_TYPE
352043
+ custom: custom_1.CUSTOM_DEPLOY_TYPE,
352044
+ "google-cloudrun": cloudRun_1.GCLOUD_RUN_DEPLOY_TYPE
351340
352045
  };
351341
352046
 
351342
352047
  /***/ }),
@@ -351466,7 +352171,7 @@ var runner_1 = __nccwpck_require__(55071);
351466
352171
 
351467
352172
  var base_1 = __nccwpck_require__(89177);
351468
352173
 
351469
- var types_1 = __nccwpck_require__(49702);
352174
+ var types_1 = __nccwpck_require__(63109);
351470
352175
 
351471
352176
  var kubeValues_1 = __nccwpck_require__(1061);
351472
352177
 
@@ -351602,7 +352307,7 @@ var __read = this && this.__read || function (o, n) {
351602
352307
  exports.__esModule = true;
351603
352308
  exports.createKubeEnv = void 0;
351604
352309
 
351605
- var types_1 = __nccwpck_require__(49702);
352310
+ var types_1 = __nccwpck_require__(63109);
351606
352311
 
351607
352312
  var shouldGoIntoSecrets = function (key, value) {
351608
352313
  var _a;
@@ -351677,7 +352382,7 @@ var utils_1 = __nccwpck_require__(37461);
351677
352382
 
351678
352383
  var cloudSql_1 = __nccwpck_require__(13539);
351679
352384
 
351680
- var types_1 = __nccwpck_require__(49702);
352385
+ var types_1 = __nccwpck_require__(63109);
351681
352386
 
351682
352387
  var cloudsql_1 = __nccwpck_require__(395);
351683
352388
 
@@ -351940,15 +352645,58 @@ exports.processSecretsAsFiles = processSecretsAsFiles;
351940
352645
 
351941
352646
  /***/ }),
351942
352647
 
351943
- /***/ 49702:
352648
+ /***/ 20438:
352649
+ /***/ ((__unused_webpack_module, exports) => {
352650
+
352651
+ "use strict";
352652
+
352653
+
352654
+ exports.__esModule = true;
352655
+
352656
+ /***/ }),
352657
+
352658
+ /***/ 22689:
351944
352659
  /***/ ((__unused_webpack_module, exports) => {
351945
352660
 
351946
352661
  "use strict";
351947
352662
 
351948
352663
 
352664
+ exports.__esModule = true;
352665
+
352666
+ /***/ }),
352667
+
352668
+ /***/ 63109:
352669
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
352670
+
352671
+ "use strict";
352672
+
352673
+
352674
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
352675
+ if (k2 === undefined) k2 = k;
352676
+ Object.defineProperty(o, k2, {
352677
+ enumerable: true,
352678
+ get: function () {
352679
+ return m[k];
352680
+ }
352681
+ });
352682
+ } : function (o, m, k, k2) {
352683
+ if (k2 === undefined) k2 = k;
352684
+ o[k2] = m[k];
352685
+ });
352686
+
352687
+ var __exportStar = this && this.__exportStar || function (m, exports) {
352688
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
352689
+ };
352690
+
351949
352691
  exports.__esModule = true;
351950
352692
  exports.isOfDeployType = void 0;
351951
352693
 
352694
+ __exportStar(__nccwpck_require__(20438), exports);
352695
+
352696
+ __exportStar(__nccwpck_require__(22689), exports);
352697
+
352698
+ __exportStar(__nccwpck_require__(15299), exports);
352699
+
351952
352700
  var isOfDeployType = function (t) {
351953
352701
  var types = [];
351954
352702
 
@@ -351963,6 +352711,16 @@ exports.isOfDeployType = isOfDeployType;
351963
352711
 
351964
352712
  /***/ }),
351965
352713
 
352714
+ /***/ 15299:
352715
+ /***/ ((__unused_webpack_module, exports) => {
352716
+
352717
+ "use strict";
352718
+
352719
+
352720
+ exports.__esModule = true;
352721
+
352722
+ /***/ }),
352723
+
351966
352724
  /***/ 92757:
351967
352725
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
351968
352726
 
@@ -351972,7 +352730,7 @@ exports.isOfDeployType = isOfDeployType;
351972
352730
  exports.__esModule = true;
351973
352731
  exports.contextIsStoppable = exports.getKubernetesNamespace = exports.getFullKubernetesClusterName = void 0;
351974
352732
 
351975
- var types_1 = __nccwpck_require__(49702);
352733
+ var types_1 = __nccwpck_require__(63109);
351976
352734
 
351977
352735
  var getFullKubernetesClusterName = function (cluster) {
351978
352736
  if (cluster.type === "gcloud") {
@@ -351995,6 +352753,10 @@ var contextIsStoppable = function (context) {
351995
352753
  return true;
351996
352754
  }
351997
352755
 
352756
+ if ((0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
352757
+ return true;
352758
+ }
352759
+
351998
352760
  if ((0, types_1.isOfDeployType)(deployConfig, "custom") && deployConfig.stopScript) {
351999
352761
  return true;
352000
352762
  }