@catladder/cli 0.0.0-main-99d0da33 → 0.0.0-main-c5bbedc6

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.
Files changed (26) hide show
  1. package/dist/bundles/catenv/index.js +292 -114
  2. package/dist/bundles/cli/index.js +292 -114
  3. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +5 -3
  4. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js +16 -105
  5. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js.map +1 -1
  6. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.d.ts +4 -0
  7. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js +85 -0
  8. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js.map +1 -0
  9. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.d.ts +3 -0
  10. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js +136 -0
  11. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js.map +1 -0
  12. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +5 -3
  13. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
  14. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +5 -3
  15. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js.map +1 -1
  16. package/dist/pipeline/src/deploy/cloudRun/index.js +6 -2
  17. package/dist/pipeline/src/deploy/cloudRun/index.js.map +1 -1
  18. package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.d.ts +6 -0
  19. package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.js +11 -0
  20. package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.js.map +1 -0
  21. package/dist/pipeline/src/deploy/cloudRun/utils/jobName.d.ts +5 -1
  22. package/dist/pipeline/src/deploy/cloudRun/utils/jobName.js +7 -1
  23. package/dist/pipeline/src/deploy/cloudRun/utils/jobName.js.map +1 -1
  24. package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +95 -1
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +1 -1
@@ -6778,62 +6778,27 @@ exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
6778
6778
  "use strict";
6779
6779
 
6780
6780
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6781
- exports.getCreateScheduleScripts = exports.getJobCreateScripts = exports.getJobRunScripts = exports.getDeleteJobsScripts = exports.getDeleteSchedulesScripts = void 0;
6781
+ exports.getCloudRunJobsWithNames = exports.getJobCreateScripts = exports.getDeleteJobsScripts = void 0;
6782
+ const getLabels_1 = __nccwpck_require__(30920);
6783
+ const utils_1 = __nccwpck_require__(32497);
6782
6784
  const createArgsString_1 = __nccwpck_require__(49598);
6783
6785
  const jobName_1 = __nccwpck_require__(9626);
6784
6786
  const common_1 = __nccwpck_require__(73325);
6785
- const getLabels_1 = __nccwpck_require__(30920);
6786
- const volumes_1 = __nccwpck_require__(60847);
6787
6787
  const constants_1 = __nccwpck_require__(38865);
