@catladder/cli 0.0.0-main-c2f81f59 → 0.0.0-main-877fa9b2
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 +52 -38
- package/dist/bundles/cli/index.js +52 -38
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js +52 -38
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js.map +1 -1
- package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +14 -12
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -3854,16 +3854,14 @@ const getJobRunScriptForJob = (context, jobName, wait) => {
|
|
|
3854
3854
|
};
|
|
3855
3855
|
const getDeleteSchedulesScripts = (context) => {
|
|
3856
3856
|
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
3857
|
-
const
|
|
3857
|
+
const schedules = getSchedules(context);
|
|
3858
3858
|
const argsString = (0, createArgsString_1.createArgsString)({
|
|
3859
3859
|
project: deployConfig.projectId,
|
|
3860
3860
|
location: deployConfig.region,
|
|
3861
3861
|
});
|
|
3862
|
-
return
|
|
3863
|
-
.map(({
|
|
3864
|
-
return [
|
|
3865
|
-
`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${schedulerName} ${argsString}`,
|
|
3866
|
-
];
|
|
3862
|
+
return schedules
|
|
3863
|
+
.map(({ name }) => {
|
|
3864
|
+
return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${name} ${argsString}`];
|
|
3867
3865
|
})
|
|
3868
3866
|
.flat();
|
|
3869
3867
|
};
|
|
@@ -3896,25 +3894,31 @@ const getJobRunScripts = (context, when) => {
|
|
|
3896
3894
|
});
|
|
3897
3895
|
};
|
|
3898
3896
|
exports.getJobRunScripts = getJobRunScripts;
|
|
3899
|
-
const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map(({ job
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3897
|
+
const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map(({ job, jobName }, jobIndex) => {
|
|
3898
|
+
var _a, _b, _c, _d;
|
|
3899
|
+
const commandArray = Array.isArray(job.command)
|
|
3900
|
+
? job.command
|
|
3901
|
+
: job.command.split(" ");
|
|
3903
3902
|
const { image: commonImage, project, region, ...deployArgs } = (0, common_1.getCommonDeployArgs)(context);
|
|
3904
3903
|
const commonDeployArgsString = (0, createArgsString_1.createArgsString)({
|
|
3905
3904
|
command: `"${commandArray.join(",")}"`,
|
|
3906
3905
|
labels: `"${(0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context))},cloud-run-job-name=$current_job_name"`,
|
|
3907
|
-
image: `"${image !== null &&
|
|
3906
|
+
image: `"${(_a = job.image) !== null && _a !== void 0 ? _a : commonImage}"`,
|
|
3908
3907
|
project,
|
|
3909
3908
|
region,
|
|
3910
|
-
cpu,
|
|
3911
|
-
memory,
|
|
3912
|
-
parallelism,
|
|
3913
|
-
"task-timeout": timeout,
|
|
3909
|
+
cpu: job.cpu,
|
|
3910
|
+
memory: (_b = job.memory) !== null && _b !== void 0 ? _b : "512Mi",
|
|
3911
|
+
parallelism: (_c = job.parallelism) !== null && _c !== void 0 ? _c : 1,
|
|
3912
|
+
"task-timeout": (_d = job.timeout) !== null && _d !== void 0 ? _d : "10m",
|
|
3914
3913
|
"env-vars-file": constants_1.ENV_VARS_FILENAME,
|
|
3915
3914
|
"max-retries": 0,
|
|
3916
3915
|
...deployArgs,
|
|
3917
|
-
|
|
3916
|
+
// network
|
|
3917
|
+
"vpc-connector": job === null || job === void 0 ? void 0 : job.vpcConnector,
|
|
3918
|
+
"vpc-egress": job === null || job === void 0 ? void 0 : job.vpcEgress,
|
|
3919
|
+
network: job === null || job === void 0 ? void 0 : job.network,
|
|
3920
|
+
subnet: job === null || job === void 0 ? void 0 : job.subnet,
|
|
3921
|
+
}, ...(0, volumes_1.createVolumeConfig)(job.volumes, "job"));
|
|
3918
3922
|
return [
|
|
3919
3923
|
jobIndex === 0
|
|
3920
3924
|
? `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)"`
|
|
@@ -3931,28 +3935,26 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
|
|
|
3931
3935
|
});
|
|
3932
3936
|
exports.getJobCreateScripts = getJobCreateScripts;
|
|
3933
3937
|
const getCreateScheduleScripts = (context) => {
|
|
3934
|
-
const
|
|
3938
|
+
const schedules = getSchedules(context);
|
|
3935
3939
|
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
location,
|
|
3940
|
-
uri: `"$current_job_uri"`,
|
|
3941
|
-
"http-method": "POST",
|
|
3942
|
-
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
3943
|
-
};
|
|
3944
|
-
return jobsWithSchedule.map(({ job: { maxRetryAttempts, schedule }, jobName, schedulerName }, jobIndex) => {
|
|
3940
|
+
return schedules.map((scheduler, jobIndex) => {
|
|
3941
|
+
var _a;
|
|
3942
|
+
const uri = getSchedulerUrl(scheduler, context);
|
|
3945
3943
|
const argsString = (0, createArgsString_1.createArgsString)({
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
"
|
|
3944
|
+
project,
|
|
3945
|
+
location,
|
|
3946
|
+
uri: `"$current_job_uri"`,
|
|
3947
|
+
"http-method": "POST",
|
|
3948
|
+
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
3949
|
+
schedule: `"${scheduler.schedule}"`,
|
|
3950
|
+
"max-retry-attempts": (_a = scheduler.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
|
|
3949
3951
|
});
|
|
3950
3952
|
return [
|
|
3951
3953
|
jobIndex === 0
|
|
3952
3954
|
? `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)"`
|
|
3953
3955
|
: null,
|
|
3954
|
-
`current_job_uri="${
|
|
3955
|
-
`current_scheduler_name="${
|
|
3956
|
+
`current_job_uri="${uri}"`,
|
|
3957
|
+
`current_scheduler_name="${scheduler.name}"`,
|
|
3956
3958
|
`if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
|
|
3957
3959
|
` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
|
|
3958
3960
|
`else`,
|
|
@@ -3964,16 +3966,28 @@ const getCreateScheduleScripts = (context) => {
|
|
|
3964
3966
|
});
|
|
3965
3967
|
};
|
|
3966
3968
|
exports.getCreateScheduleScripts = getCreateScheduleScripts;
|
|
3967
|
-
const
|
|
3969
|
+
const getSchedulerUrl = (scheduler, context) => {
|
|
3970
|
+
if (scheduler.type === "cloudRunJob") {
|
|
3971
|
+
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
3972
|
+
const uriBase = `https://${location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${project}/jobs`;
|
|
3973
|
+
return `${uriBase}/${scheduler.jobName}:run`;
|
|
3974
|
+
}
|
|
3975
|
+
throw new Error(`Unknown scheduler type: ${scheduler.type}`);
|
|
3976
|
+
};
|
|
3977
|
+
const getSchedules = (context) => {
|
|
3968
3978
|
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
3969
3979
|
return jobsWithNames
|
|
3970
3980
|
.filter((entry) => entry.job.when === "schedule")
|
|
3971
|
-
.map(({ job,
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3981
|
+
.map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
|
|
3982
|
+
const schedulerName = jobName.concat("-scheduler");
|
|
3983
|
+
return {
|
|
3984
|
+
name: schedulerName,
|
|
3985
|
+
maxRetryAttempts,
|
|
3986
|
+
schedule,
|
|
3987
|
+
type: "cloudRunJob",
|
|
3988
|
+
jobName,
|
|
3989
|
+
};
|
|
3990
|
+
});
|
|
3977
3991
|
};
|
|
3978
3992
|
const getCloudRunJobsWithNames = (context) => {
|
|
3979
3993
|
var _a;
|
|
@@ -6791,16 +6791,14 @@ const getJobRunScriptForJob = (context, jobName, wait) => {
|
|
|
6791
6791
|
};
|
|
6792
6792
|
const getDeleteSchedulesScripts = (context) => {
|
|
6793
6793
|
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
6794
|
-
const
|
|
6794
|
+
const schedules = getSchedules(context);
|
|
6795
6795
|
const argsString = (0, createArgsString_1.createArgsString)({
|
|
6796
6796
|
project: deployConfig.projectId,
|
|
6797
6797
|
location: deployConfig.region,
|
|
6798
6798
|
});
|
|
6799
|
-
return
|
|
6800
|
-
.map(({
|
|
6801
|
-
return [
|
|
6802
|
-
`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${schedulerName} ${argsString}`,
|
|
6803
|
-
];
|
|
6799
|
+
return schedules
|
|
6800
|
+
.map(({ name }) => {
|
|
6801
|
+
return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${name} ${argsString}`];
|
|
6804
6802
|
})
|
|
6805
6803
|
.flat();
|
|
6806
6804
|
};
|
|
@@ -6833,25 +6831,31 @@ const getJobRunScripts = (context, when) => {
|
|
|
6833
6831
|
});
|
|
6834
6832
|
};
|
|
6835
6833
|
exports.getJobRunScripts = getJobRunScripts;
|
|
6836
|
-
const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map(({ job
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6834
|
+
const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map(({ job, jobName }, jobIndex) => {
|
|
6835
|
+
var _a, _b, _c, _d;
|
|
6836
|
+
const commandArray = Array.isArray(job.command)
|
|
6837
|
+
? job.command
|
|
6838
|
+
: job.command.split(" ");
|
|
6840
6839
|
const { image: commonImage, project, region, ...deployArgs } = (0, common_1.getCommonDeployArgs)(context);
|
|
6841
6840
|
const commonDeployArgsString = (0, createArgsString_1.createArgsString)({
|
|
6842
6841
|
command: `"${commandArray.join(",")}"`,
|
|
6843
6842
|
labels: `"${(0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context))},cloud-run-job-name=$current_job_name"`,
|
|
6844
|
-
image: `"${image !== null &&
|
|
6843
|
+
image: `"${(_a = job.image) !== null && _a !== void 0 ? _a : commonImage}"`,
|
|
6845
6844
|
project,
|
|
6846
6845
|
region,
|
|
6847
|
-
cpu,
|
|
6848
|
-
memory,
|
|
6849
|
-
parallelism,
|
|
6850
|
-
"task-timeout": timeout,
|
|
6846
|
+
cpu: job.cpu,
|
|
6847
|
+
memory: (_b = job.memory) !== null && _b !== void 0 ? _b : "512Mi",
|
|
6848
|
+
parallelism: (_c = job.parallelism) !== null && _c !== void 0 ? _c : 1,
|
|
6849
|
+
"task-timeout": (_d = job.timeout) !== null && _d !== void 0 ? _d : "10m",
|
|
6851
6850
|
"env-vars-file": constants_1.ENV_VARS_FILENAME,
|
|
6852
6851
|
"max-retries": 0,
|
|
6853
6852
|
...deployArgs,
|
|
6854
|
-
|
|
6853
|
+
// network
|
|
6854
|
+
"vpc-connector": job === null || job === void 0 ? void 0 : job.vpcConnector,
|
|
6855
|
+
"vpc-egress": job === null || job === void 0 ? void 0 : job.vpcEgress,
|
|
6856
|
+
network: job === null || job === void 0 ? void 0 : job.network,
|
|
6857
|
+
subnet: job === null || job === void 0 ? void 0 : job.subnet,
|
|
6858
|
+
}, ...(0, volumes_1.createVolumeConfig)(job.volumes, "job"));
|
|
6855
6859
|
return [
|
|
6856
6860
|
jobIndex === 0
|
|
6857
6861
|
? `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)"`
|
|
@@ -6868,28 +6872,26 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
|
|
|
6868
6872
|
});
|
|
6869
6873
|
exports.getJobCreateScripts = getJobCreateScripts;
|
|
6870
6874
|
const getCreateScheduleScripts = (context) => {
|
|
6871
|
-
const
|
|
6875
|
+
const schedules = getSchedules(context);
|
|
6872
6876
|
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
location,
|
|
6877
|
-
uri: `"$current_job_uri"`,
|
|
6878
|
-
"http-method": "POST",
|
|
6879
|
-
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
6880
|
-
};
|
|
6881
|
-
return jobsWithSchedule.map(({ job: { maxRetryAttempts, schedule }, jobName, schedulerName }, jobIndex) => {
|
|
6877
|
+
return schedules.map((scheduler, jobIndex) => {
|
|
6878
|
+
var _a;
|
|
6879
|
+
const uri = getSchedulerUrl(scheduler, context);
|
|
6882
6880
|
const argsString = (0, createArgsString_1.createArgsString)({
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
"
|
|
6881
|
+
project,
|
|
6882
|
+
location,
|
|
6883
|
+
uri: `"$current_job_uri"`,
|
|
6884
|
+
"http-method": "POST",
|
|
6885
|
+
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
6886
|
+
schedule: `"${scheduler.schedule}"`,
|
|
6887
|
+
"max-retry-attempts": (_a = scheduler.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
|
|
6886
6888
|
});
|
|
6887
6889
|
return [
|
|
6888
6890
|
jobIndex === 0
|
|
6889
6891
|
? `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)"`
|
|
6890
6892
|
: null,
|
|
6891
|
-
`current_job_uri="${
|
|
6892
|
-
`current_scheduler_name="${
|
|
6893
|
+
`current_job_uri="${uri}"`,
|
|
6894
|
+
`current_scheduler_name="${scheduler.name}"`,
|
|
6893
6895
|
`if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
|
|
6894
6896
|
` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
|
|
6895
6897
|
`else`,
|
|
@@ -6901,16 +6903,28 @@ const getCreateScheduleScripts = (context) => {
|
|
|
6901
6903
|
});
|
|
6902
6904
|
};
|
|
6903
6905
|
exports.getCreateScheduleScripts = getCreateScheduleScripts;
|
|
6904
|
-
const
|
|
6906
|
+
const getSchedulerUrl = (scheduler, context) => {
|
|
6907
|
+
if (scheduler.type === "cloudRunJob") {
|
|
6908
|
+
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
6909
|
+
const uriBase = `https://${location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${project}/jobs`;
|
|
6910
|
+
return `${uriBase}/${scheduler.jobName}:run`;
|
|
6911
|
+
}
|
|
6912
|
+
throw new Error(`Unknown scheduler type: ${scheduler.type}`);
|
|
6913
|
+
};
|
|
6914
|
+
const getSchedules = (context) => {
|
|
6905
6915
|
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
6906
6916
|
return jobsWithNames
|
|
6907
6917
|
.filter((entry) => entry.job.when === "schedule")
|
|
6908
|
-
.map(({ job,
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6918
|
+
.map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
|
|
6919
|
+
const schedulerName = jobName.concat("-scheduler");
|
|
6920
|
+
return {
|
|
6921
|
+
name: schedulerName,
|
|
6922
|
+
maxRetryAttempts,
|
|
6923
|
+
schedule,
|
|
6924
|
+
type: "cloudRunJob",
|
|
6925
|
+
jobName,
|
|
6926
|
+
};
|
|
6927
|
+
});
|
|
6914
6928
|
};
|
|
6915
6929
|
const getCloudRunJobsWithNames = (context) => {
|
|
6916
6930
|
var _a;
|
|
@@ -15,16 +15,14 @@ const getJobRunScriptForJob = (context, jobName, wait) => {
|
|
|
15
15
|
};
|
|
16
16
|
const getDeleteSchedulesScripts = (context) => {
|
|
17
17
|
const deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
|
|
18
|
-
const
|
|
18
|
+
const schedules = getSchedules(context);
|
|
19
19
|
const argsString = (0, createArgsString_1.createArgsString)({
|
|
20
20
|
project: deployConfig.projectId,
|
|
21
21
|
location: deployConfig.region,
|
|
22
22
|
});
|
|
23
|
-
return
|
|
24
|
-
.map(({
|
|
25
|
-
return [
|
|
26
|
-
`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${schedulerName} ${argsString}`,
|
|
27
|
-
];
|
|
23
|
+
return schedules
|
|
24
|
+
.map(({ name }) => {
|
|
25
|
+
return [`${(0, common_1.gcloudSchedulerCmd)()} jobs delete ${name} ${argsString}`];
|
|
28
26
|
})
|
|
29
27
|
.flat();
|
|
30
28
|
};
|
|
@@ -57,25 +55,31 @@ const getJobRunScripts = (context, when) => {
|
|
|
57
55
|
});
|
|
58
56
|
};
|
|
59
57
|
exports.getJobRunScripts = getJobRunScripts;
|
|
60
|
-
const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map(({ job
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map(({ job, jobName }, jobIndex) => {
|
|
59
|
+
var _a, _b, _c, _d;
|
|
60
|
+
const commandArray = Array.isArray(job.command)
|
|
61
|
+
? job.command
|
|
62
|
+
: job.command.split(" ");
|
|
64
63
|
const { image: commonImage, project, region, ...deployArgs } = (0, common_1.getCommonDeployArgs)(context);
|
|
65
64
|
const commonDeployArgsString = (0, createArgsString_1.createArgsString)({
|
|
66
65
|
command: `"${commandArray.join(",")}"`,
|
|
67
66
|
labels: `"${(0, common_1.makeLabelString)((0, getLabels_1.getLabels)(context))},cloud-run-job-name=$current_job_name"`,
|
|
68
|
-
image: `"${image !== null &&
|
|
67
|
+
image: `"${(_a = job.image) !== null && _a !== void 0 ? _a : commonImage}"`,
|
|
69
68
|
project,
|
|
70
69
|
region,
|
|
71
|
-
cpu,
|
|
72
|
-
memory,
|
|
73
|
-
parallelism,
|
|
74
|
-
"task-timeout": timeout,
|
|
70
|
+
cpu: job.cpu,
|
|
71
|
+
memory: (_b = job.memory) !== null && _b !== void 0 ? _b : "512Mi",
|
|
72
|
+
parallelism: (_c = job.parallelism) !== null && _c !== void 0 ? _c : 1,
|
|
73
|
+
"task-timeout": (_d = job.timeout) !== null && _d !== void 0 ? _d : "10m",
|
|
75
74
|
"env-vars-file": constants_1.ENV_VARS_FILENAME,
|
|
76
75
|
"max-retries": 0,
|
|
77
76
|
...deployArgs,
|
|
78
|
-
|
|
77
|
+
// network
|
|
78
|
+
"vpc-connector": job === null || job === void 0 ? void 0 : job.vpcConnector,
|
|
79
|
+
"vpc-egress": job === null || job === void 0 ? void 0 : job.vpcEgress,
|
|
80
|
+
network: job === null || job === void 0 ? void 0 : job.network,
|
|
81
|
+
subnet: job === null || job === void 0 ? void 0 : job.subnet,
|
|
82
|
+
}, ...(0, volumes_1.createVolumeConfig)(job.volumes, "job"));
|
|
79
83
|
return [
|
|
80
84
|
jobIndex === 0
|
|
81
85
|
? `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)"`
|
|
@@ -92,28 +96,26 @@ const getJobCreateScripts = (context) => getCloudRunJobsWithNames(context).map((
|
|
|
92
96
|
});
|
|
93
97
|
exports.getJobCreateScripts = getJobCreateScripts;
|
|
94
98
|
const getCreateScheduleScripts = (context) => {
|
|
95
|
-
const
|
|
99
|
+
const schedules = getSchedules(context);
|
|
96
100
|
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
location,
|
|
101
|
-
uri: `"$current_job_uri"`,
|
|
102
|
-
"http-method": "POST",
|
|
103
|
-
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
104
|
-
};
|
|
105
|
-
return jobsWithSchedule.map(({ job: { maxRetryAttempts, schedule }, jobName, schedulerName }, jobIndex) => {
|
|
101
|
+
return schedules.map((scheduler, jobIndex) => {
|
|
102
|
+
var _a;
|
|
103
|
+
const uri = getSchedulerUrl(scheduler, context);
|
|
106
104
|
const argsString = (0, createArgsString_1.createArgsString)({
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"
|
|
105
|
+
project,
|
|
106
|
+
location,
|
|
107
|
+
uri: `"$current_job_uri"`,
|
|
108
|
+
"http-method": "POST",
|
|
109
|
+
"oauth-service-account-email": `"$GCLOUD_PROJECT_NUMBER-compute@developer.gserviceaccount.com"`,
|
|
110
|
+
schedule: `"${scheduler.schedule}"`,
|
|
111
|
+
"max-retry-attempts": (_a = scheduler.maxRetryAttempts) !== null && _a !== void 0 ? _a : 0,
|
|
110
112
|
});
|
|
111
113
|
return [
|
|
112
114
|
jobIndex === 0
|
|
113
115
|
? `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)"`
|
|
114
116
|
: null,
|
|
115
|
-
`current_job_uri="${
|
|
116
|
-
`current_scheduler_name="${
|
|
117
|
+
`current_job_uri="${uri}"`,
|
|
118
|
+
`current_scheduler_name="${scheduler.name}"`,
|
|
117
119
|
`if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
|
|
118
120
|
` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
|
|
119
121
|
`else`,
|
|
@@ -125,16 +127,28 @@ const getCreateScheduleScripts = (context) => {
|
|
|
125
127
|
});
|
|
126
128
|
};
|
|
127
129
|
exports.getCreateScheduleScripts = getCreateScheduleScripts;
|
|
128
|
-
const
|
|
130
|
+
const getSchedulerUrl = (scheduler, context) => {
|
|
131
|
+
if (scheduler.type === "cloudRunJob") {
|
|
132
|
+
const { region: location, projectId: project } = (0, common_1.getCloudRunDeployConfig)(context);
|
|
133
|
+
const uriBase = `https://${location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${project}/jobs`;
|
|
134
|
+
return `${uriBase}/${scheduler.jobName}:run`;
|
|
135
|
+
}
|
|
136
|
+
throw new Error(`Unknown scheduler type: ${scheduler.type}`);
|
|
137
|
+
};
|
|
138
|
+
const getSchedules = (context) => {
|
|
129
139
|
const jobsWithNames = getCloudRunJobsWithNames(context);
|
|
130
140
|
return jobsWithNames
|
|
131
141
|
.filter((entry) => entry.job.when === "schedule")
|
|
132
|
-
.map(({ job,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
.map(({ job: { maxRetryAttempts, schedule }, jobName }) => {
|
|
143
|
+
const schedulerName = jobName.concat("-scheduler");
|
|
144
|
+
return {
|
|
145
|
+
name: schedulerName,
|
|
146
|
+
maxRetryAttempts,
|
|
147
|
+
schedule,
|
|
148
|
+
type: "cloudRunJob",
|
|
149
|
+
jobName,
|
|
150
|
+
};
|
|
151
|
+
});
|
|
138
152
|
};
|
|
139
153
|
const getCloudRunJobsWithNames = (context) => {
|
|
140
154
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudRunJobs.js","sourceRoot":"","sources":["../../../../../../../pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.ts"],"names":[],"mappings":";;;AAMA,gEAA6D;AAC7D,8CAAsD;AACtD,qCAOkB;AAClB,0DAAuD;AACvD,uCAA+C;AAK/C,2CAAgD;AAChD,0CAAwC;AAExC,MAAM,qBAAqB,GAAG,CAC5B,OAAyB,EACzB,OAA+B,EAC/B,IAAa,EACb,EAAE;IACF,MAAM,UAAU,GAAG,IAAA,8BAAqB,EAAC,OAAO,CAAC,CAAC;IAElD,MAAM,gBAAgB,GAAG,IAAA,mCAAgB,EAAC,UAAU,CAAC,CAAC;IACtD,OAAO,GAAG,IAAA,qBAAY,GAAE,iBAAiB,OAAO,CAAC,QAAQ,EAAE,IAAI,gBAAgB,GAC7E,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACrB,EAAE,CAAC;AACL,CAAC,CAAC;AAEK,MAAM,yBAAyB,GAAG,CAAC,OAAyB,EAAE,EAAE;IACrE,MAAM,YAAY,GAAG,IAAA,gCAAuB,EAAC,OAAO,CAAC,CAAC;IACtD,MAAM,
|
|
1
|
+
{"version":3,"file":"cloudRunJobs.js","sourceRoot":"","sources":["../../../../../../../pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.ts"],"names":[],"mappings":";;;AAMA,gEAA6D;AAC7D,8CAAsD;AACtD,qCAOkB;AAClB,0DAAuD;AACvD,uCAA+C;AAK/C,2CAAgD;AAChD,0CAAwC;AAExC,MAAM,qBAAqB,GAAG,CAC5B,OAAyB,EACzB,OAA+B,EAC/B,IAAa,EACb,EAAE;IACF,MAAM,UAAU,GAAG,IAAA,8BAAqB,EAAC,OAAO,CAAC,CAAC;IAElD,MAAM,gBAAgB,GAAG,IAAA,mCAAgB,EAAC,UAAU,CAAC,CAAC;IACtD,OAAO,GAAG,IAAA,qBAAY,GAAE,iBAAiB,OAAO,CAAC,QAAQ,EAAE,IAAI,gBAAgB,GAC7E,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACrB,EAAE,CAAC;AACL,CAAC,CAAC;AAEK,MAAM,yBAAyB,GAAG,CAAC,OAAyB,EAAE,EAAE;IACrE,MAAM,YAAY,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CAAI,EAAE,CAAC;QAC3D,2BAA2B;SAC1B,MAAM,CAAC,CAAC,KAAK,EAA8C,EAAE,CAC5D,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAClB;SACA,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QACvB,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC;QAC/B,GAAG;QACH,MAAM;KACP,CAAC,CAAC,CAAC;IACN,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC"}
|
|
@@ -106,6 +106,18 @@ export type DeployConfigCloudRunService = {
|
|
|
106
106
|
* defaults to gen1 according to gcloud
|
|
107
107
|
*/
|
|
108
108
|
executionEnvironment?: "gen2" | "gen1";
|
|
109
|
+
/**
|
|
110
|
+
* Use http2 end-to-end. See https://cloud.google.com/run/docs/configuring/http2
|
|
111
|
+
*
|
|
112
|
+
* Defaults to false.
|
|
113
|
+
*
|
|
114
|
+
* Your service needs to be able to handle http2 requests.
|
|
115
|
+
* Its recommended to use http2 without tls, since cloud run handles the encryption for you. (so called "h2c" (http2 cleartext))
|
|
116
|
+
*
|
|
117
|
+
*/
|
|
118
|
+
http2?: boolean;
|
|
119
|
+
} & DeployConfigCloudRunWithVolumes & DeployConfigCloudRunNetworkConfig;
|
|
120
|
+
export type DeployConfigCloudRunNetworkConfig = {
|
|
109
121
|
network?: string;
|
|
110
122
|
/**
|
|
111
123
|
* vpc subnet to use, see https://cloud.google.com/sdk/gcloud/reference/run/deploy#--subnet
|
|
@@ -119,17 +131,7 @@ export type DeployConfigCloudRunService = {
|
|
|
119
131
|
* vpc connector
|
|
120
132
|
*/
|
|
121
133
|
vpcConnector?: string;
|
|
122
|
-
|
|
123
|
-
* Use http2 end-to-end. See https://cloud.google.com/run/docs/configuring/http2
|
|
124
|
-
*
|
|
125
|
-
* Defaults to false.
|
|
126
|
-
*
|
|
127
|
-
* Your service needs to be able to handle http2 requests.
|
|
128
|
-
* Its recommended to use http2 without tls, since cloud run handles the encryption for you. (so called "h2c" (http2 cleartext))
|
|
129
|
-
*
|
|
130
|
-
*/
|
|
131
|
-
http2?: boolean;
|
|
132
|
-
} & DeployConfigCloudRunWithVolumes;
|
|
134
|
+
};
|
|
133
135
|
export type DeployConfigCloudRunJobBase = {
|
|
134
136
|
/**
|
|
135
137
|
* command
|
|
@@ -157,7 +159,7 @@ export type DeployConfigCloudRunJobBase = {
|
|
|
157
159
|
* number of tasks that may run concurrently, defaults to 1
|
|
158
160
|
*/
|
|
159
161
|
parallelism?: number;
|
|
160
|
-
} & DeployConfigCloudRunWithVolumes;
|
|
162
|
+
} & DeployConfigCloudRunWithVolumes & DeployConfigCloudRunNetworkConfig;
|
|
161
163
|
type Minute = string;
|
|
162
164
|
type Hour = string;
|
|
163
165
|
type DayOfMonth = string;
|