@catladder/pipeline 0.0.0-main-c595e7af → 0.0.0-main-2f2f483e

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.
@@ -25763,7 +25763,7 @@ Object.defineProperty(exports, "__esModule", ({
25763
25763
  value: true
25764
25764
  }));
25765
25765
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
25766
- exports.PIPELINE_IMAGE_TAG = "main-c595e7af" || 0;
25766
+ exports.PIPELINE_IMAGE_TAG = "main-2f2f483e" || 0;
25767
25767
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
25768
25768
 
25769
25769
  /***/ }),
@@ -28222,6 +28222,14 @@ var __assign = this && this.__assign || function () {
28222
28222
  };
28223
28223
  return __assign.apply(this, arguments);
28224
28224
  };
28225
+ var __rest = this && this.__rest || function (s, e) {
28226
+ var t = {};
28227
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
28228
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
28229
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
28230
+ }
28231
+ return t;
28232
+ };
28225
28233
  var __read = this && this.__read || function (o, n) {
28226
28234
  var m = typeof Symbol === "function" && o[Symbol.iterator];
28227
28235
  if (!m) return o;
@@ -28257,13 +28265,13 @@ Object.defineProperty(exports, "__esModule", ({
28257
28265
  value: true
28258
28266
  }));
28259
28267
  exports.getCreateScheduleScripts = exports.getJobCreateScripts = exports.getJobRunScripts = exports.getDeleteJobsScripts = exports.getDeleteSchedulesScripts = void 0;
28260
- var gitlab_1 = __nccwpck_require__(9818);
28261
28268
  var createArgsString_1 = __nccwpck_require__(947);
28262
28269
  var jobName_1 = __nccwpck_require__(9357);
28263
28270
  var common_1 = __nccwpck_require__(5113);
28264
28271
  var getLabels_1 = __nccwpck_require__(2101);
28265
28272
  var volumes_1 = __nccwpck_require__(2118);
28266
28273
  var constants_1 = __nccwpck_require__(4620);
28274
+ var utils_1 = __nccwpck_require__(1815);
28267
28275
  var getJobRunScriptForJob = function (context, jobName, wait) {
28268
28276
  var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
28269
28277
  var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
@@ -28308,58 +28316,73 @@ var getJobRunScripts = function (context, when) {
28308
28316
  };
28309
28317
  exports.getJobRunScripts = getJobRunScripts;
28310
28318
  var getJobCreateScripts = function (context) {
28311
- var jobsWithNames = getCloudRunJobsWithNames(context);
28312
- return jobsWithNames.map(function (_a) {
28313
- var job = _a.job,
28319
+ return getCloudRunJobsWithNames(context).map(function (_a, jobIndex) {
28320
+ var _b = _a.job,
28321
+ command = _b.command,
28322
+ image = _b.image,
28323
+ cpu = _b.cpu,
28324
+ _c = _b.memory,
28325
+ memory = _c === void 0 ? "512Mi" : _c,
28326
+ _d = _b.timeout,
28327
+ timeout = _d === void 0 ? "10m" : _d,
28328
+ _e = _b.parallelism,
28329
+ parallelism = _e === void 0 ? 1 : _e,
28330
+ volumes = _b.volumes,
28314
28331
  jobName = _a.jobName;
28315
- return getJobCreateScriptsForJob(context, jobName, job);
28316
- }).flat();
28332
+ var commandArray = Array.isArray(command) ? command : command.split(" ");
28333
+ var _f = (0, common_1.getCommonDeployArgs)(context),
28334
+ commonImage = _f.image,
28335
+ project = _f.project,
28336
+ region = _f.region,
28337
+ deployArgs = __rest(_f, ["image", "project", "region"]);
28338
+ var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign({
28339
+ command: "\"".concat(commandArray.join(","), "\""),
28340
+ labels: "\"".concat((0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context)), ",cloud-run-job-name=$current_job_name\""),
28341
+ image: "\"".concat(image !== null && image !== void 0 ? image : commonImage, "\""),
28342
+ project: project,
28343
+ region: region,
28344
+ cpu: cpu,
28345
+ memory: memory,
28346
+ parallelism: parallelism,
28347
+ "task-timeout": timeout,
28348
+ "env-vars-file": constants_1.ENV_VARS_FILENAME,
28349
+ "max-retries": 0
28350
+ }, deployArgs));
28351
+ // due to some oversight from google, jobs create does not yet accept `--add-volume` 🤦
28352
+ // lucky, update on the other hand accepts it... so let's just imediatly update it
28353
+ // we cannot upsert a job, so we have to create it and catch the error and then update
28354
+ var hasVolumes = Object.keys(volumes || {}).length > 0;
28355
+ var needsBeta = hasVolumes ? "beta" : undefined;
28356
+ var volumeArgs = hasVolumes ? createArgsString_1.createArgsString.apply(void 0, __spreadArray([], __read((0, volumes_1.createVolumeConfig)(volumes, "job")), false)) : "";
28357
+ return [jobIndex === 0 ? "exist_job_names=\"$(\n ".concat((0, common_1.gcloudRunCmd)(), " jobs list --filter='metadata.name ~ ").concat(context.env, ".*").concat(context.name, "' --format='value(name)' --limit=999 --project='").concat(project, "' --region='").concat(region, "'\n)\"") : null, "current_job_name=\"".concat(jobName, "\""), 'if grep "$current_job_name" <<<"$exist_job_names" >/dev/null; then', " ".concat((0, common_1.gcloudRunCmd)(needsBeta), " jobs update \"$current_job_name\" ").concat(commonDeployArgsString, " ").concat(volumeArgs), "else", " ".concat((0, common_1.gcloudRunCmd)(), " jobs create \"$current_job_name\" ").concat(commonDeployArgsString), "fi"].filter(utils_1.notNil).join("\n");
28358
+ });
28317
28359
  };