6788
- const utils_1 = __nccwpck_require__(32497);
6789
- const getJobRunScriptForJob = (context, jobName, wait) => {
6790
- const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
6791
- const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
6792
- return `${(0, common_1.gcloudRunCmd)()} jobs execute ${jobName.toString()} ${commonArgsString}${wait ? " --wait" : ""}`;
6793
- };
6794
- const getDeleteSchedulesScripts = (context) => {
6795
- const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
6796
- const schedules = getSchedules(context);
6797
- const argsString = (0, createArgsString_1.createArgsString)({
6798
- project: deployConfig.projectId,
6799
- location: deployConfig.region,
6800
- });
6801
- return schedules
6802
- .map(({ name }) => {
6803
- return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${name} ${argsString}`];
6804
- })
6805
- .flat();
6806
- };
6807
- exports.getDeleteSchedulesScripts = getDeleteSchedulesScripts;
6788
+ const volumes_1 = __nccwpck_require__(60847);
6789
+ const onDeploy_1 = __nccwpck_require__(2358);
6808
6790
  const getDeleteJobsScripts = (context) => {
6809
6791
  const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
6810
6792
  const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
6811
- const jobsWithNames = getCloudRunJobsWithNames(context);
6812
- return jobsWithNames.flatMap(({ jobName }) => [
6793
+ const jobsWithNames = (0, exports.getCloudRunJobsWithNames)(context);
6794
+ return jobsWithNames.flatMap(({ fullJobName }) => [
6813
6795
  // first delete all job executions. Otherwise delete might fail if one of those is still running
6814
- `${(0, common_1.gcloudRunCmd)()} jobs executions list ${commonArgsString} --job ${jobName} --format="value(name)" | xargs -I {} ${(0, common_1.gcloudRunCmd)()} jobs executions delete {} --quiet ${commonArgsString}`,
6815
- `${(0, common_1.gcloudRunCmd)()} jobs delete ${jobName} ${commonArgsString}`,
6796
+ `${(0, common_1.gcloudRunCmd)()} jobs executions list ${commonArgsString} --job ${fullJobName} --format="value(name)" | xargs -I {} ${(0, common_1.gcloudRunCmd)()} jobs executions delete {} --quiet ${commonArgsString}`,
6797
+ `${(0, common_1.gcloudRunCmd)()} jobs delete ${fullJobName} ${commonArgsString}`,
6816
6798
  ]);
6817
6799
  };
6818
6800
  exports.getDeleteJobsScripts = getDeleteJobsScripts;
6819
- const getJobRunScripts = (context, when) => {
6820
- const jobsWithNames = getCloudRunJobsWithNames(context);
6821
- return jobsWithNames
6822
- .filter(({ job }) => job.when === when)
6823
- .map(({ jobName, job }) => {
6824
- var _a;
6825
- // always wait for completion for preStop and postStop jobs
6826
- // since stop will delete the jobs afterwards, so they will fail
6827
- const waitForCompletion = ["preStop", "postStop"].includes(when)
6828
- ? true
6829
- : "waitForCompletion" in job
6830
- ? ((_a = job.waitForCompletion) !== null && _a !== void 0 ? _a : false)
6831
- : false;
6832
- return getJobRunScriptForJob(context, jobName, waitForCompletion);
6833
- });
6834
- };
6835
- exports.getJobRunScripts = getJobRunScripts;
6836
- const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map(({ job, jobName }, jobIndex) => {
6801
+ const getJobCreateScripts = (context) => (0, exports.getCloudRunJobsWithNames)(context).map(({ job, fullJobName }, jobIndex) => {
6837
6802
  var _a, _b, _c, _d;
6838
6803
  const commandArray = Array.isArray(job.command)
6839
6804
  ? job.command
@@ -6841,6 +6806,7 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
6841
6806
  const { image: commonImage, project, region, ...deployArgs } = (0, common_1.getCommonDeployArgs)(context);
6842
6807
  const commonDeployArgsString = (0, createArgsString_1.createArgsString)({
6843
6808
  command: `"${commandArray.join(",")}"`,
6809
+ args: (0, onDeploy_1.getCloudRunJobArgsArg)(job.args),
6844
6810
  labels: `"${(0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context))},cloud-run-job-name=$current_job_name"`,
6845
6811
  image: `"${(_a = job.image) !== null && _a !== void 0 ? _a : commonImage}"`,
6846
6812
  project,
@@ -6862,7 +6828,7 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
6862
6828
  jobIndex === 0
6863
6829
  ? `exist_job_names="$(\n ${(0, common_1.gcloudRunCmd)()} jobs list --filter='metadata.name ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --project='${project}' --region='${region}'\n)"`
6864
6830
  : null,
6865
- `current_job_name="${jobName}"`,
6831
+ `current_job_name="${fullJobName}"`,
6866
6832
  'if grep "$current_job_name" <<<"$exist_job_names" >/dev/null; then',
6867
6833
  ` ${(0, common_1.gcloudRunCmd)()} jobs update "$current_job_name" ${commonDeployArgsString}`,
6868
6834
  "else",
@@ -6873,75 +6839,20 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
6873
6839
  .join("\n");
6874
6840
  });
6875
6841
  exports.getJobCreateScripts = getJobCreateScripts;
6876
- const getCreateScheduleScripts = (context) => {
6877
- const schedules = getSchedules(context);
6878
- const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
6879
- return schedules.map((scheduler, jobIndex) => {
6880
- var _a;
6881
- const uri = getSchedulerUrl(scheduler, context);
6882
- const argsString = (0, createArgsString_1.createArgsString)({
6883
- project,
6884
- location,
6885
- uri: `"$current_job_uri"`,
6886
- "http-method": "POST",
6887
- "oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
6888
- schedule: `"${scheduler.schedule}"`,
6889
- "max-retry-attempts": (_a = scheduler.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
6890
- });
6891
- return [
6892
- jobIndex === 0
6893
- ? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"`
6894
- : null,
6895
- `current_job_uri="${uri}"`,
6896
- `current_scheduler_name="${scheduler.name}"`,
6897
- `if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
6898
- ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
6899
- `else`,
6900
- ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`,
6901
- `fi`,
6902
- ]
6903
- .filter(utils_1.notNil)
6904
- .join("\n");
6905
- });
6906
- };
6907
- exports.getCreateScheduleScripts = getCreateScheduleScripts;
6908
- const getSchedulerUrl = (scheduler, context) => {
6909
- if (scheduler.type === "cloudRunJob") {
6910
- const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
6911
- const uriBase = `https://${location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${project}/jobs`;
6912
- return `${uriBase}/${scheduler.jobName}:run`;
6913
- }
6914
- throw new Error(`Unknown scheduler type: ${scheduler.type}`);
6915
- };
6916
- const getSchedules = (context) => {
6917
- const jobsWithNames = getCloudRunJobsWithNames(context);
6918
- return jobsWithNames
6919
- .filter((entry) => entry.job.when === "schedule")
6920
- .map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
6921
- const schedulerName = jobName.concat("-scheduler");
6922
- return {
6923
- name: schedulerName,
6924
- maxRetryAttempts,
6925
- schedule,
6926
- type: "cloudRunJob",
6927
- jobName,
6928
- };
6929
- });
6930
- };
6931
6842
  const getCloudRunJobsWithNames = (context) => {
6932
6843
  var _a;
6933
6844
  const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
6934
- const getFullJobName = (name) => (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
6935
6845
  const jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
6936
6846
  // filter out disabled jobs
6937
6847
  .filter((entry) => Boolean(entry[1]))
6938
- .map(([jobKey, job]) => ({
6939
- jobName: getFullJobName(jobKey),
6848
+ .map(([jobName, job]) => ({
6849
+ fullJobName: (0, jobName_1.getFullJobName)(context, jobName),
6940
6850
  job,
6941
- jobKey,
6851
+ jobName,
6942
6852
  }));
6943
6853
  return jobsWithNames;
6944
6854
  };
6855
+ exports.getCloudRunJobsWithNames = getCloudRunJobsWithNames;
6945
6856
  //# sourceMappingURL=cloudRunJobs.js.map
6946
6857
 
6947
6858
  /***/ }),
@@ -7093,6 +7004,241 @@ exports.ENV_VARS_FILENAME = "____envvars.yaml";
7093
7004
 
7094
7005
  /***/ }),
