http: Support fetching builds by derivation.

There's a one to one mapping of build id to derivation, so allow querying by
derivation file name as well. I'm looking at this as I'm interested in getting
build information in to the Guix Data Service.

* src/cuirass/http.scm (url-handler): Support fetching builds by numeric id or
the derivation file name.
This commit is contained in:
Christopher Baines 2019-09-29 19:13:02 +01:00
parent d27ff21e43
commit 9acb0aa55b
1 changed files with 7 additions and 3 deletions

View File

@ -42,6 +42,7 @@
#:use-module (sxml simple)
#:use-module (cuirass templates)
#:use-module (guix utils)
#:use-module ((guix store) #:select (%store-prefix))
#:use-module (guix build union)
#:export (run-cuirass-server))
@ -243,11 +244,14 @@ Hydra format."
(((or "jobsets" "specifications") . rest)
(respond-json (object->json-string
(list->vector (db-get-specifications)))))
(("build" build-id)
(let ((hydra-build (handle-build-request (string->number build-id))))
(("build" id)
(let ((hydra-build (handle-build-request
(if (string-suffix? ".drv" id)
(string-append (%store-prefix) "/" id)
(string->number id)))))
(if hydra-build
(respond-json (object->json-string hydra-build))
(respond-build-not-found build-id))))
(respond-build-not-found id))))
(("build" build-id "details")
(let ((build (db-get-build (string->number build-id))))
(if build