feat: allow queueing one-time builds

This commit is contained in:
Jef Roosens 2022-12-13 21:22:22 +01:00
parent f6c5e7c246
commit 6a208dbe6c
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
3 changed files with 51 additions and 18 deletions

View file

@ -19,3 +19,24 @@ fn (mut app App) v1_poll_job_queue() web.Result {
return app.json(.ok, new_data_response(out))
}
['/api/v1/jobs/queue'; auth; post]
fn (mut app App) v1_queue_job() web.Result {
target_id := app.query['target'] or {
return app.json(.bad_request, new_response('Missing target query arg.'))
}.int()
arch := app.query['arch'] or {
return app.json(.bad_request, new_response('Missing arch query arg.'))
}
target := app.db.get_target(target_id) or {
return app.json(.bad_request, new_response('Unknown target id.'))
}
app.job_queue.insert(target: target, arch: arch, single: true) or {
return app.status(.internal_server_error)
}
return app.status(.ok)
}

View file

@ -37,7 +37,7 @@ fn (mut app App) init_job_queue() ! {
for targets.len > 0 {
for target in targets {
for arch in target.arch {
app.job_queue.insert(target, arch.value)!
app.job_queue.insert(target: target, arch: arch.value)!
}
}