7095
7006
 
7007
+ /***/ 2358:
7008
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7009
+
7010
+ "use strict";
7011
+
7012
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7013
+ exports.getCloudRunJobArgsArg = exports.getOnDeployExecuteScript = void 0;
7014
+ const createArgsString_1 = __nccwpck_require__(49598);
7015
+ const jobName_1 = __nccwpck_require__(9626);
7016
+ const cloudRunJobs_1 = __nccwpck_require__(61224);
7017
+ const common_1 = __nccwpck_require__(73325);
7018
+ const getOnDeployExecuteScript = (context, when) => {
7019
+ const executes = getExecutes(context);
7020
+ return executes
7021
+ .filter(({ config }) => config.when === when)
7022
+ .map((execute) => {
7023
+ return getJobRunScriptForExecute(context, execute);
7024
+ });
7025
+ };
7026
+ exports.getOnDeployExecuteScript = getOnDeployExecuteScript;
7027
+ const getExecutes = (context) => {
7028
+ var _a;
7029
+ const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7030
+ return [
7031
+ ...getLegacyExecutes(context),
7032
+ ...Object.entries((_a = deployConfig.execute) !== null && _a !== void 0 ? _a : {}).flatMap(([key, value]) => {
7033
+ if (!value || (value.when !== "schedule" && value.type !== "job")) {
7034
+ return [];
7035
+ }
7036
+ return [
7037
+ {
7038
+ jobName: key,
7039
+ config: value,
7040
+ },
7041
+ ];
7042
+ }),
7043
+ ];
7044
+ };
7045
+ const getLegacyExecutes = (context) => {
7046
+ const jobsWithNames = (0, cloudRunJobs_1.getCloudRunJobsWithNames)(context);
7047
+ return jobsWithNames.flatMap(({ jobName, job }) => {
7048
+ if (!job.when ||
7049
+ !["preDeploy", "postDeploy", "preStop", "postStop"].includes(job.when)) {
7050
+ return [];
7051
+ }
7052
+ return [
7053
+ {
7054
+ jobName,
7055
+ config: {
7056
+ job: jobName,
7057
+ type: "job",
7058
+ when: job.when,
7059
+ ...(job.when === "preDeploy" || job.when === "postDeploy"
7060
+ ? {
7061
+ waitForCompletion: job.waitForCompletion,
7062
+ }
7063
+ : {}),
7064
+ },
7065
+ },
7066
+ ];
7067
+ });
7068
+ };
7069
+ const getJobRunScriptForExecute = (context, { jobName, config }) => {
7070
+ var _a;
7071
+ const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
7072
+ // always wait for completion for preStop and postStop jobs
7073
+ // since stop will delete the jobs afterwards, so they will fail
7074
+ const waitForCompletion = ["preStop", "postStop"].includes(config.when)
7075
+ ? true // always
7076
+ : "waitForCompletion" in config
7077
+ ? ((_a = config.waitForCompletion) !== null && _a !== void 0 ? _a : false) // depends on config
7078
+ : false;
7079
+ const argString = (0, createArgsString_1.createArgsString)({
7080
+ ...commonArgs,
7081
+ wait: waitForCompletion === true ? true : undefined,
7082
+ args: (0, exports.getCloudRunJobArgsArg)(config.args),
7083
+ });
7084
+ const fullJobName = (0, jobName_1.getFullJobName)(context, jobName);
7085
+ return `${(0, common_1.gcloudRunCmd)()} jobs execute ${fullJobName.toString()} ${argString}`;
7086
+ };
7087
+ const getCloudRunJobArgsArg = (args) => {
7088
+ return args !== undefined
7089
+ ? args.length > 0
7090
+ ? args === null || args === void 0 ? void 0 : args.map((arg) => `"${arg}"`).join(",")
7091
+ : ""
7092
+ : undefined;
7093
+ };
7094
+ exports.getCloudRunJobArgsArg = getCloudRunJobArgsArg;
7095
+ //# sourceMappingURL=onDeploy.js.map
7096
+
7097
+ /***/ }),
7098
+
7099
+ /***/ 3697:
7100
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7101
+
7102
+ "use strict";
7103
+
7104
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7105
+ exports.getCreateScheduleScript = exports.getDeleteSchedulesScript = void 0;
7106
+ const bash_1 = __nccwpck_require__(22990);
7107
+ const utils_1 = __nccwpck_require__(32497);
7108
+ const cloudRunExecutionUrl_1 = __nccwpck_require__(24856);
7109
+ const createArgsString_1 = __nccwpck_require__(49598);
7110
+ const jobName_1 = __nccwpck_require__(9626);
7111
+ const cloudRunJobs_1 = __nccwpck_require__(61224);
7112
+ const common_1 = __nccwpck_require__(73325);
7113
+ const getDeleteSchedulesScript = (context) => {
7114
+ const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7115
+ const schedules = getSchedules(context);
7116
+ const argsString = (0, createArgsString_1.createArgsString)({
7117
+ project: deployConfig.projectId,
7118
+ location: deployConfig.region,
7119
+ });
7120
+ return schedules
7121
+ .map(({ fullName }) => {
7122
+ return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${fullName} ${argsString}`];
7123
+ })
7124
+ .flat();
7125
+ };
7126
+ exports.getDeleteSchedulesScript = getDeleteSchedulesScript;
7127
+ const getCreateScheduleScript = (context) => {
7128
+ const schedules = getSchedules(context);
7129
+ const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
7130
+ return schedules.map(({ fullName, config }, jobIndex) => {
7131
+ var _a;
7132
+ const { uri, ...args } = getSchedulerArgs(config, context);
7133
+ const argsString = (0, createArgsString_1.createArgsString)({
7134
+ project,
7135
+ location,
7136
+ uri: `"$current_job_uri"`,
7137
+ ...args,
7138
+ schedule: `"${config.schedule}"`,
7139
+ "max-retry-attempts": (_a = config.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
7140
+ });
7141
+ return [
7142
+ jobIndex === 0
7143
+ ? `exist_scheduler_names="$(\n ${(0, common_1.gcloudSchedulerCmd)()} jobs list --filter='httpTarget.uri ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --location='${location}' --project='${project}'\n)"`
7144
+ : null,
7145
+ `current_job_uri="${uri}"`,
7146
+ `current_scheduler_name="${fullName}"`,
7147
+ `if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
7148
+ ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
7149
+ `else`,
7150
+ ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`,
7151
+ `fi`,
7152
+ ]
7153
+ .filter(utils_1.notNil)
7154
+ .join("\n");
7155
+ });
7156
+ };
7157
+ exports.getCreateScheduleScript = getCreateScheduleScript;
7158
+ const getSchedulerArgs = (scheduler, context) => {
7159
+ var _a;
7160
+ if (scheduler.type === "job") {
7161
+ const { projectId, region } = (0, common_1.getCloudRunDeployConfig)(context);
7162
+ const body = scheduler.args !== undefined
7163
+ ? {
7164
+ overrides: {
7165
+ containerOverrides: [
7166
+ ((_a = scheduler.args) === null || _a === void 0 ? void 0 : _a.length) > 0
7167
+ ? {
7168
+ args: scheduler.args,
7169
+ }
7170
+ : {
7171
+ args: [],
7172
+ clearArgs: true, // not sure why this is neeeded, but it is
7173
+ },
7174
+ ],
7175
+ },
7176
+ }
7177
+ : null;
7178
+ return {
7179
+ uri: (0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(scheduler.job, {
7180
+ appFullName: context.environment.fullName,
7181
+ projectId,
7182
+ region,
7183
+ }),
7184
+ "message-body": body
7185
+ ? '"' + (0, bash_1.bashEscape)(JSON.stringify(body)) + '"'
7186
+ : undefined,
7187
+ "http-method": "POST",
7188
+ "oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
7189
+ };
7190
+ }
7191
+ if (scheduler.type === "http") {
7192
+ return {
7193
+ uri: scheduler.url,
7194
+ "message-body": scheduler.body,
7195
+ "http-method": scheduler.method,
7196
+ "oidc-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
7197
+ };
7198
+ }
7199
+ throw new Error(`Unknown scheduler type: ${scheduler.type}`);
7200
+ };
7201
+ const getSchedules = (context) => {
7202
+ const legacyScheduleJobs = getLegacyJobSchedules(context);
7203
+ const schedules = getScheduledExecutes(context);
7204
+ return Object.entries({ ...legacyScheduleJobs, ...schedules }).map(([name, config]) => ({
7205
+ name,
7206
+ fullName: (0, jobName_1.getFullSchedulerName)(context, name),
7207
+ config,
7208
+ }));
7209
+ };
7210
+ const getLegacyJobSchedules = (context) => {
7211
+ const jobsWithNames = (0, cloudRunJobs_1.getCloudRunJobsWithNames)(context);
7212
+ return Object.fromEntries(jobsWithNames
7213
+ .filter((entry) => entry.job.when === "schedule")
7214
+ .map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
7215
+ const schedulerName = jobName.concat("-scheduler");
7216
+ return [
7217
+ schedulerName,
7218
+ {
7219
+ type: "job",
7220
+ job: jobName,
7221
+ maxRetryAttempts,
7222
+ schedule,
7223
+ when: "schedule",
7224
+ },
7225
+ ];
7226
+ }));
7227
+ };
7228
+ const getScheduledExecutes = (context) => {
7229
+ var _a;
7230
+ const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7231
+ return Object.fromEntries(Object.entries((_a = deployConfig.execute) !== null && _a !== void 0 ? _a : {}).flatMap(([key, value]) => {
7232
+ if (!value || value.when !== "schedule") {
7233
+ return [];
7234
+ }
7235
+ return [[key, value]];
7236
+ }));
7237
+ };
7238
+ //# sourceMappingURL=schedules.js.map
7239
+
7240
+ /***/ }),
7241
+
7096
7242
  /***/ 53695:
7097
7243
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7098
7244
 
@@ -7109,9 +7255,11 @@ const cleanup_1 = __nccwpck_require__(67888);
7109
7255
  const database_1 = __nccwpck_require__(28206);
7110
7256
  const gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(46320);
7111
7257
  const cloudRunJobs_1 = __nccwpck_require__(61224);
7258
+ const onDeploy_1 = __nccwpck_require__(2358);
7112
7259
  const cloudRunServices_1 = __nccwpck_require__(17334);
7113
7260
  const common_1 = __nccwpck_require__(73325);
7114
7261
  const constants_1 = __nccwpck_require__(38865);
7262
+ const schedules_1 = __nccwpck_require__(3697);
7115
7263
  function getCloudRunDeployScripts(context) {
7116
7264
  var _a;
7117
7265
  const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
@@ -7126,14 +7274,14 @@ function getCloudRunDeployScripts(context) {
7126
7274
  ...(deployConfig.cloudSql
7127
7275
  ? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
7128
7276
  : []),
7129
- ...(0, cloudRunJobs_1.getCreateScheduleScripts)(context),
7277
+ ...(0, schedules_1.getCreateScheduleScript)(context),
7130
7278
  ...(0, cloudRunJobs_1.getJobCreateScripts)(context),
7131
- ...(0, cloudRunJobs_1.getJobRunScripts)(context, "preDeploy"),
7279
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preDeploy"),
7132
7280
  ...(deployConfig.service !== false
7133
7281
  ? [(0, cloudRunServices_1.getServiceDeployScript)(context, deployConfig.service)]
7134
7282
  : []),
7135
7283
  ...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).map(([name, service]) => (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name)),
7136
- ...(0, cloudRunJobs_1.getJobRunScripts)(context, "postDeploy"),
7284
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postDeploy"),
7137
7285
  ]),
7138
7286
  ...(0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy")),
7139
7287
  ...(0, sbom_1.getDependencyTrackUploadScript)(context),
@@ -7156,6 +7304,8 @@ const cleanup_1 = __nccwpck_require__(67888);
7156
7304
  const database_1 = __nccwpck_require__(28206);
7157
7305
  const gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(46320);
7158
7306
  const cloudRunJobs_1 = __nccwpck_require__(61224);
7307
+ const onDeploy_1 = __nccwpck_require__(2358);
7308
+ const schedules_1 = __nccwpck_require__(3697);
7159
7309
  const cloudRunServices_1 = __nccwpck_require__(17334);
7160
7310
  const common_1 = __nccwpck_require__(73325);
7161
7311
  function getCloudRunStopScripts(context) {
@@ -7163,11 +7313,11 @@ function getCloudRunStopScripts(context) {
7163
7313
  const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
7164
7314
  return [
7165
7315
  ...(0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context),
7166
- ...(0, cloudRunJobs_1.getJobRunScripts)(context, "preStop"),
7316
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preStop"),
7167
7317
  ...(deployConfig.service !== false ? (0, cloudRunServices_1.getServiceDeleteScript)(context) : []),
7168
7318
  ...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).flatMap(([name]) => (0, cloudRunServices_1.getServiceDeleteScript)(context, name)),
7169
- ...(0, cloudRunJobs_1.getJobRunScripts)(context, "postStop"),
7170
- ...(0, cloudRunJobs_1.getDeleteSchedulesScripts)(context),
7319
+ ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postStop"),
7320
+ ...(0, schedules_1.getDeleteSchedulesScript)(context),
7171
7321
  ...(0, cloudRunJobs_1.getDeleteJobsScripts)(context),
7172
7322
  ...(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop
7173
7323
  ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig)
@@ -7272,8 +7422,8 @@ const context_1 = __nccwpck_require__(5875);
7272
7422
  const gitlab_1 = __nccwpck_require__(38490);
7273
7423
  const utils_1 = __nccwpck_require__(62089);
7274
7424
  const createJobs_1 = __nccwpck_require__(34069);
7425
+ const cloudRunExecutionUrl_1 = __nccwpck_require__(24856);
7275
7426
  const database_1 = __nccwpck_require__(28206);
7276
- const jobName_1 = __nccwpck_require__(9626);
7277
7427
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
7278
7428
  // FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
7279
7429
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
@@ -7329,7 +7479,11 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
7329
7479
  const jobTriggers = deployConfigRaw && deployConfigRaw.jobs
7330
7480
  ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(([name, job]) => [
7331
7481
  "CLOUD_RUN_JOB_TRIGGER_URL_" + (0, gitlab_1.sanitizeForBashVariable)(name),
7332
- `https://${deployConfigRaw.region}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${deployConfigRaw.projectId}/jobs/${(0, jobName_1.getCloudRunJobName)(fullName, name)}:run`,
7482
+ (0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(name, {
7483
+ appFullName: fullName,
7484
+ projectId: deployConfigRaw.projectId,
7485
+ region: deployConfigRaw.region,
7486
+ }),
7333
7487
  ]))
7334
7488
  : {};
7335
7489
  return {
@@ -7349,6 +7503,24 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
7349
7503
 
7350
7504
  /***/ }),
