@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.
- package/dist/bundles/catenv/index.js +292 -114
- package/dist/bundles/cli/index.js +292 -114
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +5 -3
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js +16 -105
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.d.ts +4 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js +85 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js.map +1 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.d.ts +3 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js +136 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js.map +1 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +5 -3
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +5 -3
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/index.js +6 -2
- package/dist/pipeline/src/deploy/cloudRun/index.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.d.ts +6 -0
- package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.js +11 -0
- package/dist/pipeline/src/deploy/cloudRun/utils/cloudRunExecutionUrl.js.map +1 -0
- package/dist/pipeline/src/deploy/cloudRun/utils/jobName.d.ts +5 -1
- package/dist/pipeline/src/deploy/cloudRun/utils/jobName.js +7 -1
- package/dist/pipeline/src/deploy/cloudRun/utils/jobName.js.map +1 -1
- package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +95 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -3841,62 +3841,27 @@ exports.getDeleteUnusedRevisionsCommands = getDeleteUnusedRevisionsCommands;
|
|
|
3841
3841
|
"use strict";
|
|
3842
3842
|
|
|
3843
3843
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3844
|
-
exports.
|
|
3844
|
+
exports.getCloudRunJobsWithNames = exports.getJobCreateScripts = exports.getDeleteJobsScripts = void 0;
|
|
3845
|
+
const getLabels_1 = __nccwpck_require__(920);
|
|
3846
|
+
const utils_1 = __nccwpck_require__(2497);
|
|
3845
3847
|
const createArgsString_1 = __nccwpck_require__(9598);
|
|
3846
3848
|
const jobName_1 = __nccwpck_require__(9626);
|
|
3847
3849
|
const common_1 = __nccwpck_require__(3325);
|
|
3848
|
-
const getLabels_1 = __nccwpck_require__(920);
|
|
3849
|
-
const volumes_1 = __nccwpck_require__(847);
|
|
3850
3850
|
const constants_1 = __nccwpck_require__(8865);
|
|
3851
|
-
const
|
|
3852
|
-
const
|
|
3853
|
-
const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
3854
|
-
const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
3855
|
-
return `${(0, common_1.gcloudRunCmd)()} jobs execute ${jobName.toString()} ${commonArgsString}${wait ? " --wait" : ""}`;
|
|
3856
|
-
};
|
|
3857
|
-
const getDeleteSchedulesScripts = (context) => {
|
|
3858
|
-
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
3859
|
-
const schedules = getSchedules(context);
|
|
3860
|
-
const argsString = (0, createArgsString_1.createArgsString)({
|
|
3861
|
-
project: deployConfig.projectId,
|
|
3862
|
-
location: deployConfig.region,
|
|
3863
|
-
});
|
|
3864
|
-
return schedules
|
|
3865
|
-
.map(({ name }) => {
|
|
3866
|
-
return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${name} ${argsString}`];
|
|
3867
|
-
})
|
|
3868
|
-
.flat();
|
|
3869
|
-
};
|
|
3870
|
-
exports.getDeleteSchedulesScripts = getDeleteSchedulesScripts;
|
|
3851
|
+
const volumes_1 = __nccwpck_require__(847);
|
|
3852
|
+
const onDeploy_1 = __nccwpck_require__(2358);
|
|
3871
3853
|
const getDeleteJobsScripts = (context) => {
|
|
3872
3854
|
const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
3873
3855
|
const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs);
|
|
3874
|
-
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
3875
|
-
return jobsWithNames.flatMap(({
|
|
3856
|
+
const jobsWithNames = (0, exports.getCloudRunJobsWithNames)(context);
|
|
3857
|
+
return jobsWithNames.flatMap(({ fullJobName }) => [
|
|
3876
3858
|
// first delete all job executions. Otherwise delete might fail if one of those is still running
|
|
3877
|
-
`${(0, common_1.gcloudRunCmd)()} jobs executions list ${commonArgsString} --job ${
|
|
3878
|
-
`${(0, common_1.gcloudRunCmd)()} jobs delete ${
|
|
3859
|
+
`${(0, common_1.gcloudRunCmd)()} jobs executions list ${commonArgsString} --job ${fullJobName} --format="value(name)" | xargs -I {} ${(0, common_1.gcloudRunCmd)()} jobs executions delete {} --quiet ${commonArgsString}`,
|
|
3860
|
+
`${(0, common_1.gcloudRunCmd)()} jobs delete ${fullJobName} ${commonArgsString}`,
|
|
3879
3861
|
]);
|
|
3880
3862
|
};
|
|
3881
3863
|
exports.getDeleteJobsScripts = getDeleteJobsScripts;
|
|
3882
|
-
const
|
|
3883
|
-
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
3884
|
-
return jobsWithNames
|
|
3885
|
-
.filter(({ job }) => job.when === when)
|
|
3886
|
-
.map(({ jobName, job }) => {
|
|
3887
|
-
var _a;
|
|
3888
|
-
// always wait for completion for preStop and postStop jobs
|
|
3889
|
-
// since stop will delete the jobs afterwards, so they will fail
|
|
3890
|
-
const waitForCompletion = ["preStop", "postStop"].includes(when)
|
|
3891
|
-
? true
|
|
3892
|
-
: "waitForCompletion" in job
|
|
3893
|
-
? ((_a = job.waitForCompletion) !== null && _a !== void 0 ? _a : false)
|
|
3894
|
-
: false;
|
|
3895
|
-
return getJobRunScriptForJob(context, jobName, waitForCompletion);
|
|
3896
|
-
});
|
|
3897
|
-
};
|
|
3898
|
-
exports.getJobRunScripts = getJobRunScripts;
|
|
3899
|
-
const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map(({ job, jobName }, jobIndex) => {
|
|
3864
|
+
const getJobCreateScripts = (context) => (0, exports.getCloudRunJobsWithNames)(context).map(({ job, fullJobName }, jobIndex) => {
|
|
3900
3865
|
var _a, _b, _c, _d;
|
|
3901
3866
|
const commandArray = Array.isArray(job.command)
|
|
3902
3867
|
? job.command
|
|
@@ -3904,6 +3869,7 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
|
|
|
3904
3869
|
const { image: commonImage, project, region, ...deployArgs } = (0, common_1.getCommonDeployArgs)(context);
|
|
3905
3870
|
const commonDeployArgsString = (0, createArgsString_1.createArgsString)({
|
|
3906
3871
|
command: `"${commandArray.join(",")}"`,
|
|
3872
|
+
args: (0, onDeploy_1.getCloudRunJobArgsArg)(job.args),
|
|
3907
3873
|
labels: `"${(0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context))},cloud-run-job-name=$current_job_name"`,
|
|
3908
3874
|
image: `"${(_a = job.image) !== null && _a !== void 0 ? _a : commonImage}"`,
|
|
3909
3875
|
project,
|
|
@@ -3925,7 +3891,7 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
|
|
|
3925
3891
|
jobIndex === 0
|
|
3926
3892
|
? `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)"`
|
|
3927
3893
|
: null,
|
|
3928
|
-
`current_job_name="${
|
|
3894
|
+
`current_job_name="${fullJobName}"`,
|
|
3929
3895
|
'if grep "$current_job_name" <<<"$exist_job_names" >/dev/null; then',
|
|
3930
3896
|
` ${(0, common_1.gcloudRunCmd)()} jobs update "$current_job_name" ${commonDeployArgsString}`,
|
|
3931
3897
|
"else",
|
|
@@ -3936,75 +3902,20 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
|
|
|
3936
3902
|
.join("\n");
|
|
3937
3903
|
});
|
|
3938
3904
|
exports.getJobCreateScripts = getJobCreateScripts;
|
|
3939
|
-
const getCreateScheduleScripts = (context) => {
|
|
3940
|
-
const schedules = getSchedules(context);
|
|
3941
|
-
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
3942
|
-
return schedules.map((scheduler, jobIndex) => {
|
|
3943
|
-
var _a;
|
|
3944
|
-
const uri = getSchedulerUrl(scheduler, context);
|
|
3945
|
-
const argsString = (0, createArgsString_1.createArgsString)({
|
|
3946
|
-
project,
|
|
3947
|
-
location,
|
|
3948
|
-
uri: `"$current_job_uri"`,
|
|
3949
|
-
"http-method": "POST",
|
|
3950
|
-
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
3951
|
-
schedule: `"${scheduler.schedule}"`,
|
|
3952
|
-
"max-retry-attempts": (_a = scheduler.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
|
|
3953
|
-
});
|
|
3954
|
-
return [
|
|
3955
|
-
jobIndex === 0
|
|
3956
|
-
? `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)"`
|
|
3957
|
-
: null,
|
|
3958
|
-
`current_job_uri="${uri}"`,
|
|
3959
|
-
`current_scheduler_name="${scheduler.name}"`,
|
|
3960
|
-
`if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
|
|
3961
|
-
` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
|
|
3962
|
-
`else`,
|
|
3963
|
-
` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`,
|
|
3964
|
-
`fi`,
|
|
3965
|
-
]
|
|
3966
|
-
.filter(utils_1.notNil)
|
|
3967
|
-
.join("\n");
|
|
3968
|
-
});
|
|
3969
|
-
};
|
|
3970
|
-
exports.getCreateScheduleScripts = getCreateScheduleScripts;
|
|
3971
|
-
const getSchedulerUrl = (scheduler, context) => {
|
|
3972
|
-
if (scheduler.type === "cloudRunJob") {
|
|
3973
|
-
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
3974
|
-
const uriBase = `https://${location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${project}/jobs`;
|
|
3975
|
-
return `${uriBase}/${scheduler.jobName}:run`;
|
|
3976
|
-
}
|
|
3977
|
-
throw new Error(`Unknown scheduler type: ${scheduler.type}`);
|
|
3978
|
-
};
|
|
3979
|
-
const getSchedules = (context) => {
|
|
3980
|
-
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
3981
|
-
return jobsWithNames
|
|
3982
|
-
.filter((entry) => entry.job.when === "schedule")
|
|
3983
|
-
.map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
|
|
3984
|
-
const schedulerName = jobName.concat("-scheduler");
|
|
3985
|
-
return {
|
|
3986
|
-
name: schedulerName,
|
|
3987
|
-
maxRetryAttempts,
|
|
3988
|
-
schedule,
|
|
3989
|
-
type: "cloudRunJob",
|
|
3990
|
-
jobName,
|
|
3991
|
-
};
|
|
3992
|
-
});
|
|
3993
|
-
};
|
|
3994
3905
|
const getCloudRunJobsWithNames = (context) => {
|
|
3995
3906
|
var _a;
|
|
3996
3907
|
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
3997
|
-
const getFullJobName = (name) => (0, jobName_1.getCloudRunJobName)(context.environment.fullName, name);
|
|
3998
3908
|
const jobsWithNames = Object.entries((_a = deployConfig.jobs) !== null && _a !== void 0 ? _a : {})
|
|
3999
3909
|
// filter out disabled jobs
|
|
4000
3910
|
.filter((entry) => Boolean(entry[1]))
|
|
4001
|
-
.map(([
|
|
4002
|
-
|
|
3911
|
+
.map(([jobName, job]) => ({
|
|
3912
|
+
fullJobName: (0, jobName_1.getFullJobName)(context, jobName),
|
|
4003
3913
|
job,
|
|
4004
|
-
|
|
3914
|
+
jobName,
|
|
4005
3915
|
}));
|
|
4006
3916
|
return jobsWithNames;
|
|
4007
3917
|
};
|
|
3918
|
+
exports.getCloudRunJobsWithNames = getCloudRunJobsWithNames;
|
|
4008
3919
|
//# sourceMappingURL=cloudRunJobs.js.map
|
|
4009
3920
|
|
|
4010
3921
|
/***/ }),
|
|
@@ -4156,6 +4067,241 @@ exports.ENV_VARS_FILENAME = "____envvars.yaml";
|
|
|
4156
4067
|
|
|
4157
4068
|
/***/ }),
|
|
4158
4069
|
|
|
4070
|
+
/***/ 2358:
|
|
4071
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4072
|
+
|
|
4073
|
+
"use strict";
|
|
4074
|
+
|
|
4075
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4076
|
+
exports.getCloudRunJobArgsArg = exports.getOnDeployExecuteScript = void 0;
|
|
4077
|
+
const createArgsString_1 = __nccwpck_require__(9598);
|
|
4078
|
+
const jobName_1 = __nccwpck_require__(9626);
|
|
4079
|
+
const cloudRunJobs_1 = __nccwpck_require__(1224);
|
|
4080
|
+
const common_1 = __nccwpck_require__(3325);
|
|
4081
|
+
const getOnDeployExecuteScript = (context, when) => {
|
|
4082
|
+
const executes = getExecutes(context);
|
|
4083
|
+
return executes
|
|
4084
|
+
.filter(({ config }) => config.when === when)
|
|
4085
|
+
.map((execute) => {
|
|
4086
|
+
return getJobRunScriptForExecute(context, execute);
|
|
4087
|
+
});
|
|
4088
|
+
};
|
|
4089
|
+
exports.getOnDeployExecuteScript = getOnDeployExecuteScript;
|
|
4090
|
+
const getExecutes = (context) => {
|
|
4091
|
+
var _a;
|
|
4092
|
+
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
4093
|
+
return [
|
|
4094
|
+
...getLegacyExecutes(context),
|
|
4095
|
+
...Object.entries((_a = deployConfig.execute) !== null && _a !== void 0 ? _a : {}).flatMap(([key, value]) => {
|
|
4096
|
+
if (!value || (value.when !== "schedule" && value.type !== "job")) {
|
|
4097
|
+
return [];
|
|
4098
|
+
}
|
|
4099
|
+
return [
|
|
4100
|
+
{
|
|
4101
|
+
jobName: key,
|
|
4102
|
+
config: value,
|
|
4103
|
+
},
|
|
4104
|
+
];
|
|
4105
|
+
}),
|
|
4106
|
+
];
|
|
4107
|
+
};
|
|
4108
|
+
const getLegacyExecutes = (context) => {
|
|
4109
|
+
const jobsWithNames = (0, cloudRunJobs_1.getCloudRunJobsWithNames)(context);
|
|
4110
|
+
return jobsWithNames.flatMap(({ jobName, job }) => {
|
|
4111
|
+
if (!job.when ||
|
|
4112
|
+
!["preDeploy", "postDeploy", "preStop", "postStop"].includes(job.when)) {
|
|
4113
|
+
return [];
|
|
4114
|
+
}
|
|
4115
|
+
return [
|
|
4116
|
+
{
|
|
4117
|
+
jobName,
|
|
4118
|
+
config: {
|
|
4119
|
+
job: jobName,
|
|
4120
|
+
type: "job",
|
|
4121
|
+
when: job.when,
|
|
4122
|
+
...(job.when === "preDeploy" || job.when === "postDeploy"
|
|
4123
|
+
? {
|
|
4124
|
+
waitForCompletion: job.waitForCompletion,
|
|
4125
|
+
}
|
|
4126
|
+
: {}),
|
|
4127
|
+
},
|
|
4128
|
+
},
|
|
4129
|
+
];
|
|
4130
|
+
});
|
|
4131
|
+
};
|
|
4132
|
+
const getJobRunScriptForExecute = (context, { jobName, config }) => {
|
|
4133
|
+
var _a;
|
|
4134
|
+
const commonArgs = (0, common_1.getCommonCloudRunArgs)(context);
|
|
4135
|
+
// always wait for completion for preStop and postStop jobs
|
|
4136
|
+
// since stop will delete the jobs afterwards, so they will fail
|
|
4137
|
+
const waitForCompletion = ["preStop", "postStop"].includes(config.when)
|
|
4138
|
+
? true // always
|
|
4139
|
+
: "waitForCompletion" in config
|
|
4140
|
+
? ((_a = config.waitForCompletion) !== null && _a !== void 0 ? _a : false) // depends on config
|
|
4141
|
+
: false;
|
|
4142
|
+
const argString = (0, createArgsString_1.createArgsString)({
|
|
4143
|
+
...commonArgs,
|
|
4144
|
+
wait: waitForCompletion === true ? true : undefined,
|
|
4145
|
+
args: (0, exports.getCloudRunJobArgsArg)(config.args),
|
|
4146
|
+
});
|
|
4147
|
+
const fullJobName = (0, jobName_1.getFullJobName)(context, jobName);
|
|
4148
|
+
return `${(0, common_1.gcloudRunCmd)()} jobs execute ${fullJobName.toString()} ${argString}`;
|
|
4149
|
+
};
|
|
4150
|
+
const getCloudRunJobArgsArg = (args) => {
|
|
4151
|
+
return args !== undefined
|
|
4152
|
+
? args.length > 0
|
|
4153
|
+
? args === null || args === void 0 ? void 0 : args.map((arg) => `"${arg}"`).join(",")
|
|
4154
|
+
: ""
|
|
4155
|
+
: undefined;
|
|
4156
|
+
};
|
|
4157
|
+
exports.getCloudRunJobArgsArg = getCloudRunJobArgsArg;
|
|
4158
|
+
//# sourceMappingURL=onDeploy.js.map
|
|
4159
|
+
|
|
4160
|
+
/***/ }),
|
|
4161
|
+
|
|
4162
|
+
/***/ 3697:
|
|
4163
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4164
|
+
|
|
4165
|
+
"use strict";
|
|
4166
|
+
|
|
4167
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4168
|
+
exports.getCreateScheduleScript = exports.getDeleteSchedulesScript = void 0;
|
|
4169
|
+
const bash_1 = __nccwpck_require__(2990);
|
|
4170
|
+
const utils_1 = __nccwpck_require__(2497);
|
|
4171
|
+
const cloudRunExecutionUrl_1 = __nccwpck_require__(4856);
|
|
4172
|
+
const createArgsString_1 = __nccwpck_require__(9598);
|
|
4173
|
+
const jobName_1 = __nccwpck_require__(9626);
|
|
4174
|
+
const cloudRunJobs_1 = __nccwpck_require__(1224);
|
|
4175
|
+
const common_1 = __nccwpck_require__(3325);
|
|
4176
|
+
const getDeleteSchedulesScript = (context) => {
|
|
4177
|
+
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
4178
|
+
const schedules = getSchedules(context);
|
|
4179
|
+
const argsString = (0, createArgsString_1.createArgsString)({
|
|
4180
|
+
project: deployConfig.projectId,
|
|
4181
|
+
location: deployConfig.region,
|
|
4182
|
+
});
|
|
4183
|
+
return schedules
|
|
4184
|
+
.map(({ fullName }) => {
|
|
4185
|
+
return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${fullName} ${argsString}`];
|
|
4186
|
+
})
|
|
4187
|
+
.flat();
|
|
4188
|
+
};
|
|
4189
|
+
exports.getDeleteSchedulesScript = getDeleteSchedulesScript;
|
|
4190
|
+
const getCreateScheduleScript = (context) => {
|
|
4191
|
+
const schedules = getSchedules(context);
|
|
4192
|
+
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
4193
|
+
return schedules.map(({ fullName, config }, jobIndex) => {
|
|
4194
|
+
var _a;
|
|
4195
|
+
const { uri, ...args } = getSchedulerArgs(config, context);
|
|
4196
|
+
const argsString = (0, createArgsString_1.createArgsString)({
|
|
4197
|
+
project,
|
|
4198
|
+
location,
|
|
4199
|
+
uri: `"$current_job_uri"`,
|
|
4200
|
+
...args,
|
|
4201
|
+
schedule: `"${config.schedule}"`,
|
|
4202
|
+
"max-retry-attempts": (_a = config.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
|
|
4203
|
+
});
|
|
4204
|
+
return [
|
|
4205
|
+
jobIndex === 0
|
|
4206
|
+
? `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)"`
|
|
4207
|
+
: null,
|
|
4208
|
+
`current_job_uri="${uri}"`,
|
|
4209
|
+
`current_scheduler_name="${fullName}"`,
|
|
4210
|
+
`if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
|
|
4211
|
+
` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
|
|
4212
|
+
`else`,
|
|
4213
|
+
` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`,
|
|
4214
|
+
`fi`,
|
|
4215
|
+
]
|
|
4216
|
+
.filter(utils_1.notNil)
|
|
4217
|
+
.join("\n");
|
|
4218
|
+
});
|
|
4219
|
+
};
|
|
4220
|
+
exports.getCreateScheduleScript = getCreateScheduleScript;
|
|
4221
|
+
const getSchedulerArgs = (scheduler, context) => {
|
|
4222
|
+
var _a;
|
|
4223
|
+
if (scheduler.type === "job") {
|
|
4224
|
+
const { projectId, region } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
4225
|
+
const body = scheduler.args !== undefined
|
|
4226
|
+
? {
|
|
4227
|
+
overrides: {
|
|
4228
|
+
containerOverrides: [
|
|
4229
|
+
((_a = scheduler.args) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
4230
|
+
? {
|
|
4231
|
+
args: scheduler.args,
|
|
4232
|
+
}
|
|
4233
|
+
: {
|
|
4234
|
+
args: [],
|
|
4235
|
+
clearArgs: true, // not sure why this is neeeded, but it is
|
|
4236
|
+
},
|
|
4237
|
+
],
|
|
4238
|
+
},
|
|
4239
|
+
}
|
|
4240
|
+
: null;
|
|
4241
|
+
return {
|
|
4242
|
+
uri: (0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(scheduler.job, {
|
|
4243
|
+
appFullName: context.environment.fullName,
|
|
4244
|
+
projectId,
|
|
4245
|
+
region,
|
|
4246
|
+
}),
|
|
4247
|
+
"message-body": body
|
|
4248
|
+
? '"' + (0, bash_1.bashEscape)(JSON.stringify(body)) + '"'
|
|
4249
|
+
: undefined,
|
|
4250
|
+
"http-method": "POST",
|
|
4251
|
+
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
4252
|
+
};
|
|
4253
|
+
}
|
|
4254
|
+
if (scheduler.type === "http") {
|
|
4255
|
+
return {
|
|
4256
|
+
uri: scheduler.url,
|
|
4257
|
+
"message-body": scheduler.body,
|
|
4258
|
+
"http-method": scheduler.method,
|
|
4259
|
+
"oidc-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
4260
|
+
};
|
|
4261
|
+
}
|
|
4262
|
+
throw new Error(`Unknown scheduler type: ${scheduler.type}`);
|
|
4263
|
+
};
|
|
4264
|
+
const getSchedules = (context) => {
|
|
4265
|
+
const legacyScheduleJobs = getLegacyJobSchedules(context);
|
|
4266
|
+
const schedules = getScheduledExecutes(context);
|
|
4267
|
+
return Object.entries({ ...legacyScheduleJobs, ...schedules }).map(([name, config]) => ({
|
|
4268
|
+
name,
|
|
4269
|
+
fullName: (0, jobName_1.getFullSchedulerName)(context, name),
|
|
4270
|
+
config,
|
|
4271
|
+
}));
|
|
4272
|
+
};
|
|
4273
|
+
const getLegacyJobSchedules = (context) => {
|
|
4274
|
+
const jobsWithNames = (0, cloudRunJobs_1.getCloudRunJobsWithNames)(context);
|
|
4275
|
+
return Object.fromEntries(jobsWithNames
|
|
4276
|
+
.filter((entry) => entry.job.when === "schedule")
|
|
4277
|
+
.map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
|
|
4278
|
+
const schedulerName = jobName.concat("-scheduler");
|
|
4279
|
+
return [
|
|
4280
|
+
schedulerName,
|
|
4281
|
+
{
|
|
4282
|
+
type: "job",
|
|
4283
|
+
job: jobName,
|
|
4284
|
+
maxRetryAttempts,
|
|
4285
|
+
schedule,
|
|
4286
|
+
when: "schedule",
|
|
4287
|
+
},
|
|
4288
|
+
];
|
|
4289
|
+
}));
|
|
4290
|
+
};
|
|
4291
|
+
const getScheduledExecutes = (context) => {
|
|
4292
|
+
var _a;
|
|
4293
|
+
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
4294
|
+
return Object.fromEntries(Object.entries((_a = deployConfig.execute) !== null && _a !== void 0 ? _a : {}).flatMap(([key, value]) => {
|
|
4295
|
+
if (!value || value.when !== "schedule") {
|
|
4296
|
+
return [];
|
|
4297
|
+
}
|
|
4298
|
+
return [[key, value]];
|
|
4299
|
+
}));
|
|
4300
|
+
};
|
|
4301
|
+
//# sourceMappingURL=schedules.js.map
|
|
4302
|
+
|
|
4303
|
+
/***/ }),
|
|
4304
|
+
|
|
4159
4305
|
/***/ 3695:
|
|
4160
4306
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4161
4307
|
|
|
@@ -4172,9 +4318,11 @@ const cleanup_1 = __nccwpck_require__(7888);
|
|
|
4172
4318
|
const database_1 = __nccwpck_require__(8206);
|
|
4173
4319
|
const gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(6320);
|
|
4174
4320
|
const cloudRunJobs_1 = __nccwpck_require__(1224);
|
|
4321
|
+
const onDeploy_1 = __nccwpck_require__(2358);
|
|
4175
4322
|
const cloudRunServices_1 = __nccwpck_require__(7334);
|
|
4176
4323
|
const common_1 = __nccwpck_require__(3325);
|
|
4177
4324
|
const constants_1 = __nccwpck_require__(8865);
|
|
4325
|
+
const schedules_1 = __nccwpck_require__(3697);
|
|
4178
4326
|
function getCloudRunDeployScripts(context) {
|
|
4179
4327
|
var _a;
|
|
4180
4328
|
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
@@ -4189,14 +4337,14 @@ function getCloudRunDeployScripts(context) {
|
|
|
4189
4337
|
...(deployConfig.cloudSql
|
|
4190
4338
|
? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
4191
4339
|
: []),
|
|
4192
|
-
...(0,
|
|
4340
|
+
...(0, schedules_1.getCreateScheduleScript)(context),
|
|
4193
4341
|
...(0, cloudRunJobs_1.getJobCreateScripts)(context),
|
|
4194
|
-
...(0,
|
|
4342
|
+
...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preDeploy"),
|
|
4195
4343
|
...(deployConfig.service !== false
|
|
4196
4344
|
? [(0, cloudRunServices_1.getServiceDeployScript)(context, deployConfig.service)]
|
|
4197
4345
|
: []),
|
|
4198
4346
|
...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).map(([name, service]) => (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name)),
|
|
4199
|
-
...(0,
|
|
4347
|
+
...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postDeploy"),
|
|
4200
4348
|
]),
|
|
4201
4349
|
...(0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy")),
|
|
4202
4350
|
...(0, sbom_1.getDependencyTrackUploadScript)(context),
|
|
@@ -4219,6 +4367,8 @@ const cleanup_1 = __nccwpck_require__(7888);
|
|
|
4219
4367
|
const database_1 = __nccwpck_require__(8206);
|
|
4220
4368
|
const gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(6320);
|
|
4221
4369
|
const cloudRunJobs_1 = __nccwpck_require__(1224);
|
|
4370
|
+
const onDeploy_1 = __nccwpck_require__(2358);
|
|
4371
|
+
const schedules_1 = __nccwpck_require__(3697);
|
|
4222
4372
|
const cloudRunServices_1 = __nccwpck_require__(7334);
|
|
4223
4373
|
const common_1 = __nccwpck_require__(3325);
|
|
4224
4374
|
function getCloudRunStopScripts(context) {
|
|
@@ -4226,11 +4376,11 @@ function getCloudRunStopScripts(context) {
|
|
|
4226
4376
|
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
4227
4377
|
return [
|
|
4228
4378
|
...(0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context),
|
|
4229
|
-
...(0,
|
|
4379
|
+
...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preStop"),
|
|
4230
4380
|
...(deployConfig.service !== false ? (0, cloudRunServices_1.getServiceDeleteScript)(context) : []),
|
|
4231
4381
|
...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).flatMap(([name]) => (0, cloudRunServices_1.getServiceDeleteScript)(context, name)),
|
|
4232
|
-
...(0,
|
|
4233
|
-
...(0,
|
|
4382
|
+
...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postStop"),
|
|
4383
|
+
...(0, schedules_1.getDeleteSchedulesScript)(context),
|
|
4234
4384
|
...(0, cloudRunJobs_1.getDeleteJobsScripts)(context),
|
|
4235
4385
|
...(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop
|
|
4236
4386
|
? (0, database_1.getDatabaseDeleteScript)(context, deployConfig)
|
|
@@ -4335,8 +4485,8 @@ const context_1 = __nccwpck_require__(5875);
|
|
|
4335
4485
|
const gitlab_1 = __nccwpck_require__(8490);
|
|
4336
4486
|
const utils_1 = __nccwpck_require__(2089);
|
|
4337
4487
|
const createJobs_1 = __nccwpck_require__(4069);
|
|
4488
|
+
const cloudRunExecutionUrl_1 = __nccwpck_require__(4856);
|
|
4338
4489
|
const database_1 = __nccwpck_require__(8206);
|
|
4339
|
-
const jobName_1 = __nccwpck_require__(9626);
|
|
4340
4490
|
exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
|
|
4341
4491
|
// FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
|
|
4342
4492
|
exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
|
|
@@ -4392,7 +4542,11 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
|
|
|
4392
4542
|
const jobTriggers = deployConfigRaw && deployConfigRaw.jobs
|
|
4393
4543
|
? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(([name, job]) => [
|
|
4394
4544
|
"CLOUD_RUN_JOB_TRIGGER_URL_" + (0, gitlab_1.sanitizeForBashVariable)(name),
|
|
4395
|
-
|
|
4545
|
+
(0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(name, {
|
|
4546
|
+
appFullName: fullName,
|
|
4547
|
+
projectId: deployConfigRaw.projectId,
|
|
4548
|
+
region: deployConfigRaw.region,
|
|
4549
|
+
}),
|
|
4396
4550
|
]))
|
|
4397
4551
|
: {};
|
|
4398
4552
|
return {
|
|
@@ -4412,6 +4566,24 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
|
|
|
4412
4566
|
|
|
4413
4567
|
/***/ }),
|
|
4414
4568
|
|
|
4569
|
+
/***/ 4856:
|
|
4570
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4571
|
+
|
|
4572
|
+
"use strict";
|
|
4573
|
+
|
|
4574
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4575
|
+
exports.getCloudRunJobExecuteUrl = void 0;
|
|
4576
|
+
const jobName_1 = __nccwpck_require__(9626);
|
|
4577
|
+
function getCloudRunJobExecuteUrl(jobName, { region, projectId, appFullName, }) {
|
|
4578
|
+
const uriBase = `https://${region}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${projectId}/jobs`;
|
|
4579
|
+
const fullJobName = (0, jobName_1.getCloudRunJobName)(appFullName, jobName);
|
|
4580
|
+
return `${uriBase}/${fullJobName}:run`;
|
|
4581
|
+
}
|
|
4582
|
+
exports.getCloudRunJobExecuteUrl = getCloudRunJobExecuteUrl;
|
|
4583
|
+
//# sourceMappingURL=cloudRunExecutionUrl.js.map
|
|
4584
|
+
|
|
4585
|
+
/***/ }),
|
|
4586
|
+
|
|
4415
4587
|
/***/ 9598:
|
|
4416
4588
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4417
4589
|
|
|
@@ -4546,9 +4718,15 @@ exports.getServiceName = getServiceName;
|
|
|
4546
4718
|
"use strict";
|
|
4547
4719
|
|
|
4548
4720
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4549
|
-
exports.getCloudRunJobName = void 0;
|
|
4721
|
+
exports.getFullSchedulerName = exports.getCloudRunSchedulerName = exports.getFullJobName = exports.getCloudRunJobName = void 0;
|
|
4550
4722
|
const getCloudRunJobName = (fullAppName, jobName) => fullAppName.toLowerCase().concat("-" + jobName.toLowerCase());
|
|
4551
4723
|
exports.getCloudRunJobName = getCloudRunJobName;
|
|
4724
|
+
const getFullJobName = (context, name) => (0, exports.getCloudRunJobName)(context.environment.fullName, name);
|
|
4725
|
+
exports.getFullJobName = getFullJobName;
|
|
4726
|
+
const getCloudRunSchedulerName = (fullAppName, schedulerName) => fullAppName.toLowerCase().concat("-" + schedulerName.toLowerCase());
|
|
4727
|
+
exports.getCloudRunSchedulerName = getCloudRunSchedulerName;
|
|
4728
|
+
const getFullSchedulerName = (context, name) => (0, exports.getCloudRunSchedulerName)(context.environment.fullName, name);
|
|
4729
|
+
exports.getFullSchedulerName = getFullSchedulerName;
|
|
4552
4730
|
//# sourceMappingURL=jobName.js.map
|
|
4553
4731
|
|
|
4554
4732
|
/***/ }),
|