@catladder/pipeline 1.54.0 → 1.55.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 +3 -3
- package/dist/constants.js +1 -1
- package/dist/deploy/cloudRun/deployJob.js +61 -24
- package/dist/deploy/cloudRun/index.d.ts +1 -6
- package/dist/deploy/cloudRun/index.js +51 -31
- package/dist/deploy/index.js +4 -17
- package/dist/deploy/types/googleCloudRun.d.ts +27 -23
- package/dist/deploy/types/index.d.ts +2 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/deploy/cloudRun/deployJob.ts +75 -24
- package/src/deploy/cloudRun/index.ts +12 -23
- package/src/deploy/index.ts +2 -2
- package/src/deploy/types/googleCloudRun.ts +25 -23
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-55-0-40141b86" || "";
|
|
6
6
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
|
|
@@ -57,13 +57,15 @@ var types_1 = require("../types");
|
|
|
57
57
|
var gcloudServiceAccountLoginCommands_1 = require("./utils/gcloudServiceAccountLoginCommands");
|
|
58
58
|
|
|
59
59
|
var createGoogleCloudRunDeployJobs = function (context) {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
|
|
60
62
|
var deployConfig = context.componentConfig.deploy;
|
|
61
63
|
|
|
62
64
|
if (deployConfig === false) {
|
|
63
65
|
return [];
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun"
|
|
68
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
67
69
|
// should not happen
|
|
68
70
|
throw new Error("deploy config is wrong");
|
|
69
71
|
}
|
|
@@ -84,44 +86,76 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
84
86
|
return "".concat(key, "=").concat(value);
|
|
85
87
|
}).join(",");
|
|
86
88
|
var commonArgs = "--project ".concat(deployConfig.projectId, " --region=").concat(deployConfig.region);
|
|
89
|
+
var commonDeployArgs = "--image ".concat(gcloudImageName, " ").concat(commonArgs, " --labels ").concat(labelsString);
|
|
90
|
+
var serviceName = context.environment.fullName.toLowerCase();
|
|
87
91
|
|
|
88
|
-
var
|
|
92
|
+
var getServiceDeployScript = function (service) {
|
|
89
93
|
var _a;
|
|
90
94
|
|
|
91
|
-
var
|
|
92
|
-
var command = (_a = deployConfig.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand;
|
|
95
|
+
var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
|
|
93
96
|
var commandArg = command ? "--command=\"".concat(command.split(" ").join(","), "\"") : "";
|
|
94
|
-
|
|
97
|
+
return "gcloud run deploy ".concat(serviceName, " ").concat(commandArg, " ").concat(commonDeployArgs, " --env-vars-file=____envvars.yaml --allow-unauthenticated");
|
|
98
|
+
};
|
|
95
99
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
var getJobDeployScripts = function (jobName, job) {
|
|
101
|
+
// due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
|
|
102
|
+
// lucky, update on the other hand accepts it... so let's just imediatly update it
|
|
103
|
+
// also we cannot upsert a job, so we have to create it and catch the error and then update
|
|
104
|
+
var args = "".concat(jobName, " --command=\"").concat(job.command.split(" ").join(","), "\" ").concat(commonDeployArgs);
|
|
105
|
+
return ["set +e", "gcloud beta run jobs create ".concat(args), "set -e", "gcloud beta run jobs update ".concat(args, " --env-vars-file=____envvars.yaml")];
|
|
106
|
+
};
|
|
99
107
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
108
|
+
var getJobRunScript = function (jobName) {
|
|
109
|
+
return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgs);
|
|
103
110
|
};
|
|
104
111
|
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
var getFullJobName = function (name) {
|
|
113
|
+
return context.environment.fullName.toLowerCase() + "-" + name;
|
|
114
|
+
};
|
|
108
115
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
var jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
|
|
117
|
+
var _b = __read(_a, 2),
|
|
118
|
+
name = _b[0],
|
|
119
|
+
job = _b[1];
|
|
112
120
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
return [getFullJobName(name), job];
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
var cloudRunDeployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml"], __read(jobsWithNames.map(function (_a) {
|
|
125
|
+
var _b = __read(_a, 2),
|
|
126
|
+
name = _b[0],
|
|
127
|
+
job = _b[1];
|
|
128
|
+
|
|
129
|
+
return getJobDeployScripts(name, job);
|
|
130
|
+
}).flat()), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(jobsWithNames.filter(function (_a) {
|
|
131
|
+
var _b = __read(_a, 2),
|
|
132
|
+
name = _b[0],
|
|
133
|
+
job = _b[1];
|
|
134
|
+
|
|
135
|
+
return job.when === "postDeploy";
|
|
136
|
+
}).map(function (_a) {
|
|
137
|
+
var _b = __read(_a, 2),
|
|
138
|
+
name = _b[0],
|
|
139
|
+
job = _b[1];
|
|
140
|
+
|
|
141
|
+
return getJobRunScript(name);
|
|
142
|
+
})), false), ["docker image rm ".concat(gcloudImageName)], false);
|
|
143
|
+
|
|
144
|
+
var cloudRunStopScripts = __spreadArray(__spreadArray([], __read(deployConfig.service !== false ? ["gcloud run services delete ".concat(serviceName)] : []), false), __read(Object.entries((_b = deployConfig.jobs) !== null && _b !== void 0 ? _b : {}).map(function (_a) {
|
|
145
|
+
var _b = __read(_a, 2),
|
|
146
|
+
jobName = _b[0],
|
|
147
|
+
job = _b[1];
|
|
148
|
+
|
|
149
|
+
return "gcloud beta run jobs delete ".concat(jobName);
|
|
150
|
+
})), false);
|
|
117
151
|
|
|
118
|
-
var cloudRunDeploy = ["echo \"$ENV_VARS\" > ____envvars.yaml", getDeployCommand(), "docker image rm ".concat(gcloudImageName)];
|
|
119
152
|
var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
|
|
120
153
|
return [(0, lodash_1.merge)({}, baseDeploymentJob, (0, docker_1.getDockerJobBaseProps)(context), {
|
|
121
154
|
artifacts: {
|
|
122
155
|
paths: ["____envvars.yaml"]
|
|
123
156
|
},
|
|
124
157
|
variables: {
|
|
158
|
+
CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
|
|
125
159
|
ENV_VARS: (0, js_yaml_1.dump)(allEnvVars, {
|
|
126
160
|
lineWidth: -1,
|
|
127
161
|
quotingType: "'",
|
|
@@ -129,10 +163,13 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
129
163
|
})
|
|
130
164
|
},
|
|
131
165
|
image: (0, runner_1.getRunnerImage)("gcloud"),
|
|
132
|
-
script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(
|
|
166
|
+
script: __spreadArray(__spreadArray([], __read(pushImageToArtifactsRegistry), false), __read(cloudRunDeployScripts), false)
|
|
133
167
|
}), (0, lodash_1.merge)({}, baseStopJob, {
|
|
134
168
|
image: (0, runner_1.getRunnerImage)("gcloud"),
|
|
135
|
-
|
|
169
|
+
variables: {
|
|
170
|
+
CLOUDSDK_CORE_DISABLE_PROMPTS: "1"
|
|
171
|
+
},
|
|
172
|
+
script: __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(cloudRunStopScripts), false)
|
|
136
173
|
})];
|
|
137
174
|
};
|
|
138
175
|
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { DeployTypeDefinition } from "..";
|
|
2
2
|
export declare const GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
|
|
3
3
|
export declare const GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
|
|
4
|
-
export declare const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun">;
|
|
5
|
-
export declare const GCLOUD_RUN_JOB_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun-job">;
|
|
6
|
-
export declare const GCLOUD_RUN_DEPLOY_TYPES: {
|
|
7
|
-
"google-cloudrun": DeployTypeDefinition<"google-cloudrun">;
|
|
8
|
-
"google-cloudrun-job": DeployTypeDefinition<"google-cloudrun-job">;
|
|
9
|
-
};
|
|
4
|
+
export declare const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun">;
|
|
@@ -1,7 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
+
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var __read = this && this.__read || function (o, n) {
|
|
18
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
+
if (!m) return o;
|
|
20
|
+
var i = m.call(o),
|
|
21
|
+
r,
|
|
22
|
+
ar = [],
|
|
23
|
+
e;
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
e = {
|
|
29
|
+
error: error
|
|
30
|
+
};
|
|
31
|
+
} finally {
|
|
32
|
+
try {
|
|
33
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
34
|
+
} finally {
|
|
35
|
+
if (e) throw e.error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return ar;
|
|
40
|
+
};
|
|
41
|
+
|
|
3
42
|
exports.__esModule = true;
|
|
4
|
-
exports.
|
|
43
|
+
exports.GCLOUD_RUN_DEPLOY_TYPE = exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = void 0;
|
|
5
44
|
|
|
6
45
|
var context_1 = require("../../context");
|
|
7
46
|
|
|
@@ -20,37 +59,18 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
|
|
|
20
59
|
getAdditionalEnvVars: function (_a) {
|
|
21
60
|
var fullName = _a.fullName,
|
|
22
61
|
env = _a.env,
|
|
23
|
-
componentName = _a.componentName
|
|
62
|
+
componentName = _a.componentName,
|
|
63
|
+
deployConfig = _a.deployConfig;
|
|
24
64
|
var HOST_CANONICAL = fullName.toLowerCase() + "-" + process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
exports.GCLOUD_RUN_JOB_DEPLOY_TYPE = {
|
|
31
|
-
jobs: deployJob_1.createGoogleCloudRunDeployJobs,
|
|
32
|
-
defaults: function () {
|
|
33
|
-
return {};
|
|
34
|
-
},
|
|
35
|
-
additionalSecretKeys: function () {
|
|
36
|
-
return [exports.GCLOUD_DEPLOY_CREDENTIALS_KEY];
|
|
37
|
-
},
|
|
38
|
-
getAdditionalEnvVars: function (_a) {
|
|
39
|
-
var deployConfig = _a.deployConfig,
|
|
40
|
-
fullName = _a.fullName;
|
|
41
|
-
|
|
42
|
-
if (!deployConfig) {
|
|
43
|
-
return {};
|
|
44
|
-
}
|
|
65
|
+
var jobTriggers = deployConfig && deployConfig.jobs ? Object.fromEntries(Object.entries(deployConfig.jobs).map(function (_a) {
|
|
66
|
+
var _b = __read(_a, 2),
|
|
67
|
+
name = _b[0],
|
|
68
|
+
job = _b[1];
|
|
45
69
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
|
|
50
|
-
};
|
|
70
|
+
return ["CLOUD_RUN_JOB_TRIGGER_URL_" + name, "https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(name, ":run")];
|
|
71
|
+
})) : {};
|
|
72
|
+
return __assign({
|
|
73
|
+
HOST_CANONICAL: HOST_CANONICAL
|
|
74
|
+
}, jobTriggers);
|
|
51
75
|
}
|
|
52
|
-
};
|
|
53
|
-
exports.GCLOUD_RUN_DEPLOY_TYPES = {
|
|
54
|
-
"google-cloudrun": exports.GCLOUD_RUN_DEPLOY_TYPE,
|
|
55
|
-
"google-cloudrun-job": exports.GCLOUD_RUN_JOB_DEPLOY_TYPE
|
|
56
76
|
};
|
package/dist/deploy/index.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
-
|
|
8
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
3
|
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
18
4
|
if (k2 === undefined) k2 = k;
|
|
19
5
|
Object.defineProperty(o, k2, {
|
|
@@ -52,8 +38,9 @@ __exportStar(require("./cloudSql"), exports);
|
|
|
52
38
|
|
|
53
39
|
__exportStar(require("./cloudRun"), exports);
|
|
54
40
|
|
|
55
|
-
exports.DEPLOY_TYPES =
|
|
41
|
+
exports.DEPLOY_TYPES = {
|
|
56
42
|
kubernetes: kubernetes_1.KUBERNETES_DEPLOY_TYPE,
|
|
57
43
|
custom: custom_1.CUSTOM_DEPLOY_TYPE,
|
|
58
|
-
dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE
|
|
59
|
-
|
|
44
|
+
dockerTag: dockerTag_1.DOCKER_TAG_DEPLOY_TYPE,
|
|
45
|
+
"google-cloudrun": cloudRun_1.GCLOUD_RUN_DEPLOY_TYPE
|
|
46
|
+
};
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import type { DeployConfigBase } from "./base";
|
|
2
2
|
export declare type Gcloudregion = "asia-east1" | "asia-northeast1" | "asia-northeast2" | "europe-north1" | "europe-southwest1" | "europe-west1" | "europe-west4" | "europe-west8" | "europe-west9" | "me-west1" | "us-central1" | "us-east1" | "us-east4" | "us-east5" | "us-south1" | "us-west1" | "asia-east2" | "asia-northeast3" | "asia-southeast1" | "asia-southeast2" | "asia-south1" | "asia-south2" | "australia-southeast1" | "australia-southeast2" | "europe-central2" | "europe-west2" | "europe-west3" | "europe-west6" | "northamerica-northeast1" | "northamerica-northeast2" | "southamerica-east1" | "southamerica-west1" | "us-west2" | "us-west3" | "us-west4";
|
|
3
|
-
export declare type
|
|
4
|
-
/**
|
|
5
|
-
* the google cloud porject id
|
|
6
|
-
*/
|
|
7
|
-
projectId: string;
|
|
8
|
-
/**
|
|
9
|
-
* the region. Set to europe-west6 for switzerland
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
region: Gcloudregion;
|
|
3
|
+
export declare type DeployConfigCloudRunService = {
|
|
13
4
|
/**
|
|
14
5
|
* command / entrypoint, fallsback to buildConfig.startcommand
|
|
15
6
|
*/
|
|
16
|
-
|
|
17
7
|
command?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare type
|
|
8
|
+
};
|
|
9
|
+
export declare type DeployConfigCloudRunJob = {
|
|
10
|
+
/**
|
|
11
|
+
* command
|
|
12
|
+
*/
|
|
13
|
+
command: string;
|
|
14
|
+
when: "manual" | "postDeploy";
|
|
15
|
+
};
|
|
16
|
+
export declare type DeployConfigCloudRun = {
|
|
20
17
|
/**
|
|
21
18
|
* EXPERIMENTAL cloud run deployment.
|
|
22
19
|
*
|
|
@@ -25,15 +22,22 @@ export declare type DeployConfigCloudRunService = {
|
|
|
25
22
|
* Requires that cloud run is enabled on the project, as well as cloud run api and artifacts registry.
|
|
26
23
|
*/
|
|
27
24
|
type: "google-cloudrun";
|
|
28
|
-
} & DeployConfigCloudRunBase;
|
|
29
|
-
export declare type DeployConfigCloudRunJob = {
|
|
30
25
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* This will deploy a cloud run job. This does not do much currently, but will be later used for cronjobs
|
|
34
|
-
*
|
|
35
|
-
* Requires that cloud run is enabled on the project, as well as cloud run api and artifacts registry.
|
|
26
|
+
* the google cloud porject id
|
|
36
27
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
|
|
29
|
+
projectId: string;
|
|
30
|
+
/**
|
|
31
|
+
* the region. Set to europe-west6 for switzerland
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
region: Gcloudregion;
|
|
35
|
+
/**
|
|
36
|
+
* whether to enable the service, defaults to true
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
service?: boolean | DeployConfigCloudRunService;
|
|
40
|
+
jobs?: {
|
|
41
|
+
[name: string]: DeployConfigCloudRunJob;
|
|
42
|
+
};
|
|
43
|
+
} & DeployConfigBase;
|
|
@@ -11,13 +11,11 @@ export declare type DeployConfigType = DeployConfig["type"];
|
|
|
11
11
|
export declare type DeployConfigGeneric<T extends DeployConfigType> = Extract<DeployConfig, {
|
|
12
12
|
type: T;
|
|
13
13
|
}>;
|
|
14
|
-
export declare const isOfDeployType: <T extends ("custom" | "dockerTag" | "google-cloudrun" | "
|
|
14
|
+
export declare const isOfDeployType: <T extends ("custom" | "dockerTag" | "google-cloudrun" | "kubernetes")[]>(t: DeployConfig | false, ...types: T) => t is Extract<DeployConfigCustom, {
|
|
15
15
|
type: T[number];
|
|
16
16
|
}> | Extract<DeployConfigDockerTag, {
|
|
17
17
|
type: T[number];
|
|
18
|
-
}> | Extract<
|
|
19
|
-
type: T[number];
|
|
20
|
-
}> | Extract<import("./googleCloudRun").DeployConfigCloudRunJob, {
|
|
18
|
+
}> | Extract<DeployConfigCloudRun, {
|
|
21
19
|
type: T[number];
|
|
22
20
|
}> | Extract<DeployConfigKubernetes, {
|
|
23
21
|
type: T[number];
|