7351
7505
 
7506
+ /***/ 24856:
7507
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7508
+
7509
+ "use strict";
7510
+
7511
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7512
+ exports.getCloudRunJobExecuteUrl = void 0;
7513
+ const jobName_1 = __nccwpck_require__(9626);
7514
+ function getCloudRunJobExecuteUrl(jobName, { region, projectId, appFullName, }) {
7515
+ const uriBase = `https://${region}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${projectId}/jobs`;
7516
+ const fullJobName = (0, jobName_1.getCloudRunJobName)(appFullName, jobName);
7517
+ return `${uriBase}/${fullJobName}:run`;
7518
+ }
7519
+ exports.getCloudRunJobExecuteUrl = getCloudRunJobExecuteUrl;
7520
+ //# sourceMappingURL=cloudRunExecutionUrl.js.map
7521
+
7522
+ /***/ }),
7523
+
7352
7524
  /***/ 49598:
7353
7525
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7354
7526
 
@@ -7483,9 +7655,15 @@ exports.getServiceName = getServiceName;
7483
7655
  "use strict";
7484
7656
 
7485
7657
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7486
- exports.getCloudRunJobName = void 0;
7658
+ exports.getFullSchedulerName = exports.getCloudRunSchedulerName = exports.getFullJobName = exports.getCloudRunJobName = void 0;
7487
7659
  const getCloudRunJobName = (fullAppName, jobName) => fullAppName.toLowerCase().concat("-" + jobName.toLowerCase());
