@catladder/cli 0.0.0-main-deeb54d7 → 0.0.0-main-30854c6a
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.
- package/dist/bundles/catenv/index.js +302 -15
- package/dist/bundles/cli/index.js +302 -15
- package/package.json +2 -2
|
@@ -40865,7 +40865,7 @@ exports.readConfigSync = readConfigSync;
|
|
|
40865
40865
|
|
|
40866
40866
|
exports.__esModule = true;
|
|
40867
40867
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
40868
|
-
exports.PIPELINE_IMAGE_TAG = "main-
|
|
40868
|
+
exports.PIPELINE_IMAGE_TAG = "main-30854c6a" || 0;
|
|
40869
40869
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
|
|
40870
40870
|
|
|
40871
40871
|
/***/ }),
|
|
@@ -42391,6 +42391,256 @@ exports.DEPLOY_RUNNER_VARIABLES = {
|
|
|
42391
42391
|
|
|
42392
42392
|
/***/ }),
|
|
42393
42393
|
|
|
42394
|
+
/***/ 8159:
|
|
42395
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
42396
|
+
|
|
42397
|
+
"use strict";
|
|
42398
|
+
|
|
42399
|
+
|
|
42400
|
+
var __read = this && this.__read || function (o, n) {
|
|
42401
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
42402
|
+
if (!m) return o;
|
|
42403
|
+
var i = m.call(o),
|
|
42404
|
+
r,
|
|
42405
|
+
ar = [],
|
|
42406
|
+
e;
|
|
42407
|
+
try {
|
|
42408
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
42409
|
+
} catch (error) {
|
|
42410
|
+
e = {
|
|
42411
|
+
error: error
|
|
42412
|
+
};
|
|
42413
|
+
} finally {
|
|
42414
|
+
try {
|
|
42415
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
42416
|
+
} finally {
|
|
42417
|
+
if (e) throw e.error;
|
|
42418
|
+
}
|
|
42419
|
+
}
|
|
42420
|
+
return ar;
|
|
42421
|
+
};
|
|
42422
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
42423
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
42424
|
+
if (ar || !(i in from)) {
|
|
42425
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42426
|
+
ar[i] = from[i];
|
|
42427
|
+
}
|
|
42428
|
+
}
|
|
42429
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
42430
|
+
};
|
|
42431
|
+
exports.__esModule = true;
|
|
42432
|
+
exports.getDeleteUnusedImagesCommands = exports.getPushToArtifactsRegistryCommands = exports.getArtifactsRegistryImage = exports.getArtifactsRegistryImageName = void 0;
|
|
42433
|
+
var docker_1 = __nccwpck_require__(3219);
|
|
42434
|
+
var gitlab_1 = __nccwpck_require__(4997);
|
|
42435
|
+
var types_1 = __nccwpck_require__(3109);
|
|
42436
|
+
var removeFirstLinesFromCommandOutput_1 = __nccwpck_require__(7547);
|
|
42437
|
+
/**
|
|
42438
|
+
*
|
|
42439
|
+
* lecacyReviewImageName is only temporary. In old versions the images had no reviewslug in review apps, which makes cleanup harder. We delete all those images now, but need the path
|
|
42440
|
+
*/
|
|
42441
|
+
var getArtifactsRegistryImageName = function (context, lecacyReviewImageName) {
|
|
42442
|
+
var _a;
|
|
42443
|
+
if (lecacyReviewImageName === void 0) {
|
|
42444
|
+
lecacyReviewImageName = false;
|
|
42445
|
+
}
|
|
42446
|
+
var deployConfig = context.componentConfig.deploy;
|
|
42447
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
42448
|
+
// should not happen
|
|
42449
|
+
throw new Error("deploy config is wrong");
|
|
42450
|
+
}
|
|
42451
|
+
if (lecacyReviewImageName && context.environment.envType !== "review") {
|
|
42452
|
+
throw new Error("lecacyReviewImageName is only allowed for review app");
|
|
42453
|
+
}
|
|
42454
|
+
var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
|
|
42455
|
+
var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
|
|
42456
|
+
var gcloudImagePath = __spreadArray([dockerUrl, context.environment.shortName, context.componentName], __read(context.environment.envType === "review" && !lecacyReviewImageName ? [(_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.reviewSlug] : []), false);
|
|
42457
|
+
return gcloudImagePath.join("/");
|
|
42458
|
+
};
|
|
42459
|
+
exports.getArtifactsRegistryImageName = getArtifactsRegistryImageName;
|
|
42460
|
+
var getArtifactsRegistryImage = function (context) {
|
|
42461
|
+
return "".concat((0, exports.getArtifactsRegistryImageName)(context), ":$DOCKER_IMAGE_TAG");
|
|
42462
|
+
};
|
|
42463
|
+
exports.getArtifactsRegistryImage = getArtifactsRegistryImage;
|
|
42464
|
+
/**
|
|
42465
|
+
* commands to pull the image from the default registry and pushes it to google artifact registry. We might build and push directly to google artifact registry in the future
|
|
42466
|
+
*/
|
|
42467
|
+
var getPushToArtifactsRegistryCommands = function (context) {
|
|
42468
|
+
var deployConfig = context.componentConfig.deploy;
|
|
42469
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
42470
|
+
// should not happen
|
|
42471
|
+
throw new Error("deploy config is wrong");
|
|
42472
|
+
}
|
|
42473
|
+
var fullImageName = (0, exports.getArtifactsRegistryImageName)(context);
|
|
42474
|
+
return [docker_1.gitlabDockerLogin, "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(fullImageName, ":$DOCKER_IMAGE_TAG"), "docker push ".concat(fullImageName, ":$DOCKER_IMAGE_TAG")];
|
|
42475
|
+
};
|
|
42476
|
+
exports.getPushToArtifactsRegistryCommands = getPushToArtifactsRegistryCommands;
|
|
42477
|
+
var getDeleteImageCommands = function (fullImageName, keepNewest) {
|
|
42478
|
+
if (keepNewest === void 0) {
|
|
42479
|
+
keepNewest = 0;
|
|
42480
|
+
}
|
|
42481
|
+
if (keepNewest === 0) {
|
|
42482
|
+
// no need to list tags, we delete the whole thing
|
|
42483
|
+
return ["gcloud artifacts docker images delete ".concat(fullImageName, " --quiet --delete-tags")];
|
|
42484
|
+
}
|
|
42485
|
+
// delete unused tags
|
|
42486
|
+
var listAllImagesCommand = "gcloud artifacts docker images list ".concat(fullImageName, " --sort-by=~CREATE_TIME --format=\"value(version)\"");
|
|
42487
|
+
var listImagesToDeletecommand = (0, removeFirstLinesFromCommandOutput_1.removeFirstLinesFromCommandOutput)(listAllImagesCommand, keepNewest);
|
|
42488
|
+
var deleteImageCommand = "gcloud artifacts docker images delete ".concat(fullImageName, "@$version --quiet --delete-tags");
|
|
42489
|
+
var deleteImagesCommand = "".concat(listImagesToDeletecommand, " | while read -r version; do ").concat(deleteImageCommand, "; done");
|
|
42490
|
+
return [deleteImagesCommand];
|
|
42491
|
+
};
|
|
42492
|
+
/**
|
|
42493
|
+
* commands to delete unused images.
|
|
42494
|
+
*
|
|
42495
|
+
* @param context
|
|
42496
|
+
* @param keep how many of the newest images to keep
|
|
42497
|
+
* @returns
|
|
42498
|
+
*/
|
|
42499
|
+
var getDeleteUnusedImagesCommands = function (context, keep) {
|
|
42500
|
+
if (keep === void 0) {
|
|
42501
|
+
keep = 0;
|
|
42502
|
+
}
|
|
42503
|
+
var deployConfig = context.componentConfig.deploy;
|
|
42504
|
+
if (deployConfig === false) {
|
|
42505
|
+
return [];
|
|
42506
|
+
}
|
|
42507
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
42508
|
+
// should not happen
|
|
42509
|
+
throw new Error("deploy config is wrong");
|
|
42510
|
+
}
|
|
42511
|
+
var fullImageName = (0, exports.getArtifactsRegistryImageName)(context);
|
|
42512
|
+
return __spreadArray(__spreadArray([], __read(getDeleteImageCommands(fullImageName, keep)), false), __read(context.environment.envType === "review" ? (0, gitlab_1.allowFailureInScripts)(getDeleteImageCommands((0, exports.getArtifactsRegistryImageName)(context, true), 0)) : []), false);
|
|
42513
|
+
};
|
|
42514
|
+
exports.getDeleteUnusedImagesCommands = getDeleteUnusedImagesCommands;
|
|
42515
|
+
|
|
42516
|
+
/***/ }),
|
|
42517
|
+
|
|
42518
|
+
/***/ 964:
|
|
42519
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
42520
|
+
|
|
42521
|
+
"use strict";
|
|
42522
|
+
|
|
42523
|
+
|
|
42524
|
+
var __read = this && this.__read || function (o, n) {
|
|
42525
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
42526
|
+
if (!m) return o;
|
|
42527
|
+
var i = m.call(o),
|
|
42528
|
+
r,
|
|
42529
|
+
ar = [],
|
|
42530
|
+
e;
|
|
42531
|
+
try {
|
|
42532
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
42533
|
+
} catch (error) {
|
|
42534
|
+
e = {
|
|
42535
|
+
error: error
|
|
42536
|
+
};
|
|
42537
|
+
} finally {
|
|
42538
|
+
try {
|
|
42539
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
42540
|
+
} finally {
|
|
42541
|
+
if (e) throw e.error;
|
|
42542
|
+
}
|
|
42543
|
+
}
|
|
42544
|
+
return ar;
|
|
42545
|
+
};
|
|
42546
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
42547
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
42548
|
+
if (ar || !(i in from)) {
|
|
42549
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42550
|
+
ar[i] = from[i];
|
|
42551
|
+
}
|
|
42552
|
+
}
|
|
42553
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
42554
|
+
};
|
|
42555
|
+
exports.__esModule = true;
|
|
42556
|
+
exports.getRemoveOldRevisionsAndImagesCommand = void 0;
|
|
42557
|
+
var artifactsRegistry_1 = __nccwpck_require__(8159);
|
|
42558
|
+
var cloudRunRevisions_1 = __nccwpck_require__(1101);
|
|
42559
|
+
var getRemoveOldRevisionsAndImagesCommand = function (context, when) {
|
|
42560
|
+
if (when === "onStop") {
|
|
42561
|
+
// service is already deleted, so we don't need to delete old revisions, just delete all images
|
|
42562
|
+
return (0, artifactsRegistry_1.getDeleteUnusedImagesCommands)(context);
|
|
42563
|
+
}
|
|
42564
|
+
// this number only targets inactive revisions
|
|
42565
|
+
var revisionsToKeep = context.environment.envType === "prod" ? 5 : 0;
|
|
42566
|
+
// this number needs to be higher than inactive after deploy, so we add one
|
|
42567
|
+
var imagesToKeep = revisionsToKeep + 1;
|
|
42568
|
+
var deleteOldRevisionsCommands = (0, cloudRunRevisions_1.getDeleteUnusedRevisionsCommands)(context, revisionsToKeep);
|
|
42569
|
+
var deleteOldImagesCommands = (0, artifactsRegistry_1.getDeleteUnusedImagesCommands)(context, imagesToKeep);
|
|
42570
|
+
return __spreadArray(__spreadArray([], __read(deleteOldRevisionsCommands), false), __read(deleteOldImagesCommands), false);
|
|
42571
|
+
};
|
|
42572
|
+
exports.getRemoveOldRevisionsAndImagesCommand = getRemoveOldRevisionsAndImagesCommand;
|
|
42573
|
+
|
|
42574
|
+
/***/ }),
|
|
42575
|
+
|
|
42576
|
+
/***/ 1101:
|
|
42577
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
42578
|
+
|
|
42579
|
+
"use strict";
|
|
42580
|
+
|
|
42581
|
+
|
|
42582
|
+
var __assign = this && this.__assign || function () {
|
|
42583
|
+
__assign = Object.assign || function (t) {
|
|
42584
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
42585
|
+
s = arguments[i];
|
|
42586
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
42587
|
+
}
|
|
42588
|
+
return t;
|
|
42589
|
+
};
|
|
42590
|
+
return __assign.apply(this, arguments);
|
|
42591
|
+
};
|
|
42592
|
+
exports.__esModule = true;
|
|
42593
|
+
exports.getDeleteUnusedRevisionsCommands = void 0;
|
|
42594
|
+
var types_1 = __nccwpck_require__(3109);
|
|
42595
|
+
var createArgsString_1 = __nccwpck_require__(8686);
|
|
42596
|
+
var getServiceName_1 = __nccwpck_require__(9391);
|
|
42597
|
+
var removeFirstLinesFromCommandOutput_1 = __nccwpck_require__(7547);
|
|
42598
|
+
var getListRevisionsCommand = function (context, args) {
|
|
42599
|
+
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
42600
|
+
var deployConfig = context.componentConfig.deploy;
|
|
42601
|
+
if (!deployConfig || !(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
42602
|
+
// should not happen
|
|
42603
|
+
throw new Error("deploy config is wrong");
|
|
42604
|
+
}
|
|
42605
|
+
var filterRevisionArgs = __assign({
|
|
42606
|
+
project: deployConfig.projectId,
|
|
42607
|
+
region: deployConfig.region,
|
|
42608
|
+
// only show inactive revisions
|
|
42609
|
+
service: serviceName,
|
|
42610
|
+
limit: "unlimited",
|
|
42611
|
+
"sort-by": "metadata.creationTimestamp"
|
|
42612
|
+
}, args);
|
|
42613
|
+
// this prints out all inactive images of the given app
|
|
42614
|
+
return "gcloud run revisions list ".concat((0, createArgsString_1.createArgsString)(filterRevisionArgs));
|
|
42615
|
+
};
|
|
42616
|
+
var getDeleteUnusedRevisionsCommands = function (context, keep) {
|
|
42617
|
+
var deployConfig = context.componentConfig.deploy;
|
|
42618
|
+
if (deployConfig === false) {
|
|
42619
|
+
return [];
|
|
42620
|
+
}
|
|
42621
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
42622
|
+
// should not happen
|
|
42623
|
+
throw new Error("deploy config is wrong");
|
|
42624
|
+
}
|
|
42625
|
+
// this prints out all inactive images of the given app
|
|
42626
|
+
var listAllInactiveRevisionsCmd = getListRevisionsCommand(context, {
|
|
42627
|
+
format: "\"value(name)\"",
|
|
42628
|
+
filter: "'(status.conditions.status=False OR status.conditions.status=Unknown)'"
|
|
42629
|
+
});
|
|
42630
|
+
// this removes the newest `revisionsToKeep` images
|
|
42631
|
+
var listRevisionsToDeleteCmd = (0, removeFirstLinesFromCommandOutput_1.removeFirstLinesFromCommandOutput)(listAllInactiveRevisionsCmd, keep);
|
|
42632
|
+
var deleteRevisionCmd = "gcloud run revisions delete ".concat((0, createArgsString_1.createArgsString)({
|
|
42633
|
+
project: deployConfig.projectId,
|
|
42634
|
+
region: deployConfig.region,
|
|
42635
|
+
quiet: true
|
|
42636
|
+
}), " $revisionname ");
|
|
42637
|
+
var deleteRevisionsCmd = "".concat(listRevisionsToDeleteCmd, " | while read -r revisionname; do ").concat(deleteRevisionCmd, "; done");
|
|
42638
|
+
return [deleteRevisionsCmd];
|
|
42639
|
+
};
|
|
42640
|
+
exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
|
|
42641
|
+
|
|
42642
|
+
/***/ }),
|
|
42643
|
+
|
|
42394
42644
|
/***/ 2256:
|
|
42395
42645
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
42396
42646
|
|
|
@@ -42454,11 +42704,14 @@ var createArgsString_1 = __nccwpck_require__(8686);
|
|
|
42454
42704
|
var database_1 = __nccwpck_require__(1384);
|
|
42455
42705
|
var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
|
|
42456
42706
|
var jobName_1 = __nccwpck_require__(7311);
|
|
42707
|
+
var artifactsRegistry_1 = __nccwpck_require__(8159);
|
|
42708
|
+
var getServiceName_1 = __nccwpck_require__(9391);
|
|
42709
|
+
var cleanup_1 = __nccwpck_require__(964);
|
|
42457
42710
|
var setExtraVarsScripts = function (deployConfig) {
|
|
42458
42711
|
return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
|
|
42459
42712
|
};
|
|
42460
42713
|
var createGoogleCloudRunDeployJobs = function (context) {
|
|
42461
|
-
var _a, _b, _c
|
|
42714
|
+
var _a, _b, _c;
|
|
42462
42715
|
var deployConfig = context.componentConfig.deploy;
|
|
42463
42716
|
if (deployConfig === false) {
|
|
42464
42717
|
return [];
|
|
@@ -42467,11 +42720,6 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
42467
42720
|
// should not happen
|
|
42468
42721
|
throw new Error("deploy config is wrong");
|
|
42469
42722
|
}
|
|
42470
|
-
var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
|
|
42471
|
-
var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
|
|
42472
|
-
var gcloudImagePath = __spreadArray([dockerUrl, context.environment.shortName, context.componentName], __read(context.environment.envType === "review" ? [(_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.reviewSlug] : []), false);
|
|
42473
|
-
var gcloudImageName = "".concat(gcloudImagePath.join("/"), ":$DOCKER_IMAGE_TAG");
|
|
42474
|
-
var pushImageToArtifactsRegistry = [docker_1.gitlabDockerLogin, "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)];
|
|
42475
42723
|
var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
|
|
42476
42724
|
var labelsString = Object.entries((0, getLabels_1.getLabels)(context)).map(function (_a) {
|
|
42477
42725
|
var _b = __read(_a, 2),
|
|
@@ -42484,16 +42732,16 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
42484
42732
|
region: deployConfig.region
|
|
42485
42733
|
};
|
|
42486
42734
|
var commonDeployArgs = __assign(__assign({
|
|
42487
|
-
image:
|
|
42735
|
+
image: (0, artifactsRegistry_1.getArtifactsRegistryImage)(context)
|
|
42488
42736
|
}, commonArgs), {
|
|
42489
42737
|
"set-cloudsql-instances": deployConfig.cloudSql ? deployConfig.cloudSql.instanceConnectionName : undefined,
|
|
42490
42738
|
labels: labelsString
|
|
42491
42739
|
});
|
|
42492
|
-
var serviceName =
|
|
42740
|
+
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
42493
42741
|
var getFullJobName = function (name) {
|
|
42494
42742
|
return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
|
|
42495
42743
|
};
|
|
42496
|
-
var jobsWithNames = Object.entries((
|
|
42744
|
+
var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
|
|
42497
42745
|
// filter out disabled jobs
|
|
42498
42746
|
.filter(function (entry) {
|
|
42499
42747
|
return Boolean(entry[1]);
|
|
@@ -42605,18 +42853,19 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
42605
42853
|
"gcloud beta run jobs executions list ".concat(commonArgsString, " --job ").concat(jobName, " --format=\"value(name)\" | xargs -I {} gcloud beta run jobs executions delete {} --quiet ").concat(commonArgsString), "gcloud beta run jobs delete ".concat(jobName, " ").concat(commonArgsString)];
|
|
42606
42854
|
});
|
|
42607
42855
|
};
|
|
42608
|
-
var deployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gitlab_1.collapseableSection)("prepare", "Prepare...")(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(setExtraVarsScripts(deployConfig)), false))), false), __read((0, gitlab_1.collapseableSection)("pushToArtifactRegistry", "Pushing image to artifacts registry")(
|
|
42609
|
-
: []), false), __read(getCreateScheduleScripts()), false), __read(getJobCreateScripts()), false), __read(getJobRunScripts("preDeploy")), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(Object.entries((
|
|
42856
|
+
var deployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gitlab_1.collapseableSection)("prepare", "Prepare...")(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(setExtraVarsScripts(deployConfig)), false))), false), __read((0, gitlab_1.collapseableSection)("pushToArtifactRegistry", "Pushing image to artifacts registry")((0, artifactsRegistry_1.getPushToArtifactsRegistryCommands)(context))), false), __read((0, gitlab_1.collapseableSection)("deploy", "Deploy to cloud run")(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml"], __read(deployConfig.cloudSql ? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
42857
|
+
: []), false), __read(getCreateScheduleScripts()), false), __read(getJobCreateScripts()), false), __read(getJobRunScripts("preDeploy")), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(Object.entries((_b = deployConfig.additionalServices) !== null && _b !== void 0 ? _b : {}).map(function (_a) {
|
|
42610
42858
|
var _b = __read(_a, 2),
|
|
42611
42859
|
name = _b[0],
|
|
42612
42860
|
service = _b[1];
|
|
42613
42861
|
return getServiceDeployScript(service, "-" + name);
|
|
42614
|
-
})), false), __read(getJobRunScripts("postDeploy")), false))), false),
|
|
42615
|
-
|
|
42862
|
+
})), false), __read(getJobRunScripts("postDeploy")), false))), false), __read((0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy") // we cleanup inactive images both on deploy and stop
|
|
42863
|
+
)), false), __read((0, sbom_1.getDependencyTrackUploadScript)(context)), false);
|
|
42864
|
+
var stopScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(deployConfig.service !== false ? ["gcloud run services delete ".concat(serviceName, " ").concat(commonArgsString)] : []), false), __read(Object.entries((_c = deployConfig.additionalServices) !== null && _c !== void 0 ? _c : {}).map(function (_a) {
|
|
42616
42865
|
var _b = __read(_a, 1),
|
|
42617
42866
|
name = _b[0];
|
|
42618
42867
|
return "gcloud run services delete ".concat(serviceName, "-").concat(name, " ").concat(commonArgsString);
|
|
42619
|
-
})), false), __read(getDeleteSchedulesScripts()), false), __read(getDeleteJobsScripts()), false), __read(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig) : []), false), __read((0, sbom_1.getDependencyTrackDeleteScript)(context)), false);
|
|
42868
|
+
})), false), __read(getDeleteSchedulesScripts()), false), __read(getDeleteJobsScripts()), false), __read(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig) : []), false), __read((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "onStop")), false), __read((0, sbom_1.getDependencyTrackDeleteScript)(context)), false);
|
|
42620
42869
|
return (0, base_1.createDeployementJobs)(context, {
|
|
42621
42870
|
deploy: (0, lodash_1.merge)((0, docker_1.getDockerJobBaseProps)(context), {
|
|
42622
42871
|
artifacts: {
|
|
@@ -42924,6 +43173,21 @@ exports.gcloudServiceAccountLoginCommands = gcloudServiceAccountLoginCommands;
|
|
|
42924
43173
|
|
|
42925
43174
|
/***/ }),
|
|
42926
43175
|
|
|
43176
|
+
/***/ 9391:
|
|
43177
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
43178
|
+
|
|
43179
|
+
"use strict";
|
|
43180
|
+
|
|
43181
|
+
|
|
43182
|
+
exports.__esModule = true;
|
|
43183
|
+
exports.getServiceName = void 0;
|
|
43184
|
+
var getServiceName = function (context) {
|
|
43185
|
+
return context.environment.fullName.toLowerCase();
|
|
43186
|
+
};
|
|
43187
|
+
exports.getServiceName = getServiceName;
|
|
43188
|
+
|
|
43189
|
+
/***/ }),
|
|
43190
|
+
|
|
42927
43191
|
/***/ 7311:
|
|
42928
43192
|
/***/ ((__unused_webpack_module, exports) => {
|
|
42929
43193
|
|
|
@@ -42939,6 +43203,29 @@ exports.getCloudRunJobName = getCloudRunJobName;
|
|
|
42939
43203
|
|
|
42940
43204
|
/***/ }),
|
|
42941
43205
|
|
|
43206
|
+
/***/ 7547:
|
|
43207
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
43208
|
+
|
|
43209
|
+
"use strict";
|
|
43210
|
+
|
|
43211
|
+
|
|
43212
|
+
exports.__esModule = true;
|
|
43213
|
+
exports.removeFirstLinesFromCommandOutput = void 0;
|
|
43214
|
+
/**
|
|
43215
|
+
*
|
|
43216
|
+
* takes a command and removes the first keep lines from the output
|
|
43217
|
+
*
|
|
43218
|
+
* @param cmd the command, its stdout is then limited
|
|
43219
|
+
* @param removeFirstN how many lines to remove at the start of the command
|
|
43220
|
+
* @returns
|
|
43221
|
+
*/
|
|
43222
|
+
var removeFirstLinesFromCommandOutput = function (cmd, removeFirstN) {
|
|
43223
|
+
return removeFirstN === 0 ? cmd : "".concat(cmd, " | tail -n +").concat(removeFirstN + 1);
|
|
43224
|
+
};
|
|
43225
|
+
exports.removeFirstLinesFromCommandOutput = removeFirstLinesFromCommandOutput;
|
|
43226
|
+
|
|
43227
|
+
/***/ }),
|
|
43228
|
+
|
|
42942
43229
|
/***/ 463:
|
|
42943
43230
|
/***/ ((__unused_webpack_module, exports) => {
|
|
42944
43231
|
|
|
@@ -354984,7 +354984,7 @@ exports.readConfigSync = readConfigSync;
|
|
|
354984
354984
|
|
|
354985
354985
|
exports.__esModule = true;
|
|
354986
354986
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
354987
|
-
exports.PIPELINE_IMAGE_TAG = "main-
|
|
354987
|
+
exports.PIPELINE_IMAGE_TAG = "main-30854c6a" || 0;
|
|
354988
354988
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
|
|
354989
354989
|
|
|
354990
354990
|
/***/ }),
|
|
@@ -356510,6 +356510,256 @@ exports.DEPLOY_RUNNER_VARIABLES = {
|
|
|
356510
356510
|
|
|
356511
356511
|
/***/ }),
|
|
356512
356512
|
|
|
356513
|
+
/***/ 28159:
|
|
356514
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
356515
|
+
|
|
356516
|
+
"use strict";
|
|
356517
|
+
|
|
356518
|
+
|
|
356519
|
+
var __read = this && this.__read || function (o, n) {
|
|
356520
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
356521
|
+
if (!m) return o;
|
|
356522
|
+
var i = m.call(o),
|
|
356523
|
+
r,
|
|
356524
|
+
ar = [],
|
|
356525
|
+
e;
|
|
356526
|
+
try {
|
|
356527
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
356528
|
+
} catch (error) {
|
|
356529
|
+
e = {
|
|
356530
|
+
error: error
|
|
356531
|
+
};
|
|
356532
|
+
} finally {
|
|
356533
|
+
try {
|
|
356534
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
356535
|
+
} finally {
|
|
356536
|
+
if (e) throw e.error;
|
|
356537
|
+
}
|
|
356538
|
+
}
|
|
356539
|
+
return ar;
|
|
356540
|
+
};
|
|
356541
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
356542
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
356543
|
+
if (ar || !(i in from)) {
|
|
356544
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
356545
|
+
ar[i] = from[i];
|
|
356546
|
+
}
|
|
356547
|
+
}
|
|
356548
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
356549
|
+
};
|
|
356550
|
+
exports.__esModule = true;
|
|
356551
|
+
exports.getDeleteUnusedImagesCommands = exports.getPushToArtifactsRegistryCommands = exports.getArtifactsRegistryImage = exports.getArtifactsRegistryImageName = void 0;
|
|
356552
|
+
var docker_1 = __nccwpck_require__(33219);
|
|
356553
|
+
var gitlab_1 = __nccwpck_require__(84997);
|
|
356554
|
+
var types_1 = __nccwpck_require__(63109);
|
|
356555
|
+
var removeFirstLinesFromCommandOutput_1 = __nccwpck_require__(77547);
|
|
356556
|
+
/**
|
|
356557
|
+
*
|
|
356558
|
+
* lecacyReviewImageName is only temporary. In old versions the images had no reviewslug in review apps, which makes cleanup harder. We delete all those images now, but need the path
|
|
356559
|
+
*/
|
|
356560
|
+
var getArtifactsRegistryImageName = function (context, lecacyReviewImageName) {
|
|
356561
|
+
var _a;
|
|
356562
|
+
if (lecacyReviewImageName === void 0) {
|
|
356563
|
+
lecacyReviewImageName = false;
|
|
356564
|
+
}
|
|
356565
|
+
var deployConfig = context.componentConfig.deploy;
|
|
356566
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
356567
|
+
// should not happen
|
|
356568
|
+
throw new Error("deploy config is wrong");
|
|
356569
|
+
}
|
|
356570
|
+
if (lecacyReviewImageName && context.environment.envType !== "review") {
|
|
356571
|
+
throw new Error("lecacyReviewImageName is only allowed for review app");
|
|
356572
|
+
}
|
|
356573
|
+
var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
|
|
356574
|
+
var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
|
|
356575
|
+
var gcloudImagePath = __spreadArray([dockerUrl, context.environment.shortName, context.componentName], __read(context.environment.envType === "review" && !lecacyReviewImageName ? [(_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.reviewSlug] : []), false);
|
|
356576
|
+
return gcloudImagePath.join("/");
|
|
356577
|
+
};
|
|
356578
|
+
exports.getArtifactsRegistryImageName = getArtifactsRegistryImageName;
|
|
356579
|
+
var getArtifactsRegistryImage = function (context) {
|
|
356580
|
+
return "".concat((0, exports.getArtifactsRegistryImageName)(context), ":$DOCKER_IMAGE_TAG");
|
|
356581
|
+
};
|
|
356582
|
+
exports.getArtifactsRegistryImage = getArtifactsRegistryImage;
|
|
356583
|
+
/**
|
|
356584
|
+
* commands to pull the image from the default registry and pushes it to google artifact registry. We might build and push directly to google artifact registry in the future
|
|
356585
|
+
*/
|
|
356586
|
+
var getPushToArtifactsRegistryCommands = function (context) {
|
|
356587
|
+
var deployConfig = context.componentConfig.deploy;
|
|
356588
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
356589
|
+
// should not happen
|
|
356590
|
+
throw new Error("deploy config is wrong");
|
|
356591
|
+
}
|
|
356592
|
+
var fullImageName = (0, exports.getArtifactsRegistryImageName)(context);
|
|
356593
|
+
return [docker_1.gitlabDockerLogin, "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(fullImageName, ":$DOCKER_IMAGE_TAG"), "docker push ".concat(fullImageName, ":$DOCKER_IMAGE_TAG")];
|
|
356594
|
+
};
|
|
356595
|
+
exports.getPushToArtifactsRegistryCommands = getPushToArtifactsRegistryCommands;
|
|
356596
|
+
var getDeleteImageCommands = function (fullImageName, keepNewest) {
|
|
356597
|
+
if (keepNewest === void 0) {
|
|
356598
|
+
keepNewest = 0;
|
|
356599
|
+
}
|
|
356600
|
+
if (keepNewest === 0) {
|
|
356601
|
+
// no need to list tags, we delete the whole thing
|
|
356602
|
+
return ["gcloud artifacts docker images delete ".concat(fullImageName, " --quiet --delete-tags")];
|
|
356603
|
+
}
|
|
356604
|
+
// delete unused tags
|
|
356605
|
+
var listAllImagesCommand = "gcloud artifacts docker images list ".concat(fullImageName, " --sort-by=~CREATE_TIME --format=\"value(version)\"");
|
|
356606
|
+
var listImagesToDeletecommand = (0, removeFirstLinesFromCommandOutput_1.removeFirstLinesFromCommandOutput)(listAllImagesCommand, keepNewest);
|
|
356607
|
+
var deleteImageCommand = "gcloud artifacts docker images delete ".concat(fullImageName, "@$version --quiet --delete-tags");
|
|
356608
|
+
var deleteImagesCommand = "".concat(listImagesToDeletecommand, " | while read -r version; do ").concat(deleteImageCommand, "; done");
|
|
356609
|
+
return [deleteImagesCommand];
|
|
356610
|
+
};
|
|
356611
|
+
/**
|
|
356612
|
+
* commands to delete unused images.
|
|
356613
|
+
*
|
|
356614
|
+
* @param context
|
|
356615
|
+
* @param keep how many of the newest images to keep
|
|
356616
|
+
* @returns
|
|
356617
|
+
*/
|
|
356618
|
+
var getDeleteUnusedImagesCommands = function (context, keep) {
|
|
356619
|
+
if (keep === void 0) {
|
|
356620
|
+
keep = 0;
|
|
356621
|
+
}
|
|
356622
|
+
var deployConfig = context.componentConfig.deploy;
|
|
356623
|
+
if (deployConfig === false) {
|
|
356624
|
+
return [];
|
|
356625
|
+
}
|
|
356626
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
356627
|
+
// should not happen
|
|
356628
|
+
throw new Error("deploy config is wrong");
|
|
356629
|
+
}
|
|
356630
|
+
var fullImageName = (0, exports.getArtifactsRegistryImageName)(context);
|
|
356631
|
+
return __spreadArray(__spreadArray([], __read(getDeleteImageCommands(fullImageName, keep)), false), __read(context.environment.envType === "review" ? (0, gitlab_1.allowFailureInScripts)(getDeleteImageCommands((0, exports.getArtifactsRegistryImageName)(context, true), 0)) : []), false);
|
|
356632
|
+
};
|
|
356633
|
+
exports.getDeleteUnusedImagesCommands = getDeleteUnusedImagesCommands;
|
|
356634
|
+
|
|
356635
|
+
/***/ }),
|
|
356636
|
+
|
|
356637
|
+
/***/ 10964:
|
|
356638
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
356639
|
+
|
|
356640
|
+
"use strict";
|
|
356641
|
+
|
|
356642
|
+
|
|
356643
|
+
var __read = this && this.__read || function (o, n) {
|
|
356644
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
356645
|
+
if (!m) return o;
|
|
356646
|
+
var i = m.call(o),
|
|
356647
|
+
r,
|
|
356648
|
+
ar = [],
|
|
356649
|
+
e;
|
|
356650
|
+
try {
|
|
356651
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
356652
|
+
} catch (error) {
|
|
356653
|
+
e = {
|
|
356654
|
+
error: error
|
|
356655
|
+
};
|
|
356656
|
+
} finally {
|
|
356657
|
+
try {
|
|
356658
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
356659
|
+
} finally {
|
|
356660
|
+
if (e) throw e.error;
|
|
356661
|
+
}
|
|
356662
|
+
}
|
|
356663
|
+
return ar;
|
|
356664
|
+
};
|
|
356665
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
356666
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
356667
|
+
if (ar || !(i in from)) {
|
|
356668
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
356669
|
+
ar[i] = from[i];
|
|
356670
|
+
}
|
|
356671
|
+
}
|
|
356672
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
356673
|
+
};
|
|
356674
|
+
exports.__esModule = true;
|
|
356675
|
+
exports.getRemoveOldRevisionsAndImagesCommand = void 0;
|
|
356676
|
+
var artifactsRegistry_1 = __nccwpck_require__(28159);
|
|
356677
|
+
var cloudRunRevisions_1 = __nccwpck_require__(31101);
|
|
356678
|
+
var getRemoveOldRevisionsAndImagesCommand = function (context, when) {
|
|
356679
|
+
if (when === "onStop") {
|
|
356680
|
+
// service is already deleted, so we don't need to delete old revisions, just delete all images
|
|
356681
|
+
return (0, artifactsRegistry_1.getDeleteUnusedImagesCommands)(context);
|
|
356682
|
+
}
|
|
356683
|
+
// this number only targets inactive revisions
|
|
356684
|
+
var revisionsToKeep = context.environment.envType === "prod" ? 5 : 0;
|
|
356685
|
+
// this number needs to be higher than inactive after deploy, so we add one
|
|
356686
|
+
var imagesToKeep = revisionsToKeep + 1;
|
|
356687
|
+
var deleteOldRevisionsCommands = (0, cloudRunRevisions_1.getDeleteUnusedRevisionsCommands)(context, revisionsToKeep);
|
|
356688
|
+
var deleteOldImagesCommands = (0, artifactsRegistry_1.getDeleteUnusedImagesCommands)(context, imagesToKeep);
|
|
356689
|
+
return __spreadArray(__spreadArray([], __read(deleteOldRevisionsCommands), false), __read(deleteOldImagesCommands), false);
|
|
356690
|
+
};
|
|
356691
|
+
exports.getRemoveOldRevisionsAndImagesCommand = getRemoveOldRevisionsAndImagesCommand;
|
|
356692
|
+
|
|
356693
|
+
/***/ }),
|
|
356694
|
+
|
|
356695
|
+
/***/ 31101:
|
|
356696
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
356697
|
+
|
|
356698
|
+
"use strict";
|
|
356699
|
+
|
|
356700
|
+
|
|
356701
|
+
var __assign = this && this.__assign || function () {
|
|
356702
|
+
__assign = Object.assign || function (t) {
|
|
356703
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
356704
|
+
s = arguments[i];
|
|
356705
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
356706
|
+
}
|
|
356707
|
+
return t;
|
|
356708
|
+
};
|
|
356709
|
+
return __assign.apply(this, arguments);
|
|
356710
|
+
};
|
|
356711
|
+
exports.__esModule = true;
|
|
356712
|
+
exports.getDeleteUnusedRevisionsCommands = void 0;
|
|
356713
|
+
var types_1 = __nccwpck_require__(63109);
|
|
356714
|
+
var createArgsString_1 = __nccwpck_require__(8686);
|
|
356715
|
+
var getServiceName_1 = __nccwpck_require__(89391);
|
|
356716
|
+
var removeFirstLinesFromCommandOutput_1 = __nccwpck_require__(77547);
|
|
356717
|
+
var getListRevisionsCommand = function (context, args) {
|
|
356718
|
+
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
356719
|
+
var deployConfig = context.componentConfig.deploy;
|
|
356720
|
+
if (!deployConfig || !(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
356721
|
+
// should not happen
|
|
356722
|
+
throw new Error("deploy config is wrong");
|
|
356723
|
+
}
|
|
356724
|
+
var filterRevisionArgs = __assign({
|
|
356725
|
+
project: deployConfig.projectId,
|
|
356726
|
+
region: deployConfig.region,
|
|
356727
|
+
// only show inactive revisions
|
|
356728
|
+
service: serviceName,
|
|
356729
|
+
limit: "unlimited",
|
|
356730
|
+
"sort-by": "metadata.creationTimestamp"
|
|
356731
|
+
}, args);
|
|
356732
|
+
// this prints out all inactive images of the given app
|
|
356733
|
+
return "gcloud run revisions list ".concat((0, createArgsString_1.createArgsString)(filterRevisionArgs));
|
|
356734
|
+
};
|
|
356735
|
+
var getDeleteUnusedRevisionsCommands = function (context, keep) {
|
|
356736
|
+
var deployConfig = context.componentConfig.deploy;
|
|
356737
|
+
if (deployConfig === false) {
|
|
356738
|
+
return [];
|
|
356739
|
+
}
|
|
356740
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
356741
|
+
// should not happen
|
|
356742
|
+
throw new Error("deploy config is wrong");
|
|
356743
|
+
}
|
|
356744
|
+
// this prints out all inactive images of the given app
|
|
356745
|
+
var listAllInactiveRevisionsCmd = getListRevisionsCommand(context, {
|
|
356746
|
+
format: "\"value(name)\"",
|
|
356747
|
+
filter: "'(status.conditions.status=False OR status.conditions.status=Unknown)'"
|
|
356748
|
+
});
|
|
356749
|
+
// this removes the newest `revisionsToKeep` images
|
|
356750
|
+
var listRevisionsToDeleteCmd = (0, removeFirstLinesFromCommandOutput_1.removeFirstLinesFromCommandOutput)(listAllInactiveRevisionsCmd, keep);
|
|
356751
|
+
var deleteRevisionCmd = "gcloud run revisions delete ".concat((0, createArgsString_1.createArgsString)({
|
|
356752
|
+
project: deployConfig.projectId,
|
|
356753
|
+
region: deployConfig.region,
|
|
356754
|
+
quiet: true
|
|
356755
|
+
}), " $revisionname ");
|
|
356756
|
+
var deleteRevisionsCmd = "".concat(listRevisionsToDeleteCmd, " | while read -r revisionname; do ").concat(deleteRevisionCmd, "; done");
|
|
356757
|
+
return [deleteRevisionsCmd];
|
|
356758
|
+
};
|
|
356759
|
+
exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
|
|
356760
|
+
|
|
356761
|
+
/***/ }),
|
|
356762
|
+
|
|
356513
356763
|
/***/ 82256:
|
|
356514
356764
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
356515
356765
|
|
|
@@ -356573,11 +356823,14 @@ var createArgsString_1 = __nccwpck_require__(8686);
|
|
|
356573
356823
|
var database_1 = __nccwpck_require__(41384);
|
|
356574
356824
|
var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(22607);
|
|
356575
356825
|
var jobName_1 = __nccwpck_require__(77311);
|
|
356826
|
+
var artifactsRegistry_1 = __nccwpck_require__(28159);
|
|
356827
|
+
var getServiceName_1 = __nccwpck_require__(89391);
|
|
356828
|
+
var cleanup_1 = __nccwpck_require__(10964);
|
|
356576
356829
|
var setExtraVarsScripts = function (deployConfig) {
|
|
356577
356830
|
return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
|
|
356578
356831
|
};
|
|
356579
356832
|
var createGoogleCloudRunDeployJobs = function (context) {
|
|
356580
|
-
var _a, _b, _c
|
|
356833
|
+
var _a, _b, _c;
|
|
356581
356834
|
var deployConfig = context.componentConfig.deploy;
|
|
356582
356835
|
if (deployConfig === false) {
|
|
356583
356836
|
return [];
|
|
@@ -356586,11 +356839,6 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
356586
356839
|
// should not happen
|
|
356587
356840
|
throw new Error("deploy config is wrong");
|
|
356588
356841
|
}
|
|
356589
|
-
var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
|
|
356590
|
-
var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
|
|
356591
|
-
var gcloudImagePath = __spreadArray([dockerUrl, context.environment.shortName, context.componentName], __read(context.environment.envType === "review" ? [(_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.reviewSlug] : []), false);
|
|
356592
|
-
var gcloudImageName = "".concat(gcloudImagePath.join("/"), ":$DOCKER_IMAGE_TAG");
|
|
356593
|
-
var pushImageToArtifactsRegistry = [docker_1.gitlabDockerLogin, "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)];
|
|
356594
356842
|
var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
|
|
356595
356843
|
var labelsString = Object.entries((0, getLabels_1.getLabels)(context)).map(function (_a) {
|
|
356596
356844
|
var _b = __read(_a, 2),
|
|
@@ -356603,16 +356851,16 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
356603
356851
|
region: deployConfig.region
|
|
356604
356852
|
};
|
|
356605
356853
|
var commonDeployArgs = __assign(__assign({
|
|
356606
|
-
image:
|
|
356854
|
+
image: (0, artifactsRegistry_1.getArtifactsRegistryImage)(context)
|
|
356607
356855
|
}, commonArgs), {
|
|
356608
356856
|
"set-cloudsql-instances": deployConfig.cloudSql ? deployConfig.cloudSql.instanceConnectionName : undefined,
|
|
356609
356857
|
labels: labelsString
|
|
356610
356858
|
});
|
|
356611
|
-
var serviceName =
|
|
356859
|
+
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
356612
356860
|
var getFullJobName = function (name) {
|
|
356613
356861
|
return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
|
|
356614
356862
|
};
|
|
356615
|
-
var jobsWithNames = Object.entries((
|
|
356863
|
+
var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
|
|
356616
356864
|
// filter out disabled jobs
|
|
356617
356865
|
.filter(function (entry) {
|
|
356618
356866
|
return Boolean(entry[1]);
|
|
@@ -356724,18 +356972,19 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
356724
356972
|
"gcloud beta run jobs executions list ".concat(commonArgsString, " --job ").concat(jobName, " --format=\"value(name)\" | xargs -I {} gcloud beta run jobs executions delete {} --quiet ").concat(commonArgsString), "gcloud beta run jobs delete ".concat(jobName, " ").concat(commonArgsString)];
|
|
356725
356973
|
});
|
|
356726
356974
|
};
|
|
356727
|
-
var deployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gitlab_1.collapseableSection)("prepare", "Prepare...")(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(setExtraVarsScripts(deployConfig)), false))), false), __read((0, gitlab_1.collapseableSection)("pushToArtifactRegistry", "Pushing image to artifacts registry")(
|
|
356728
|
-
: []), false), __read(getCreateScheduleScripts()), false), __read(getJobCreateScripts()), false), __read(getJobRunScripts("preDeploy")), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(Object.entries((
|
|
356975
|
+
var deployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gitlab_1.collapseableSection)("prepare", "Prepare...")(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(setExtraVarsScripts(deployConfig)), false))), false), __read((0, gitlab_1.collapseableSection)("pushToArtifactRegistry", "Pushing image to artifacts registry")((0, artifactsRegistry_1.getPushToArtifactsRegistryCommands)(context))), false), __read((0, gitlab_1.collapseableSection)("deploy", "Deploy to cloud run")(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml"], __read(deployConfig.cloudSql ? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
356976
|
+
: []), false), __read(getCreateScheduleScripts()), false), __read(getJobCreateScripts()), false), __read(getJobRunScripts("preDeploy")), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(Object.entries((_b = deployConfig.additionalServices) !== null && _b !== void 0 ? _b : {}).map(function (_a) {
|
|
356729
356977
|
var _b = __read(_a, 2),
|
|
356730
356978
|
name = _b[0],
|
|
356731
356979
|
service = _b[1];
|
|
356732
356980
|
return getServiceDeployScript(service, "-" + name);
|
|
356733
|
-
})), false), __read(getJobRunScripts("postDeploy")), false))), false),
|
|
356734
|
-
|
|
356981
|
+
})), false), __read(getJobRunScripts("postDeploy")), false))), false), __read((0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy") // we cleanup inactive images both on deploy and stop
|
|
356982
|
+
)), false), __read((0, sbom_1.getDependencyTrackUploadScript)(context)), false);
|
|
356983
|
+
var stopScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(deployConfig.service !== false ? ["gcloud run services delete ".concat(serviceName, " ").concat(commonArgsString)] : []), false), __read(Object.entries((_c = deployConfig.additionalServices) !== null && _c !== void 0 ? _c : {}).map(function (_a) {
|
|
356735
356984
|
var _b = __read(_a, 1),
|
|
356736
356985
|
name = _b[0];
|
|
356737
356986
|
return "gcloud run services delete ".concat(serviceName, "-").concat(name, " ").concat(commonArgsString);
|
|
356738
|
-
})), false), __read(getDeleteSchedulesScripts()), false), __read(getDeleteJobsScripts()), false), __read(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig) : []), false), __read((0, sbom_1.getDependencyTrackDeleteScript)(context)), false);
|
|
356987
|
+
})), false), __read(getDeleteSchedulesScripts()), false), __read(getDeleteJobsScripts()), false), __read(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig) : []), false), __read((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "onStop")), false), __read((0, sbom_1.getDependencyTrackDeleteScript)(context)), false);
|
|
356739
356988
|
return (0, base_1.createDeployementJobs)(context, {
|
|
356740
356989
|
deploy: (0, lodash_1.merge)((0, docker_1.getDockerJobBaseProps)(context), {
|
|
356741
356990
|
artifacts: {
|
|
@@ -357043,6 +357292,21 @@ exports.gcloudServiceAccountLoginCommands = gcloudServiceAccountLoginCommands;
|
|
|
357043
357292
|
|
|
357044
357293
|
/***/ }),
|
|
357045
357294
|
|
|
357295
|
+
/***/ 89391:
|
|
357296
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
357297
|
+
|
|
357298
|
+
"use strict";
|
|
357299
|
+
|
|
357300
|
+
|
|
357301
|
+
exports.__esModule = true;
|
|
357302
|
+
exports.getServiceName = void 0;
|
|
357303
|
+
var getServiceName = function (context) {
|
|
357304
|
+
return context.environment.fullName.toLowerCase();
|
|
357305
|
+
};
|
|
357306
|
+
exports.getServiceName = getServiceName;
|
|
357307
|
+
|
|
357308
|
+
/***/ }),
|
|
357309
|
+
|
|
357046
357310
|
/***/ 77311:
|
|
357047
357311
|
/***/ ((__unused_webpack_module, exports) => {
|
|
357048
357312
|
|
|
@@ -357058,6 +357322,29 @@ exports.getCloudRunJobName = getCloudRunJobName;
|
|
|
357058
357322
|
|
|
357059
357323
|
/***/ }),
|
|
357060
357324
|
|
|
357325
|
+
/***/ 77547:
|
|
357326
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
357327
|
+
|
|
357328
|
+
"use strict";
|
|
357329
|
+
|
|
357330
|
+
|
|
357331
|
+
exports.__esModule = true;
|
|
357332
|
+
exports.removeFirstLinesFromCommandOutput = void 0;
|
|
357333
|
+
/**
|
|
357334
|
+
*
|
|
357335
|
+
* takes a command and removes the first keep lines from the output
|
|
357336
|
+
*
|
|
357337
|
+
* @param cmd the command, its stdout is then limited
|
|
357338
|
+
* @param removeFirstN how many lines to remove at the start of the command
|
|
357339
|
+
* @returns
|
|
357340
|
+
*/
|
|
357341
|
+
var removeFirstLinesFromCommandOutput = function (cmd, removeFirstN) {
|
|
357342
|
+
return removeFirstN === 0 ? cmd : "".concat(cmd, " | tail -n +").concat(removeFirstN + 1);
|
|
357343
|
+
};
|
|
357344
|
+
exports.removeFirstLinesFromCommandOutput = removeFirstLinesFromCommandOutput;
|
|
357345
|
+
|
|
357346
|
+
/***/ }),
|
|
357347
|
+
|
|
357061
357348
|
/***/ 70463:
|
|
357062
357349
|
/***/ ((__unused_webpack_module, exports) => {
|
|
357063
357350
|
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"node": ">=12.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@catladder/pipeline": "0.0.0-main-
|
|
27
|
+
"@catladder/pipeline": "0.0.0-main-30854c6a",
|
|
28
28
|
"@kubernetes/client-node": "^0.16.2",
|
|
29
29
|
"@tsconfig/node14": "^1.0.1",
|
|
30
30
|
"@types/common-tags": "^1.8.0",
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
"typescript": "^4.5.4",
|
|
58
58
|
"vorpal": "^1.12.0"
|
|
59
59
|
},
|
|
60
|
-
"version": "0.0.0-main-
|
|
60
|
+
"version": "0.0.0-main-30854c6a",
|
|
61
61
|
"stableVersion": "0.0.0"
|
|
62
62
|
}
|