28318
28360
  exports.getJobCreateScripts = getJobCreateScripts;
28319
- var getJobCreateScriptsForJob = function (context, jobName, job) {
28320
- var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
28321
- // due to some oversight from google, jobs create does not yet accept `--add-volume` 🤦
28322
- // lucky, update on the other hand accepts it... so let's just imediatly update it
28323
- // we cannot upsert a job, so we have to create it and catch the error and then update
28324
- var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
28325
- var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
28326
- command: '"' + commandArray.join(",") + '"'
28327
- }, commonDeployArgs), {
28328
- labels: (0, common_1.makeLabelString)(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
28329
- "cloud-run-job-name": jobName.toString()
28330
- })),
28331
- image: job.image || commonDeployArgs.image,
28332
- cpu: job === null || job === void 0 ? void 0 : job.cpu,
28333
- memory: job.memory || "512Mi",
28334
- "task-timeout": job.timeout || "10m",
28335
- parallelism: job.parallelism || 1,
28336
- "env-vars-file": constants_1.ENV_VARS_FILENAME,
28337
- "max-retries": 0
28338
- }));
28339
- var requiresBeta = (job === null || job === void 0 ? void 0 : job.volumes) && Object.keys(job === null || job === void 0 ? void 0 : job.volumes).length > 0;
28340
- var argsString = "".concat(jobName, " ").concat(commonDeployArgsString);
28341
- return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["".concat((0, common_1.gcloudRunCmd)(), " jobs create ").concat(argsString)])), false), ["".concat((0, common_1.gcloudRunCmd)(requiresBeta ? "beta" : undefined), " jobs update ").concat(argsString, " ").concat(createArgsString_1.createArgsString.apply(void 0, __spreadArray([], __read((0, volumes_1.createVolumeConfig)(job === null || job === void 0 ? void 0 : job.volumes, "job")), false)))], false);
28342
- };
28343
28361
  var getCreateScheduleScripts = function (context) {
28344
28362
  var jobsWithSchedule = getCloudRunJobsWithSchedule(context);
28345
- var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
28346
- return jobsWithSchedule.map(function (_a) {
28347
- var _b;
28348
- var job = _a.job,
28363
+ var _a = (0, common_1.getCloudRunDeployConfig)(context),
28364
+ location = _a.region,
28365
+ project = _a.projectId;
28366
+ var uriBase = "https://".concat(location, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(project, "/jobs");
28367
+ var gcloudArgs = {
28368
+ project: project,
28369
+ location: location,
28370
+ uri: "\"$current_job_uri\"",
28371
+ "http-method": "POST",
28372
+ "oauth-service-account-email": "\"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com\""
28373
+ };
28374
+ return jobsWithSchedule.map(function (_a, jobIndex) {
28375
+ var _b = _a.job,
28376
+ maxRetryAttempts = _b.maxRetryAttempts,
28377
+ schedule = _b.schedule,
28349
28378
  jobName = _a.jobName,
28350
28379
  schedulerName = _a.schedulerName;
28351
- var argsString = (0, createArgsString_1.createArgsString)({
28352
- project: deployConfig.projectId,
28353
- location: deployConfig.region,
28354
- schedule: "\"".concat(job.schedule, "\""),
28355
- "max-retry-attempts": (_b = job.maxRetryAttempts) !== null && _b !== void 0 ? _b : 0,
28356
- uri: "\"https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(jobName, ":run\""),
28357
- "http-method": "POST",
28358
- "oauth-service-account-email": "$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"
28359
- });
28360
- var commonArgs = "http ".concat(schedulerName, " ").concat(argsString);
28361
- 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);
28362
- }).flat();
28380
+ var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({}, gcloudArgs), {
28381
+ schedule: "\"".concat(schedule, "\""),
28382
+ "max-retry-attempts": maxRetryAttempts !== null && maxRetryAttempts !== void 0 ? maxRetryAttempts : 0
28383
+ }));
28384
+ return [jobIndex === 0 ? "exist_scheduler_names=\"$(\n ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs list --filter='httpTarget.uri ~ ").concat(context.env, ".*").concat(context.name, "' --format='value(name)' --limit=999 --location='").concat(location, "' --project='").concat(project, "'\n)\"") : null, "current_job_uri=\"".concat(uriBase, "/").concat(jobName, ":run\""), "current_scheduler_name=\"".concat(schedulerName, "\""), "if grep \"$current_scheduler_name\" <<<\"$exist_scheduler_names\" >/dev/null; then", " ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs update http \"$current_scheduler_name\" ").concat(argsString), "else", " ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs create http \"$current_scheduler_name\" ").concat(argsString), "fi"].filter(utils_1.notNil).join("\n");
28385
+ });
28363
28386
  };
