diff options
author | Christopher Baines <mail@cbaines.net> | 2020-01-04 09:43:04 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-01-04 09:43:04 +0000 |
commit | 4195cc3f7200527ae98d182babb266e97ea1bf8c (patch) | |
tree | c58386f5fd894fb28c164664f69ac1d9ccd55ec7 /src/cuirass/http.scm | |
parent | 5c5790ad21d88599bb07dd9669708d8b58a47124 (diff) | |
download | cuirass-support-returning-build-information-by-output.tar cuirass-support-returning-build-information-by-output.tar.gz |
Support returning build information by output.support-returning-build-information-by-output
Being able to take a derivation and query the build information is useful, but
in cases where there are multiple derivations that produce the same outputs,
the probability of getting the data back from Cuirass is reduced.
This is because Cuirass might not have build the exact derivation you have,
but a different derivation that produces the same outputs (this can commonly
happen when a related fixed output derivation changes).
Cuirass doesn't store derivations if they produce the same outputs as a
derivation it already knows about, so it can't determine if this is the
case. Therefore, provide a way of querying build results by output, rather
than derivation.
The motivation behind this is to make it easier to import build information in
to the Guix Data Service.
* src/cuirass/database.scm (db-get-output): New procedure.
* src/cuirass/http.scm (respond-output-not-found): New procedure.
(request-path-components): Handle /output/… requests.
* doc/cuirass.texi (Build information): Mention that you can get build
information by output.
Diffstat (limited to 'src/cuirass/http.scm')
-rw-r--r-- | src/cuirass/http.scm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm index 7579e1a..bf436c5 100644 --- a/src/cuirass/http.scm +++ b/src/cuirass/http.scm @@ -226,6 +226,11 @@ Hydra format." 404 (format #f "Build with ID ~a doesn't exist." build-id))) + (define (respond-output-not-found output-id) + (respond-json-with-error + 404 + (format #f "Output with ID ~a doesn't exist." output-id))) + (define (respond-html-eval-not-found eval-id) (respond-html (html-page "Page not found" @@ -331,6 +336,16 @@ Hydra format." (#f (respond-build-not-found build-id))) (respond-build-not-found build-id)))) + (('GET "output" id) + (let ((output (db-get-output + (string-append (%store-prefix) "/" id)))) + (if output + (let ((build (db-get-build (assq-ref output #:derivation)))) + (respond-json + (object->json-string + (append output + `((#:build . ,(or build #nil))))))) + (respond-output-not-found id)))) (('GET "api" "evaluations") (let* ((params (request-parameters request)) ;; 'nr parameter is mandatory to limit query size. |