7488
7660
  exports.getCloudRunJobName = getCloudRunJobName;
7661
+ const getFullJobName = (context, name) => (0, exports.getCloudRunJobName)(context.environment.fullName, name);
7662
+ exports.getFullJobName = getFullJobName;
7663
+ const getCloudRunSchedulerName = (fullAppName, schedulerName) => fullAppName.toLowerCase().concat("-" + schedulerName.toLowerCase());
7664
+ exports.getCloudRunSchedulerName = getCloudRunSchedulerName;
7665
+ const getFullSchedulerName = (context, name) => (0, exports.getCloudRunSchedulerName)(context.environment.fullName, name);
7666
+ exports.getFullSchedulerName = getFullSchedulerName;
7489
7667
  //# sourceMappingURL=jobName.js.map
7490
7668
 
7491
7669
  /***/ }),
@@ -1,7 +1,9 @@
1
1
  import type { ComponentContext } from "../../../types/context";
2
2
  import type { DeployConfigCloudRunJob } from "../../types/googleCloudRun";
3
- export declare const getDeleteSchedulesScripts: (context: ComponentContext) => string[];
4
3
  export declare const getDeleteJobsScripts: (context: ComponentContext) => string[];
5
- export declare const getJobRunScripts: (context: ComponentContext, when: DeployConfigCloudRunJob["when"]) => string[];
6
4
  export declare const getJobCreateScripts: (context: ComponentContext) => string[];
7
- export declare const getCreateScheduleScripts: (context: ComponentContext) => string[];
5
+ export declare const getCloudRunJobsWithNames: (context: ComponentContext) => {
6
+ fullJobName: import("../../..").StringOrBashExpression;
7
+ job: DeployConfigCloudRunJob;
8
+ jobName: string;
9
+ }[];