28364
28387
  exports.getCreateScheduleScripts = getCreateScheduleScripts;
28365
28388
  var getCloudRunJobsWithSchedule = function (context) {
@@ -28368,10 +28391,12 @@ var getCloudRunJobsWithSchedule = function (context) {
28368
28391
  return entry.job.when === "schedule";
28369
28392
  }).map(function (_a) {
28370
28393
  var job = _a.job,
28371
- jobName = _a.jobName;
28394
+ jobName = _a.jobName,
28395
+ jobKey = _a.jobKey;
28372
28396
  return {
28373
28397
  job: job,
28374
28398
  jobName: jobName,
28399
+ jobKey: jobKey,
28375
28400
  schedulerName: jobName.concat("-scheduler")
28376
28401
  };
28377
28402
  });
@@ -28388,11 +28413,12 @@ var getCloudRunJobsWithNames = function (context) {
28388
28413
  return Boolean(entry[1]);
28389
28414
  }).map(function (_a) {
28390
28415
  var _b = __read(_a, 2),
28391
- name = _b[0],
28416
+ jobKey = _b[0],
28392
28417
  job = _b[1];
28393
28418
  return {
28394
- jobName: getFullJobName(name),
28395
- job: job
28419
+ jobName: getFullJobName(jobKey),
28420
+ job: job,
28421
+ jobKey: jobKey
28396
28422
  };
28397
28423
  });
