@catladder/pipeline 1.115.0 → 1.117.0
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/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/deploy/cloudRun/artifactsRegistry.d.ts +19 -0
- package/dist/deploy/cloudRun/artifactsRegistry.js +117 -0
- package/dist/deploy/cloudRun/cleanup.d.ts +2 -0
- package/dist/deploy/cloudRun/cleanup.js +51 -0
- package/dist/deploy/cloudRun/cloudRunRevisions.d.ts +2 -0
- package/dist/deploy/cloudRun/cloudRunRevisions.js +61 -0
- package/dist/deploy/cloudRun/deployJob.js +13 -14
- package/dist/deploy/cloudRun/utils/getServiceName.d.ts +2 -0
- package/dist/deploy/cloudRun/utils/getServiceName.js +8 -0
- package/dist/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.d.ts +9 -0
- package/dist/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.js +16 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +46 -8
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +46 -8
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +46 -8
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +92 -16
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +92 -16
- package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +46 -8
- package/examples/__snapshots__/custom-build-job.ts.snap +46 -8
- package/examples/__snapshots__/custom-sbom-java.ts.snap +46 -8
- package/examples/__snapshots__/native-app.ts.snap +46 -8
- package/examples/__snapshots__/node-build-with-custom-image.ts.snap +46 -8
- package/package.json +1 -1
- package/src/deploy/cloudRun/artifactsRegistry.ts +119 -0
- package/src/deploy/cloudRun/cleanup.ts +30 -0
- package/src/deploy/cloudRun/cloudRunRevisions.ts +67 -0
- package/src/deploy/cloudRun/deployJob.ts +46 -44
- package/src/deploy/cloudRun/utils/getServiceName.ts +3 -0
- package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +12 -0
package/dist/constants.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
5
|
-
exports.PIPELINE_IMAGE_TAG = "v1-
|
|
5
|
+
exports.PIPELINE_IMAGE_TAG = "v1-117-0-ebc7e430" || "";
|
|
6
6
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Context } from "../../types/context";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* 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
|
|
5
|
+
*/
|
|
6
|
+
export declare const getArtifactsRegistryImageName: (context: Context, lecacyReviewImageName?: boolean) => string;
|
|
7
|
+
export declare const getArtifactsRegistryImage: (context: Context) => string;
|
|
8
|
+
/**
|
|
9
|
+
* 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
|
|
10
|
+
*/
|
|
11
|
+
export declare const getPushToArtifactsRegistryCommands: (context: Context) => string[];
|
|
12
|
+
/**
|
|
13
|
+
* commands to delete unused images.
|
|
14
|
+
*
|
|
15
|
+
* @param context
|
|
16
|
+
* @param keep how many of the newest images to keep
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare const getDeleteUnusedImagesCommands: (context: Context, keep?: number) => string[];
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __read = this && this.__read || function (o, n) {
|
|
4
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
+
if (!m) return o;
|
|
6
|
+
var i = m.call(o),
|
|
7
|
+
r,
|
|
8
|
+
ar = [],
|
|
9
|
+
e;
|
|
10
|
+
try {
|
|
11
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
e = {
|
|
14
|
+
error: error
|
|
15
|
+
};
|
|
16
|
+
} finally {
|
|
17
|
+
try {
|
|
18
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
19
|
+
} finally {
|
|
20
|
+
if (e) throw e.error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
26
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
+
if (ar || !(i in from)) {
|
|
28
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
+
ar[i] = from[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
+
};
|
|
34
|
+
exports.__esModule = true;
|
|
35
|
+
exports.getDeleteUnusedImagesCommands = exports.getPushToArtifactsRegistryCommands = exports.getArtifactsRegistryImage = exports.getArtifactsRegistryImageName = void 0;
|
|
36
|
+
var docker_1 = require("../../build/docker");
|
|
37
|
+
var gitlab_1 = require("../../utils/gitlab");
|
|
38
|
+
var types_1 = require("../types");
|
|
39
|
+
var removeFirstLinesFromCommandOutput_1 = require("./utils/removeFirstLinesFromCommandOutput");
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* 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
|
|
43
|
+
*/
|
|
44
|
+
var getArtifactsRegistryImageName = function (context, lecacyReviewImageName) {
|
|
45
|
+
var _a;
|
|
46
|
+
if (lecacyReviewImageName === void 0) {
|
|
47
|
+
lecacyReviewImageName = false;
|
|
48
|
+
}
|
|
49
|
+
var deployConfig = context.componentConfig.deploy;
|
|
50
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
51
|
+
// should not happen
|
|
52
|
+
throw new Error("deploy config is wrong");
|
|
53
|
+
}
|
|
54
|
+
if (lecacyReviewImageName && context.environment.envType !== "review") {
|
|
55
|
+
throw new Error("lecacyReviewImageName is only allowed for review app");
|
|
56
|
+
}
|
|
57
|
+
var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
|
|
58
|
+
var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
|
|
59
|
+
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);
|
|
60
|
+
return gcloudImagePath.join("/");
|
|
61
|
+
};
|
|
62
|
+
exports.getArtifactsRegistryImageName = getArtifactsRegistryImageName;
|
|
63
|
+
var getArtifactsRegistryImage = function (context) {
|
|
64
|
+
return "".concat((0, exports.getArtifactsRegistryImageName)(context), ":$DOCKER_IMAGE_TAG");
|
|
65
|
+
};
|
|
66
|
+
exports.getArtifactsRegistryImage = getArtifactsRegistryImage;
|
|
67
|
+
/**
|
|
68
|
+
* 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
|
|
69
|
+
*/
|
|
70
|
+
var getPushToArtifactsRegistryCommands = function (context) {
|
|
71
|
+
var deployConfig = context.componentConfig.deploy;
|
|
72
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
73
|
+
// should not happen
|
|
74
|
+
throw new Error("deploy config is wrong");
|
|
75
|
+
}
|
|
76
|
+
var fullImageName = (0, exports.getArtifactsRegistryImageName)(context);
|
|
77
|
+
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")];
|
|
78
|
+
};
|
|
79
|
+
exports.getPushToArtifactsRegistryCommands = getPushToArtifactsRegistryCommands;
|
|
80
|
+
var getDeleteImageCommands = function (fullImageName, keepNewest) {
|
|
81
|
+
if (keepNewest === void 0) {
|
|
82
|
+
keepNewest = 0;
|
|
83
|
+
}
|
|
84
|
+
if (keepNewest === 0) {
|
|
85
|
+
// no need to list tags, we delete the whole thing
|
|
86
|
+
return ["gcloud artifacts docker images delete ".concat(fullImageName, " --quiet --delete-tags")];
|
|
87
|
+
}
|
|
88
|
+
// delete unused tags
|
|
89
|
+
var listAllImagesCommand = "gcloud artifacts docker images list ".concat(fullImageName, " --sort-by=~CREATE_TIME --format=\"value(version)\"");
|
|
90
|
+
var listImagesToDeletecommand = (0, removeFirstLinesFromCommandOutput_1.removeFirstLinesFromCommandOutput)(listAllImagesCommand, keepNewest);
|
|
91
|
+
var deleteImageCommand = "gcloud artifacts docker images delete ".concat(fullImageName, "@$version --quiet --delete-tags");
|
|
92
|
+
var deleteImagesCommand = "".concat(listImagesToDeletecommand, " | while read -r version; do ").concat(deleteImageCommand, "; done");
|
|
93
|
+
return [deleteImagesCommand];
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* commands to delete unused images.
|
|
97
|
+
*
|
|
98
|
+
* @param context
|
|
99
|
+
* @param keep how many of the newest images to keep
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
var getDeleteUnusedImagesCommands = function (context, keep) {
|
|
103
|
+
if (keep === void 0) {
|
|
104
|
+
keep = 0;
|
|
105
|
+
}
|
|
106
|
+
var deployConfig = context.componentConfig.deploy;
|
|
107
|
+
if (deployConfig === false) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
111
|
+
// should not happen
|
|
112
|
+
throw new Error("deploy config is wrong");
|
|
113
|
+
}
|
|
114
|
+
var fullImageName = (0, exports.getArtifactsRegistryImageName)(context);
|
|
115
|
+
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);
|
|
116
|
+
};
|
|
117
|
+
exports.getDeleteUnusedImagesCommands = getDeleteUnusedImagesCommands;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __read = this && this.__read || function (o, n) {
|
|
4
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
+
if (!m) return o;
|
|
6
|
+
var i = m.call(o),
|
|
7
|
+
r,
|
|
8
|
+
ar = [],
|
|
9
|
+
e;
|
|
10
|
+
try {
|
|
11
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
e = {
|
|
14
|
+
error: error
|
|
15
|
+
};
|
|
16
|
+
} finally {
|
|
17
|
+
try {
|
|
18
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
19
|
+
} finally {
|
|
20
|
+
if (e) throw e.error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
26
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
+
if (ar || !(i in from)) {
|
|
28
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
+
ar[i] = from[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
+
};
|
|
34
|
+
exports.__esModule = true;
|
|
35
|
+
exports.getRemoveOldRevisionsAndImagesCommand = void 0;
|
|
36
|
+
var artifactsRegistry_1 = require("./artifactsRegistry");
|
|
37
|
+
var cloudRunRevisions_1 = require("./cloudRunRevisions");
|
|
38
|
+
var getRemoveOldRevisionsAndImagesCommand = function (context, when) {
|
|
39
|
+
if (when === "onStop") {
|
|
40
|
+
// service is already deleted, so we don't need to delete old revisions, just delete all images
|
|
41
|
+
return (0, artifactsRegistry_1.getDeleteUnusedImagesCommands)(context);
|
|
42
|
+
}
|
|
43
|
+
// this number only targets inactive revisions
|
|
44
|
+
var revisionsToKeep = context.environment.envType === "prod" ? 5 : 0;
|
|
45
|
+
// this number needs to be higher than inactive after deploy, so we add one
|
|
46
|
+
var imagesToKeep = revisionsToKeep + 1;
|
|
47
|
+
var deleteOldRevisionsCommands = (0, cloudRunRevisions_1.getDeleteUnusedRevisionsCommands)(context, revisionsToKeep);
|
|
48
|
+
var deleteOldImagesCommands = (0, artifactsRegistry_1.getDeleteUnusedImagesCommands)(context, imagesToKeep);
|
|
49
|
+
return __spreadArray(__spreadArray([], __read(deleteOldRevisionsCommands), false), __read(deleteOldImagesCommands), false);
|
|
50
|
+
};
|
|
51
|
+
exports.getRemoveOldRevisionsAndImagesCommand = getRemoveOldRevisionsAndImagesCommand;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
exports.__esModule = true;
|
|
14
|
+
exports.getDeleteUnusedRevisionsCommands = void 0;
|
|
15
|
+
var types_1 = require("../types");
|
|
16
|
+
var createArgsString_1 = require("./utils/createArgsString");
|
|
17
|
+
var getServiceName_1 = require("./utils/getServiceName");
|
|
18
|
+
var removeFirstLinesFromCommandOutput_1 = require("./utils/removeFirstLinesFromCommandOutput");
|
|
19
|
+
var getListRevisionsCommand = function (context, args) {
|
|
20
|
+
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
21
|
+
var deployConfig = context.componentConfig.deploy;
|
|
22
|
+
if (!deployConfig || !(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
23
|
+
// should not happen
|
|
24
|
+
throw new Error("deploy config is wrong");
|
|
25
|
+
}
|
|
26
|
+
var filterRevisionArgs = __assign({
|
|
27
|
+
project: deployConfig.projectId,
|
|
28
|
+
region: deployConfig.region,
|
|
29
|
+
// only show inactive revisions
|
|
30
|
+
service: serviceName,
|
|
31
|
+
limit: "unlimited",
|
|
32
|
+
"sort-by": "metadata.creationTimestamp"
|
|
33
|
+
}, args);
|
|
34
|
+
// this prints out all inactive images of the given app
|
|
35
|
+
return "gcloud run revisions list ".concat((0, createArgsString_1.createArgsString)(filterRevisionArgs));
|
|
36
|
+
};
|
|
37
|
+
var getDeleteUnusedRevisionsCommands = function (context, keep) {
|
|
38
|
+
var deployConfig = context.componentConfig.deploy;
|
|
39
|
+
if (deployConfig === false) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
43
|
+
// should not happen
|
|
44
|
+
throw new Error("deploy config is wrong");
|
|
45
|
+
}
|
|
46
|
+
// this prints out all inactive images of the given app
|
|
47
|
+
var listAllInactiveRevisionsCmd = getListRevisionsCommand(context, {
|
|
48
|
+
format: "\"value(name)\"",
|
|
49
|
+
filter: "'(status.conditions.status=False OR status.conditions.status=Unknown)'"
|
|
50
|
+
});
|
|
51
|
+
// this removes the newest `revisionsToKeep` images
|
|
52
|
+
var listRevisionsToDeleteCmd = (0, removeFirstLinesFromCommandOutput_1.removeFirstLinesFromCommandOutput)(listAllInactiveRevisionsCmd, keep);
|
|
53
|
+
var deleteRevisionCmd = "gcloud run revisions delete ".concat((0, createArgsString_1.createArgsString)({
|
|
54
|
+
project: deployConfig.projectId,
|
|
55
|
+
region: deployConfig.region,
|
|
56
|
+
quiet: true
|
|
57
|
+
}), " $revisionname ");
|
|
58
|
+
var deleteRevisionsCmd = "".concat(listRevisionsToDeleteCmd, " | while read -r revisionname; do ").concat(deleteRevisionCmd, "; done");
|
|
59
|
+
return [deleteRevisionsCmd];
|
|
60
|
+
};
|
|
61
|
+
exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
|
|
@@ -57,11 +57,14 @@ var createArgsString_1 = require("./utils/createArgsString");
|
|
|
57
57
|
var database_1 = require("./utils/database");
|
|
58
58
|
var gcloudServiceAccountLoginCommands_1 = require("./utils/gcloudServiceAccountLoginCommands");
|
|
59
59
|
var jobName_1 = require("./utils/jobName");
|
|
60
|
+
var artifactsRegistry_1 = require("./artifactsRegistry");
|
|
61
|
+
var getServiceName_1 = require("./utils/getServiceName");
|
|
62
|
+
var cleanup_1 = require("./cleanup");
|
|
60
63
|
var setExtraVarsScripts = function (deployConfig) {
|
|
61
64
|
return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
|
|
62
65
|
};
|
|
63
66
|
var createGoogleCloudRunDeployJobs = function (context) {
|
|
64
|
-
var _a, _b, _c
|
|
67
|
+
var _a, _b, _c;
|
|
65
68
|
var deployConfig = context.componentConfig.deploy;
|
|
66
69
|
if (deployConfig === false) {
|
|
67
70
|
return [];
|
|
@@ -70,11 +73,6 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
70
73
|
// should not happen
|
|
71
74
|
throw new Error("deploy config is wrong");
|
|
72
75
|
}
|
|
73
|
-
var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
|
|
74
|
-
var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
|
|
75
|
-
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);
|
|
76
|
-
var gcloudImageName = "".concat(gcloudImagePath.join("/"), ":$DOCKER_IMAGE_TAG");
|
|
77
|
-
var pushImageToArtifactsRegistry = (0, gitlab_1.collapseableSection)("pushToArtifactRegistry", "pushing image to artifacts registry")([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)]);
|
|
78
76
|
var allEnvVars = (0, lodash_1.omit)(context.environment.envVars, _1.GCLOUD_DEPLOY_CREDENTIALS_KEY);
|
|
79
77
|
var labelsString = Object.entries((0, getLabels_1.getLabels)(context)).map(function (_a) {
|
|
80
78
|
var _b = __read(_a, 2),
|
|
@@ -87,16 +85,16 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
87
85
|
region: deployConfig.region
|
|
88
86
|
};
|
|
89
87
|
var commonDeployArgs = __assign(__assign({
|
|
90
|
-
image:
|
|
88
|
+
image: (0, artifactsRegistry_1.getArtifactsRegistryImage)(context)
|
|
91
89
|
}, commonArgs), {
|
|
92
90
|
"set-cloudsql-instances": deployConfig.cloudSql ? deployConfig.cloudSql.instanceConnectionName : undefined,
|
|
93
91
|
labels: labelsString
|
|
94
92
|
});
|
|
95
|
-
var serviceName =
|
|
93
|
+
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
96
94
|
var getFullJobName = function (name) {
|
|
97
95
|
return (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
|
|
98
96
|
};
|
|
99
|
-
var jobsWithNames = Object.entries((
|
|
97
|
+
var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
|
|
100
98
|
// filter out disabled jobs
|
|
101
99
|
.filter(function (entry) {
|
|
102
100
|
return Boolean(entry[1]);
|
|
@@ -208,18 +206,19 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
208
206
|
"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)];
|
|
209
207
|
});
|
|
210
208
|
};
|
|
211
|
-
var deployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(
|
|
212
|
-
: []), false), __read(getCreateScheduleScripts()), false), __read(getJobCreateScripts()), false), __read(getJobRunScripts("preDeploy")), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(Object.entries((
|
|
209
|
+
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
|
|
210
|
+
: []), 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) {
|
|
213
211
|
var _b = __read(_a, 2),
|
|
214
212
|
name = _b[0],
|
|
215
213
|
service = _b[1];
|
|
216
214
|
return getServiceDeployScript(service, "-" + name);
|
|
217
|
-
})), false), __read(getJobRunScripts("postDeploy")), false),
|
|
218
|
-
|
|
215
|
+
})), 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
|
|
216
|
+
)), false), __read((0, sbom_1.getDependencyTrackUploadScript)(context)), false);
|
|
217
|
+
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) {
|
|
219
218
|
var _b = __read(_a, 1),
|
|
220
219
|
name = _b[0];
|
|
221
220
|
return "gcloud run services delete ".concat(serviceName, "-").concat(name, " ").concat(commonArgsString);
|
|
222
|
-
})), 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);
|
|
221
|
+
})), 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);
|
|
223
222
|
return (0, base_1.createDeployementJobs)(context, {
|
|
224
223
|
deploy: (0, lodash_1.merge)((0, docker_1.getDockerJobBaseProps)(context), {
|
|
225
224
|
artifacts: {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* takes a command and removes the first keep lines from the output
|
|
4
|
+
*
|
|
5
|
+
* @param cmd the command, its stdout is then limited
|
|
6
|
+
* @param removeFirstN how many lines to remove at the start of the command
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare const removeFirstLinesFromCommandOutput: (cmd: string, removeFirstN: number) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.removeFirstLinesFromCommandOutput = void 0;
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* takes a command and removes the first keep lines from the output
|
|
8
|
+
*
|
|
9
|
+
* @param cmd the command, its stdout is then limited
|
|
10
|
+
* @param removeFirstN how many lines to remove at the start of the command
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
var removeFirstLinesFromCommandOutput = function (cmd, removeFirstN) {
|
|
14
|
+
return removeFirstN === 0 ? cmd : "".concat(cmd, " | tail -n +").concat(removeFirstN + 1);
|
|
15
|
+
};
|
|
16
|
+
exports.removeFirstLinesFromCommandOutput = removeFirstLinesFromCommandOutput;
|