diff options
Diffstat (limited to 'server/middlewares/validators/runners/jobs.ts')
-rw-r--r-- | server/middlewares/validators/runners/jobs.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/server/middlewares/validators/runners/jobs.ts b/server/middlewares/validators/runners/jobs.ts index 8cb87e946..de956a1ca 100644 --- a/server/middlewares/validators/runners/jobs.ts +++ b/server/middlewares/validators/runners/jobs.ts | |||
@@ -91,6 +91,28 @@ export const successRunnerJobValidator = [ | |||
91 | } | 91 | } |
92 | ] | 92 | ] |
93 | 93 | ||
94 | export const cancelRunnerJobValidator = [ | ||
95 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
96 | const runnerJob = res.locals.runnerJob | ||
97 | |||
98 | const allowedStates = new Set<RunnerJobState>([ | ||
99 | RunnerJobState.PENDING, | ||
100 | RunnerJobState.PROCESSING, | ||
101 | RunnerJobState.WAITING_FOR_PARENT_JOB | ||
102 | ]) | ||
103 | |||
104 | if (allowedStates.has(runnerJob.state) !== true) { | ||
105 | return res.fail({ | ||
106 | status: HttpStatusCode.BAD_REQUEST_400, | ||
107 | message: 'Cannot cancel this job that is not in "pending", "processing" or "waiting for parent job" state', | ||
108 | tags | ||
109 | }) | ||
110 | } | ||
111 | |||
112 | return next() | ||
113 | } | ||
114 | ] | ||
115 | |||
94 | export const runnerJobGetValidator = [ | 116 | export const runnerJobGetValidator = [ |
95 | param('jobUUID').custom(isUUIDValid), | 117 | param('jobUUID').custom(isUUIDValid), |
96 | 118 | ||