28398
28424
  return jobsWithNames;
package/dist/constants.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
7
- exports.PIPELINE_IMAGE_TAG = "main-c595e7af" || "latest";
7
+ exports.PIPELINE_IMAGE_TAG = "main-2f2f483e" || "latest";
8
8
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
@@ -10,6 +10,14 @@ var __assign = this && this.__assign || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __rest = this && this.__rest || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
13
21
  var __read = this && this.__read || function (o, n) {
14
22
  var m = typeof Symbol === "function" && o[Symbol.iterator];
15
23
  if (!m) return o;
@@ -45,13 +53,13 @@ Object.defineProperty(exports, "__esModule", {
45
53
  value: true
46
54
  });
47
55
  exports.getCreateScheduleScripts = exports.getJobCreateScripts = exports.getJobRunScripts = exports.getDeleteJobsScripts = exports.getDeleteSchedulesScripts = void 0;
48
- var gitlab_1 = require("../../../utils/gitlab");
49
56
  var createArgsString_1 = require("../utils/createArgsString");
50
57
  var jobName_1 = require("../utils/jobName");
51
58
  var common_1 = require("./common");
52
59
  var getLabels_1 = require("../../../context/getLabels");
53
60
  var volumes_1 = require("./volumes");
54
61
  var constants_1 = require("./constants");
62
+ var utils_1 = require("../../../utils");
55
63
  var getJobRunScriptForJob = function (context, jobName, wait) {
56
64
  var commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
57
65
  var commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
@@ -96,58 +104,73 @@ var getJobRunScripts = function (context, when) {
96
104
  };
97
105
  exports.getJobRunScripts = getJobRunScripts;
98
106
  var getJobCreateScripts = function (context) {
99
- var jobsWithNames = getCloudRunJobsWithNames(context);
100
- return jobsWithNames.map(function (_a) {
101
- var job = _a.job,
107
+ return getCloudRunJobsWithNames(context).map(function (_a, jobIndex) {
108
+ var _b = _a.job,
109
+ command = _b.command,
110
+ image = _b.image,
111
+ cpu = _b.cpu,
112
+ _c = _b.memory,
113
+ memory = _c === void 0 ? "512Mi" : _c,
114
+ _d = _b.timeout,
115
+ timeout = _d === void 0 ? "10m" : _d,
116
+ _e = _b.parallelism,
117
+ parallelism = _e === void 0 ? 1 : _e,
118
+ volumes = _b.volumes,
102
119
  jobName = _a.jobName;
103
- return getJobCreateScriptsForJob(context, jobName, job);
104
- }).flat();
120
+ var commandArray = Array.isArray(command) ? command : command.split(" ");
121
+ var _f = (0, common_1.getCommonDeployArgs)(context),
122
+ commonImage = _f.image,
123
+ project = _f.project,
124
+ region = _f.region,
125
+ deployArgs = __rest(_f, ["image", "project", "region"]);
126
+ var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign({
127
+ command: "\"".concat(commandArray.join(","), "\""),
128
+ labels: "\"".concat((0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context)), ",cloud-run-job-name=$current_job_name\""),
129
+ image: "\"".concat(image !== null && image !== void 0 ? image : commonImage, "\""),
130
+ project: project,
131
+ region: region,
132
+ cpu: cpu,
133
+ memory: memory,
134
+ parallelism: parallelism,
135
+ "task-timeout": timeout,
136
+ "env-vars-file": constants_1.ENV_VARS_FILENAME,
137
+ "max-retries": 0
138
+ }, deployArgs));
139
+ // due to some oversight from google, jobs create does not yet accept `--add-volume` 🤦
140
+ // lucky, update on the other hand accepts it... so let's just imediatly update it
141
+ // we cannot upsert a job, so we have to create it and catch the error and then update
142
+ var hasVolumes = Object.keys(volumes || {}).length > 0;
143
+ var needsBeta = hasVolumes ? "beta" : undefined;
144
+ var volumeArgs = hasVolumes ? createArgsString_1.createArgsString.apply(void 0, __spreadArray([], __read((0, volumes_1.createVolumeConfig)(volumes, "job")), false)) : "";
145
+ return [jobIndex === 0 ? "exist_job_names=\"$(\n ".concat((0, common_1.gcloudRunCmd)(), " jobs list --filter='metadata.name ~ ").concat(context.env, ".*").concat(context.name, "' --format='value(name)' --limit=999 --project='").concat(project, "' --region='").concat(region, "'\n)\"") : null, "current_job_name=\"".concat(jobName, "\""), 'if grep "$current_job_name" <<<"$exist_job_names" >/dev/null; then', " ".concat((0, common_1.gcloudRunCmd)(needsBeta), " jobs update \"$current_job_name\" ").concat(commonDeployArgsString, " ").concat(volumeArgs), "else", " ".concat((0, common_1.gcloudRunCmd)(), " jobs create \"$current_job_name\" ").concat(commonDeployArgsString), "fi"].filter(utils_1.notNil).join("\n");
146
+ });
105
147
  };
