@catladder/pipeline 0.0.0-refactor-cloud-run-825d7e86 → 0.0.0-refactore-catenv-command-validates-argument-78d05852
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/build/rails/build.js +1 -1
- package/dist/bundles/catladder-gitlab/index.js +53 -33
- package/dist/constants.js +1 -1
- package/dist/context/resolveReferences.js +1 -1
- package/dist/deploy/cloudRun/createJobs/cloudRunJobs.js +10 -9
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +4 -3
- package/dist/deploy/cloudRun/createJobs/common.d.ts +3 -0
- package/dist/deploy/cloudRun/createJobs/common.js +14 -2
- package/dist/deploy/cloudRun/utils/createArgsString.d.ts +3 -1
- package/dist/deploy/cloudRun/utils/createArgsString.js +22 -16
- package/dist/deploy/types/googleCloudRun.d.ts +20 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +5 -5
- package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +1839 -0
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +36 -36
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +4 -0
- package/examples/cloud-run-service-gen2.ts +27 -0
- package/package.json +1 -1
- package/src/build/rails/build.ts +1 -0
- package/src/context/resolveReferences.ts +1 -1
- package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +16 -11
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +6 -2
- package/src/deploy/cloudRun/createJobs/common.ts +14 -1
- package/src/deploy/cloudRun/utils/createArgsString.ts +17 -13
- package/src/deploy/types/googleCloudRun.ts +23 -2
|
@@ -74,7 +74,7 @@ var createRailsBuildJobs = function (context) {
|
|
|
74
74
|
dockerBuild: {
|
|
75
75
|
variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.componentConfig.build.extraVars),
|
|
76
76
|
// custom script
|
|
77
|
-
script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
|
|
77
|
+
script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["cd ".concat(context.componentConfig.dir), "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
|
|
78
78
|
// replace private git ssh gem sources with https to make bundler with credentials via env var work
|
|
79
79
|
"sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs, " ").concat((_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : "")], false)
|
|
80
80
|
}
|
|
@@ -28290,7 +28290,7 @@ var createRailsBuildJobs = function (context) {
|
|
|
28290
28290
|
dockerBuild: {
|
|
28291
28291
|
variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.componentConfig.build.extraVars),
|
|
28292
28292
|
// custom script
|
|
28293
|
-
script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
|
|
28293
|
+
script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["cd ".concat(context.componentConfig.dir), "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
|
|
28294
28294
|
// replace private git ssh gem sources with https to make bundler with credentials via env var work
|
|
28295
28295
|
"sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs, " ").concat((_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : "")], false)
|
|
28296
28296
|
}
|
|
@@ -28740,7 +28740,7 @@ exports.readConfigSync = readConfigSync;
|
|
|
28740
28740
|
|
|
28741
28741
|
exports.__esModule = true;
|
|
28742
28742
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
28743
|
-
exports.PIPELINE_IMAGE_TAG = "
|
|
28743
|
+
exports.PIPELINE_IMAGE_TAG = "refactore-catenv-command-validates-argument-78d05852" || 0;
|
|
28744
28744
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
|
|
28745
28745
|
|
|
28746
28746
|
/***/ }),
|
|
@@ -29650,7 +29650,7 @@ exports.__esModule = true;
|
|
|
29650
29650
|
exports.translateLegacyFromComponents = exports.resolveReferences = void 0;
|
|
29651
29651
|
var lodash_1 = __nccwpck_require__(3255);
|
|
29652
29652
|
var string_replace_async_1 = __importDefault(__nccwpck_require__(4439));
|
|
29653
|
-
var REGEX = /\$\{(([^:]+):)?([^}]+)}/gm;
|
|
29653
|
+
var REGEX = /\$\{(([^:}]+):)?([^}]+)}/gm;
|
|
29654
29654
|
var resolveReferences = function (vars, getOtherVariables, alreadyVisitedBase) {
|
|
29655
29655
|
if (alreadyVisitedBase === void 0) {
|
|
29656
29656
|
alreadyVisitedBase = {};
|
|
@@ -30584,7 +30584,7 @@ var getLabels_1 = __nccwpck_require__(2101);
|
|
|
30584
30584
|
var getJobRunScriptForJob = function (context, jobName, wait) {
|
|
30585
30585
|
var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
30586
30586
|
var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
30587
|
-
return "
|
|
30587
|
+
return "".concat((0, common_1.gcloudRunCmd)(), " jobs execute ").concat(jobName, " ").concat(commonArgsString).concat(wait ? " --wait" : "");
|
|
30588
30588
|
};
|
|
30589
30589
|
var getDeleteSchedulesScripts = function (context) {
|
|
30590
30590
|
var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
@@ -30595,7 +30595,7 @@ var getDeleteSchedulesScripts = function (context) {
|
|
|
30595
30595
|
});
|
|
30596
30596
|
return jobsWithSchedule.map(function (_a) {
|
|
30597
30597
|
var schedulerName = _a.schedulerName;
|
|
30598
|
-
return ["
|
|
30598
|
+
return ["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs delete ").concat(schedulerName, " ").concat(argsString)];
|
|
30599
30599
|
}).flat();
|
|
30600
30600
|
};
|
|
30601
30601
|
exports.getDeleteSchedulesScripts = getDeleteSchedulesScripts;
|
|
@@ -30607,7 +30607,7 @@ var getDeleteJobsScripts = function (context) {
|
|
|
30607
30607
|
var jobName = _a.jobName;
|
|
30608
30608
|
return [
|
|
30609
30609
|
// first delete all job executions. Otherwise delete might fail if one of those is still running
|
|
30610
|
-
"
|
|
30610
|
+
"".concat((0, common_1.gcloudRunCmd)(), " jobs executions list ").concat(commonArgsString, " --job ").concat(jobName, " --format=\"value(name)\" | xargs -I {} ").concat((0, common_1.gcloudRunCmd)(), " jobs executions delete {} --quiet ").concat(commonArgsString), "".concat((0, common_1.gcloudRunCmd)(), " jobs delete ").concat(jobName, " ").concat(commonArgsString)];
|
|
30611
30611
|
});
|
|
30612
30612
|
};
|
|
30613
30613
|
exports.getDeleteJobsScripts = getDeleteJobsScripts;
|
|
@@ -30635,9 +30635,7 @@ var getJobCreateScripts = function (context) {
|
|
|
30635
30635
|
exports.getJobCreateScripts = getJobCreateScripts;
|
|
30636
30636
|
var getJobCreateScriptsForJob = function (context, jobName, job) {
|
|
30637
30637
|
var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
|
|
30638
|
-
//
|
|
30639
|
-
// lucky, update on the other hand accepts it... so let's just imediatly update it
|
|
30640
|
-
// also we cannot upsert a job, so we have to create it and catch the error and then update
|
|
30638
|
+
// we cannot upsert a job, so we have to create it and catch the error and then update
|
|
30641
30639
|
var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
|
|
30642
30640
|
var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
|
|
30643
30641
|
command: '"' + commandArray.join(",") + '"'
|
|
@@ -30647,10 +30645,13 @@ var getJobCreateScriptsForJob = function (context, jobName, job) {
|
|
|
30647
30645
|
})),
|
|
30648
30646
|
image: job.image || commonDeployArgs.image,
|
|
30649
30647
|
memory: job.memory || "512Mi",
|
|
30650
|
-
"task-timeout": job.timeout || "10m"
|
|
30648
|
+
"task-timeout": job.timeout || "10m",
|
|
30649
|
+
parallelism: job.parallelism || 1,
|
|
30650
|
+
"env-vars-file": "____envvars.yaml",
|
|
30651
|
+
"max-retries": 0
|
|
30651
30652
|
}));
|
|
30652
30653
|
var argsString = "".concat(jobName, " ").concat(commonDeployArgsString);
|
|
30653
|
-
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["
|
|
30654
|
+
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["".concat((0, common_1.gcloudRunCmd)(), " jobs create ").concat(argsString)])), false), ["".concat((0, common_1.gcloudRunCmd)(), " jobs update ").concat(argsString)], false);
|
|
30654
30655
|
};
|
|
30655
30656
|
var getCreateScheduleScripts = function (context) {
|
|
30656
30657
|
var jobsWithSchedule = getCloudRunJobsWithSchedule(context);
|
|
@@ -30670,7 +30671,7 @@ var getCreateScheduleScripts = function (context) {
|
|
|
30670
30671
|
"oauth-service-account-email": "$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"
|
|
30671
30672
|
});
|
|
30672
30673
|
var commonArgs = "http ".concat(schedulerName, " ").concat(argsString);
|
|
30673
|
-
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["
|
|
30674
|
+
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs create ").concat(commonArgs)])), false), ["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs update ").concat(commonArgs)], false);
|
|
30674
30675
|
}).flat();
|
|
30675
30676
|
};
|
|
30676
30677
|
exports.getCreateScheduleScripts = getCreateScheduleScripts;
|
|
@@ -30756,9 +30757,10 @@ var getServiceDeployScript = function (context, service, nameSuffix) {
|
|
|
30756
30757
|
memory: customConfig === null || customConfig === void 0 ? void 0 : customConfig.memory,
|
|
30757
30758
|
"allow-unauthenticated": (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _d !== void 0 ? _d : true,
|
|
30758
30759
|
ingress: (_e = customConfig === null || customConfig === void 0 ? void 0 : customConfig.ingress) !== null && _e !== void 0 ? _e : "all",
|
|
30759
|
-
"cpu-boost": true
|
|
30760
|
+
"cpu-boost": true,
|
|
30761
|
+
"execution-environment": customConfig === null || customConfig === void 0 ? void 0 : customConfig.executionEnvironment
|
|
30760
30762
|
}));
|
|
30761
|
-
return "
|
|
30763
|
+
return "".concat((0, common_1.gcloudRunCmd)(), " deploy ").concat(fullServiceName, " ").concat(argsString);
|
|
30762
30764
|
};
|
|
30763
30765
|
exports.getServiceDeployScript = getServiceDeployScript;
|
|
30764
30766
|
var getServiceDeleteScript = function (context, serviceSuffix) {
|
|
@@ -30766,7 +30768,7 @@ var getServiceDeleteScript = function (context, serviceSuffix) {
|
|
|
30766
30768
|
var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
30767
30769
|
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
30768
30770
|
var fullServiceName = serviceSuffix ? "".concat(serviceName, "-").concat(serviceSuffix) : serviceName;
|
|
30769
|
-
return ["
|
|
30771
|
+
return ["".concat((0, common_1.gcloudRunCmd)(), " services delete ").concat(fullServiceName, " ").concat(commonArgsString)];
|
|
30770
30772
|
};
|
|
30771
30773
|
exports.getServiceDeleteScript = getServiceDeleteScript;
|
|
30772
30774
|
|
|
@@ -30811,11 +30813,23 @@ var __read = this && this.__read || function (o, n) {
|
|
|
30811
30813
|
return ar;
|
|
30812
30814
|
};
|
|
30813
30815
|
exports.__esModule = true;
|
|
30814
|
-
exports.getCommonDeployArgs = exports.getCommonCloudRunArgs = exports.getCloudRunDeployConfig = exports.makeLabelString = exports.setGoogleProjectNumberScript = void 0;
|
|
30816
|
+
exports.getCommonDeployArgs = exports.getCommonCloudRunArgs = exports.getCloudRunDeployConfig = exports.makeLabelString = exports.setGoogleProjectNumberScript = exports.gcloudSchedulerCmd = exports.gcloudRunCmd = exports.gcloudCmd = void 0;
|
|
30815
30817
|
var types_1 = __nccwpck_require__(4436);
|
|
30816
30818
|
var artifactsRegistry_1 = __nccwpck_require__(998);
|
|
30819
|
+
var gcloudCmd = function (version) {
|
|
30820
|
+
return version ? "gcloud ".concat(version) : "gcloud";
|
|
30821
|
+
};
|
|
30822
|
+
exports.gcloudCmd = gcloudCmd;
|
|
30823
|
+
var gcloudRunCmd = function (version) {
|
|
30824
|
+
return "".concat((0, exports.gcloudCmd)(version), " run");
|
|
30825
|
+
};
|
|
30826
|
+
exports.gcloudRunCmd = gcloudRunCmd;
|
|
30827
|
+
var gcloudSchedulerCmd = function (version) {
|
|
30828
|
+
return "".concat((0, exports.gcloudCmd)(version), " scheduler");
|
|
30829
|
+
};
|
|
30830
|
+
exports.gcloudSchedulerCmd = gcloudSchedulerCmd;
|
|
30817
30831
|
var setGoogleProjectNumberScript = function (deployConfig) {
|
|
30818
|
-
return ["export GCLOUD_PROJECT_NUMBER=$(
|
|
30832
|
+
return ["export GCLOUD_PROJECT_NUMBER=$(".concat((0, exports.gcloudCmd)(), " projects describe ").concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
|
|
30819
30833
|
};
|
|
30820
30834
|
exports.setGoogleProjectNumberScript = setGoogleProjectNumberScript;
|
|
30821
30835
|
var makeLabelString = function (obj) {
|
|
@@ -31225,22 +31239,28 @@ var lodash_1 = __nccwpck_require__(3255);
|
|
|
31225
31239
|
* @param args args record
|
|
31226
31240
|
* @returns
|
|
31227
31241
|
*/
|
|
31228
|
-
var createArgsString = function (
|
|
31229
|
-
|
|
31230
|
-
|
|
31231
|
-
|
|
31232
|
-
|
|
31233
|
-
|
|
31234
|
-
|
|
31235
|
-
|
|
31236
|
-
|
|
31237
|
-
|
|
31238
|
-
|
|
31239
|
-
|
|
31240
|
-
|
|
31241
|
-
|
|
31242
|
-
|
|
31243
|
-
|
|
31242
|
+
var createArgsString = function () {
|
|
31243
|
+
var args = [];
|
|
31244
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
31245
|
+
args[_i] = arguments[_i];
|
|
31246
|
+
}
|
|
31247
|
+
return args.map(function (argObj) {
|
|
31248
|
+
return Object.entries(argObj).filter(function (_a) {
|
|
31249
|
+
var _b = __read(_a, 2),
|
|
31250
|
+
value = _b[1];
|
|
31251
|
+
return !(0, lodash_1.isNil)(value);
|
|
31252
|
+
}).map(function (_a) {
|
|
31253
|
+
var _b = __read(_a, 2),
|
|
31254
|
+
key = _b[0],
|
|
31255
|
+
value = _b[1];
|
|
31256
|
+
if (value === true) {
|
|
31257
|
+
return "--".concat(key);
|
|
31258
|
+
} else if (value === false) {
|
|
31259
|
+
return "--no-".concat(key);
|
|
31260
|
+
}
|
|
31261
|
+
return "--".concat(key, "=").concat(value);
|
|
31262
|
+
});
|
|
31263
|
+
}).flat().join(" ");
|
|
31244
31264
|
};
|
|
31245
31265
|
exports.createArgsString = createArgsString;
|
|
31246
31266
|
|
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 = "
|
|
5
|
+
exports.PIPELINE_IMAGE_TAG = "refactore-catenv-command-validates-argument-78d05852" || "";
|
|
6
6
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
|
|
@@ -146,7 +146,7 @@ exports.__esModule = true;
|
|
|
146
146
|
exports.translateLegacyFromComponents = exports.resolveReferences = void 0;
|
|
147
147
|
var lodash_1 = require("lodash");
|
|
148
148
|
var string_replace_async_1 = __importDefault(require("string-replace-async"));
|
|
149
|
-
var REGEX = /\$\{(([^:]+):)?([^}]+)}/gm;
|
|
149
|
+
var REGEX = /\$\{(([^:}]+):)?([^}]+)}/gm;
|
|
150
150
|
var resolveReferences = function (vars, getOtherVariables, alreadyVisitedBase) {
|
|
151
151
|
if (alreadyVisitedBase === void 0) {
|
|
152
152
|
alreadyVisitedBase = {};
|
|
@@ -51,7 +51,7 @@ var getLabels_1 = require("../../../context/getLabels");
|
|
|
51
51
|
var getJobRunScriptForJob = function (context, jobName, wait) {
|
|
52
52
|
var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
53
53
|
var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
54
|
-
return "
|
|
54
|
+
return "".concat((0, common_1.gcloudRunCmd)(), " jobs execute ").concat(jobName, " ").concat(commonArgsString).concat(wait ? " --wait" : "");
|
|
55
55
|
};
|
|
56
56
|
var getDeleteSchedulesScripts = function (context) {
|
|
57
57
|
var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
@@ -62,7 +62,7 @@ var getDeleteSchedulesScripts = function (context) {
|
|
|
62
62
|
});
|
|
63
63
|
return jobsWithSchedule.map(function (_a) {
|
|
64
64
|
var schedulerName = _a.schedulerName;
|
|
65
|
-
return ["
|
|
65
|
+
return ["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs delete ").concat(schedulerName, " ").concat(argsString)];
|
|
66
66
|
}).flat();
|
|
67
67
|
};
|
|
68
68
|
exports.getDeleteSchedulesScripts = getDeleteSchedulesScripts;
|
|
@@ -74,7 +74,7 @@ var getDeleteJobsScripts = function (context) {
|
|
|
74
74
|
var jobName = _a.jobName;
|
|
75
75
|
return [
|
|
76
76
|
// first delete all job executions. Otherwise delete might fail if one of those is still running
|
|
77
|
-
"
|
|
77
|
+
"".concat((0, common_1.gcloudRunCmd)(), " jobs executions list ").concat(commonArgsString, " --job ").concat(jobName, " --format=\"value(name)\" | xargs -I {} ").concat((0, common_1.gcloudRunCmd)(), " jobs executions delete {} --quiet ").concat(commonArgsString), "".concat((0, common_1.gcloudRunCmd)(), " jobs delete ").concat(jobName, " ").concat(commonArgsString)];
|
|
78
78
|
});
|
|
79
79
|
};
|
|
80
80
|
exports.getDeleteJobsScripts = getDeleteJobsScripts;
|
|
@@ -102,9 +102,7 @@ var getJobCreateScripts = function (context) {
|
|
|
102
102
|
exports.getJobCreateScripts = getJobCreateScripts;
|
|
103
103
|
var getJobCreateScriptsForJob = function (context, jobName, job) {
|
|
104
104
|
var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
|
|
105
|
-
//
|
|
106
|
-
// lucky, update on the other hand accepts it... so let's just imediatly update it
|
|
107
|
-
// also we cannot upsert a job, so we have to create it and catch the error and then update
|
|
105
|
+
// we cannot upsert a job, so we have to create it and catch the error and then update
|
|
108
106
|
var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
|
|
109
107
|
var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
|
|
110
108
|
command: '"' + commandArray.join(",") + '"'
|
|
@@ -114,10 +112,13 @@ var getJobCreateScriptsForJob = function (context, jobName, job) {
|
|
|
114
112
|
})),
|
|
115
113
|
image: job.image || commonDeployArgs.image,
|
|
116
114
|
memory: job.memory || "512Mi",
|
|
117
|
-
"task-timeout": job.timeout || "10m"
|
|
115
|
+
"task-timeout": job.timeout || "10m",
|
|
116
|
+
parallelism: job.parallelism || 1,
|
|
117
|
+
"env-vars-file": "____envvars.yaml",
|
|
118
|
+
"max-retries": 0
|
|
118
119
|
}));
|
|
119
120
|
var argsString = "".concat(jobName, " ").concat(commonDeployArgsString);
|
|
120
|
-
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["
|
|
121
|
+
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["".concat((0, common_1.gcloudRunCmd)(), " jobs create ").concat(argsString)])), false), ["".concat((0, common_1.gcloudRunCmd)(), " jobs update ").concat(argsString)], false);
|
|
121
122
|
};
|
|
122
123
|
var getCreateScheduleScripts = function (context) {
|
|
123
124
|
var jobsWithSchedule = getCloudRunJobsWithSchedule(context);
|
|
@@ -137,7 +138,7 @@ var getCreateScheduleScripts = function (context) {
|
|
|
137
138
|
"oauth-service-account-email": "$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"
|
|
138
139
|
});
|
|
139
140
|
var commonArgs = "http ".concat(schedulerName, " ").concat(argsString);
|
|
140
|
-
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["
|
|
141
|
+
return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs create ").concat(commonArgs)])), false), ["".concat((0, common_1.gcloudSchedulerCmd)(), " jobs update ").concat(commonArgs)], false);
|
|
141
142
|
}).flat();
|
|
142
143
|
};
|
|
143
144
|
exports.getCreateScheduleScripts = getCreateScheduleScripts;
|
|
@@ -38,9 +38,10 @@ var getServiceDeployScript = function (context, service, nameSuffix) {
|
|
|
38
38
|
memory: customConfig === null || customConfig === void 0 ? void 0 : customConfig.memory,
|
|
39
39
|
"allow-unauthenticated": (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _d !== void 0 ? _d : true,
|
|
40
40
|
ingress: (_e = customConfig === null || customConfig === void 0 ? void 0 : customConfig.ingress) !== null && _e !== void 0 ? _e : "all",
|
|
41
|
-
"cpu-boost": true
|
|
41
|
+
"cpu-boost": true,
|
|
42
|
+
"execution-environment": customConfig === null || customConfig === void 0 ? void 0 : customConfig.executionEnvironment
|
|
42
43
|
}));
|
|
43
|
-
return "
|
|
44
|
+
return "".concat((0, common_1.gcloudRunCmd)(), " deploy ").concat(fullServiceName, " ").concat(argsString);
|
|
44
45
|
};
|
|
45
46
|
exports.getServiceDeployScript = getServiceDeployScript;
|
|
46
47
|
var getServiceDeleteScript = function (context, serviceSuffix) {
|
|
@@ -48,6 +49,6 @@ var getServiceDeleteScript = function (context, serviceSuffix) {
|
|
|
48
49
|
var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
49
50
|
var serviceName = (0, getServiceName_1.getServiceName)(context);
|
|
50
51
|
var fullServiceName = serviceSuffix ? "".concat(serviceName, "-").concat(serviceSuffix) : serviceName;
|
|
51
|
-
return ["
|
|
52
|
+
return ["".concat((0, common_1.gcloudRunCmd)(), " services delete ").concat(fullServiceName, " ").concat(commonArgsString)];
|
|
52
53
|
};
|
|
53
54
|
exports.getServiceDeleteScript = getServiceDeleteScript;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Context } from "../../../types/context";
|
|
2
2
|
import type { DeployConfigCloudRun } from "../../types/googleCloudRun";
|
|
3
|
+
export declare const gcloudCmd: (version?: "beta" | undefined) => string;
|
|
4
|
+
export declare const gcloudRunCmd: (version?: "beta" | undefined) => string;
|
|
5
|
+
export declare const gcloudSchedulerCmd: (version?: "beta" | undefined) => string;
|
|
3
6
|
export declare const setGoogleProjectNumberScript: (deployConfig: DeployConfigCloudRun) => string[];
|
|
4
7
|
export declare const makeLabelString: (obj: Record<string, unknown>) => string;
|
|
5
8
|
export declare const getCloudRunDeployConfig: (context: Context) => DeployConfigCloudRun;
|
|
@@ -33,11 +33,23 @@ var __read = this && this.__read || function (o, n) {
|
|
|
33
33
|
return ar;
|
|
34
34
|
};
|
|
35
35
|
exports.__esModule = true;
|
|
36
|
-
exports.getCommonDeployArgs = exports.getCommonCloudRunArgs = exports.getCloudRunDeployConfig = exports.makeLabelString = exports.setGoogleProjectNumberScript = void 0;
|
|
36
|
+
exports.getCommonDeployArgs = exports.getCommonCloudRunArgs = exports.getCloudRunDeployConfig = exports.makeLabelString = exports.setGoogleProjectNumberScript = exports.gcloudSchedulerCmd = exports.gcloudRunCmd = exports.gcloudCmd = void 0;
|
|
37
37
|
var types_1 = require("../../types");
|
|
38
38
|
var artifactsRegistry_1 = require("../artifactsRegistry");
|
|
39
|
+
var gcloudCmd = function (version) {
|
|
40
|
+
return version ? "gcloud ".concat(version) : "gcloud";
|
|
41
|
+
};
|
|
42
|
+
exports.gcloudCmd = gcloudCmd;
|
|
43
|
+
var gcloudRunCmd = function (version) {
|
|
44
|
+
return "".concat((0, exports.gcloudCmd)(version), " run");
|
|
45
|
+
};
|
|
46
|
+
exports.gcloudRunCmd = gcloudRunCmd;
|
|
47
|
+
var gcloudSchedulerCmd = function (version) {
|
|
48
|
+
return "".concat((0, exports.gcloudCmd)(version), " scheduler");
|
|
49
|
+
};
|
|
50
|
+
exports.gcloudSchedulerCmd = gcloudSchedulerCmd;
|
|
39
51
|
var setGoogleProjectNumberScript = function (deployConfig) {
|
|
40
|
-
return ["export GCLOUD_PROJECT_NUMBER=$(
|
|
52
|
+
return ["export GCLOUD_PROJECT_NUMBER=$(".concat((0, exports.gcloudCmd)(), " projects describe ").concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
|
|
41
53
|
};
|
|
42
54
|
exports.setGoogleProjectNumberScript = setGoogleProjectNumberScript;
|
|
43
55
|
var makeLabelString = function (obj) {
|
|
@@ -8,4 +8,6 @@
|
|
|
8
8
|
* @param args args record
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
|
-
export declare const createArgsString: (args:
|
|
11
|
+
export declare const createArgsString: (...args: keyValuesArg[]) => string;
|
|
12
|
+
declare type keyValuesArg = Record<string, string | number | true | false | undefined>;
|
|
13
|
+
export {};
|
|
@@ -35,21 +35,27 @@ var lodash_1 = require("lodash");
|
|
|
35
35
|
* @param args args record
|
|
36
36
|
* @returns
|
|
37
37
|
*/
|
|
38
|
-
var createArgsString = function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
var createArgsString = function () {
|
|
39
|
+
var args = [];
|
|
40
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
41
|
+
args[_i] = arguments[_i];
|
|
42
|
+
}
|
|
43
|
+
return args.map(function (argObj) {
|
|
44
|
+
return Object.entries(argObj).filter(function (_a) {
|
|
45
|
+
var _b = __read(_a, 2),
|
|
46
|
+
value = _b[1];
|
|
47
|
+
return !(0, lodash_1.isNil)(value);
|
|
48
|
+
}).map(function (_a) {
|
|
49
|
+
var _b = __read(_a, 2),
|
|
50
|
+
key = _b[0],
|
|
51
|
+
value = _b[1];
|
|
52
|
+
if (value === true) {
|
|
53
|
+
return "--".concat(key);
|
|
54
|
+
} else if (value === false) {
|
|
55
|
+
return "--no-".concat(key);
|
|
56
|
+
}
|
|
57
|
+
return "--".concat(key, "=").concat(value);
|
|
58
|
+
});
|
|
59
|
+
}).flat().join(" ");
|
|
54
60
|
};
|
|
55
61
|
exports.createArgsString = createArgsString;
|
|
@@ -70,6 +70,15 @@ export declare type DeployConfigCloudRunService = {
|
|
|
70
70
|
* memory limit. Defaults to 512MB
|
|
71
71
|
*/
|
|
72
72
|
memory?: Memory;
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* set the execution environment.
|
|
76
|
+
*
|
|
77
|
+
* see https://cloud.google.com/run/docs/about-execution-environments
|
|
78
|
+
*
|
|
79
|
+
* defaults to gen1 according to gcloud
|
|
80
|
+
*/
|
|
81
|
+
executionEnvironment?: "gen2" | "gen1";
|
|
73
82
|
};
|
|
74
83
|
export declare type DeployConfigCloudRunJobBase = {
|
|
75
84
|
/**
|
|
@@ -81,7 +90,7 @@ export declare type DeployConfigCloudRunJobBase = {
|
|
|
81
90
|
*/
|
|
82
91
|
image?: string;
|
|
83
92
|
/**
|
|
84
|
-
* memory limit of the job, defaults to
|
|
93
|
+
* memory limit of the job, defaults to 512Mi
|
|
85
94
|
*/
|
|
86
95
|
memory?: `${number}${"M" | "G" | "Mi" | "Gi"}`;
|
|
87
96
|
/**
|
|
@@ -90,6 +99,10 @@ export declare type DeployConfigCloudRunJobBase = {
|
|
|
90
99
|
* you can specify something like 10m30s
|
|
91
100
|
*/
|
|
92
101
|
timeout?: string;
|
|
102
|
+
/**
|
|
103
|
+
* number of tasks that may run concurrently, defaults to 1
|
|
104
|
+
*/
|
|
105
|
+
parallelism?: number;
|
|
93
106
|
};
|
|
94
107
|
declare type Minute = string;
|
|
95
108
|
declare type Hour = string;
|
|
@@ -99,6 +112,12 @@ declare type Month = string;
|
|
|
99
112
|
export declare type DeployConfigCloudRunJobWithSchedule = DeployConfigCloudRunJobBase & {
|
|
100
113
|
when: "schedule";
|
|
101
114
|
schedule: `${Minute} ${Hour} ${DayOfMonth} ${Month} ${DayOfWeek}`;
|
|
115
|
+
/**
|
|
116
|
+
* Max number of retries of the cloud scheduler.
|
|
117
|
+
* Note: the task itself is never retried.
|
|
118
|
+
*
|
|
119
|
+
* defaults to 0 (no retries)
|
|
120
|
+
*/
|
|
102
121
|
maxRetryAttempts?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
103
122
|
};
|
|
104
123
|
export declare type DeployConfigCloudRunJobNormal = DeployConfigCloudRunJobBase & {
|