106
148
  exports.getJobCreateScripts = getJobCreateScripts;
107
- var getJobCreateScriptsForJob = function (context, jobName, job) {
108
- var commonDeployArgs = (0, common_1.getCommonDeployArgs)(context);
109
- // due to some oversight from google, jobs create does not yet accept `--add-volume` 🤦
110
- // lucky, update on the other hand accepts it... so let's just imediatly update it
111
- // we cannot upsert a job, so we have to create it and catch the error and then update
112
- var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
113
- var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
114
- command: '"' + commandArray.join(",") + '"'
115
- }, commonDeployArgs), {
116
- labels: (0, common_1.makeLabelString)(__assign(__assign({}, (0, getLabels_1.getLabels)(context)), {
117
- "cloud-run-job-name": jobName.toString()
118
- })),
119
- image: job.image || commonDeployArgs.image,
120
- cpu: job === null || job === void 0 ? void 0 : job.cpu,
121
- memory: job.memory || "512Mi",
122
- "task-timeout": job.timeout || "10m",
123
- parallelism: job.parallelism || 1,
124
- "env-vars-file": constants_1.ENV_VARS_FILENAME,
125
- "max-retries": 0
126
- }));
127
- var requiresBeta = (job === null || job === void 0 ? void 0 : job.volumes) && Object.keys(job === null || job === void 0 ? void 0 : job.volumes).length > 0;
128
- var argsString = "".concat(jobName, " ").concat(commonDeployArgsString);
129
- return __spreadArray(__spreadArray([], __read((0, gitlab_1.allowFailureInScripts)(["".concat((0, common_1.gcloudRunCmd)(), " jobs create ").concat(argsString)])), false), ["".concat((0, common_1.gcloudRunCmd)(requiresBeta ? "beta" : undefined), " jobs update ").concat(argsString, " ").concat(createArgsString_1.createArgsString.apply(void 0, __spreadArray([], __read((0, volumes_1.createVolumeConfig)(job === null || job === void 0 ? void 0 : job.volumes, "job")), false)))], false);
130
- };
131
149
  var getCreateScheduleScripts = function (context) {
132
150
  var jobsWithSchedule = getCloudRunJobsWithSchedule(context);
133
- var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
134
- return jobsWithSchedule.map(function (_a) {
135
- var _b;
136
- var job = _a.job,
151
+ var _a = (0, common_1.getCloudRunDeployConfig)(context),
152
+ location = _a.region,
153
+ project = _a.projectId;
154
+ var uriBase = "https://".concat(location, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(project, "/jobs");
155
+ var gcloudArgs = {
156
+ project: project,
157
+ location: location,
158
+ uri: "\"$current_job_uri\"",
159
+ "http-method": "POST",
160
+ "oauth-service-account-email": "\"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com\""
161
+ };
162
+ return jobsWithSchedule.map(function (_a, jobIndex) {
163
+ var _b = _a.job,
164
+ maxRetryAttempts = _b.maxRetryAttempts,
165
+ schedule = _b.schedule,
137
166
  jobName = _a.jobName,
138
167
  schedulerName = _a.schedulerName;
139
- var argsString = (0, createArgsString_1.createArgsString)({
140
- project: deployConfig.projectId,
141
- location: deployConfig.region,
142
- schedule: "\"".concat(job.schedule, "\""),
143
- "max-retry-attempts": (_b = job.maxRetryAttempts) !== null && _b !== void 0 ? _b : 0,
144
- uri: "\"https://".concat(deployConfig.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfig.projectId, "/jobs/").concat(jobName, ":run\""),
145
- "http-method": "POST",
146
- "oauth-service-account-email": "$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"
147
- });
148
- var commonArgs = "http ".concat(schedulerName, " ").concat(argsString);
149
- 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);
150
- }).flat();
168
+ var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({}, gcloudArgs), {
169
+ schedule: "\"".concat(schedule, "\""),
170
+ "max-retry-attempts": maxRetryAttempts !== null && maxRetryAttempts !== void 0 ? maxRetryAttempts : 0
171
+ }));
172
+ return [jobIndex === 0 ? "exist_scheduler_names=\"$(\n ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs list --filter='httpTarget.uri ~ ").concat(context.env, ".*").concat(context.name, "' --format='value(name)' --limit=999 --location='").concat(location, "' --project='").concat(project, "'\n)\"") : null, "current_job_uri=\"".concat(uriBase, "/").concat(jobName, ":run\""), "current_scheduler_name=\"".concat(schedulerName, "\""), "if grep \"$current_scheduler_name\" <<<\"$exist_scheduler_names\" >/dev/null; then", " ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs update http \"$current_scheduler_name\" ").concat(argsString), "else", " ".concat((0, common_1.gcloudSchedulerCmd)(), " jobs create http \"$current_scheduler_name\" ").concat(argsString), "fi"].filter(utils_1.notNil).join("\n");
173
+ });
151
174
  };
152
175
  exports.getCreateScheduleScripts = getCreateScheduleScripts;
153
176
  var getCloudRunJobsWithSchedule = function (context) {
@@ -156,10 +179,12 @@ var getCloudRunJobsWithSchedule = function (context) {
156
179
  return entry.job.when === "schedule";
157
180
  }).map(function (_a) {
158
181
  var job = _a.job,
159
- jobName = _a.jobName;
182
+ jobName = _a.jobName,
183
+ jobKey = _a.jobKey;
160
184
  return {
161
185
  job: job,
162
186
  jobName: jobName,
187
+ jobKey: jobKey,
163
188
  schedulerName: jobName.concat("-scheduler")
164
189
  };
165
190
  });
@@ -176,11 +201,12 @@ var getCloudRunJobsWithNames = function (context) {
176
201
  return Boolean(entry[1]);
177
202
  }).map(function (_a) {
178
203
  var _b = __read(_a, 2),
179
- name = _b[0],
204
+ jobKey = _b[0],
180
205
  job = _b[1];
181
206
  return {
182
- jobName: getFullJobName(name),
183
- job: job
207
+ jobName: getFullJobName(jobKey),
208
+ job: job,
209
+ jobKey: jobKey
184
210
  };
185
211
  });
186
212
  return jobsWithNames;