unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] http: Support fetching builds by derivation.
@ 2019-09-29 18:15 Christopher Baines via Development of GNU Guix and the GNU System distribution.
  2019-10-01  9:25 ` Ludovic Courtès
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Baines via Development of GNU Guix and the GNU System distribution. @ 2019-09-29 18:15 UTC (permalink / raw)
  To: guix-devel

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): Add new clause to match statement, to
return build information by derivation file name.
---
 src/cuirass/http.scm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 2da3637..3f37716 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -248,6 +248,13 @@ Hydra format."
        (if hydra-build
            (respond-json (object->json-string hydra-build))
            (respond-build-not-found build-id))))
+    (("build" "gnu" "store" derivation-file-name)
+     (let* ((full-derivation-file-name
+             (string-append "/gnu/store/" derivation-file-name))
+            (hydra-build (handle-build-request full-derivation-file-name)))
+       (if hydra-build
+           (respond-json (object->json-string hydra-build))
+           (respond-build-not-found full-derivation-file-name))))
     (("build" build-id "details")
      (let ((build (db-get-build (string->number build-id))))
        (if build
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] http: Support fetching builds by derivation.
  2019-09-29 18:15 [PATCH] http: Support fetching builds by derivation Christopher Baines via Development of GNU Guix and the GNU System distribution.
@ 2019-10-01  9:25 ` Ludovic Courtès
  2019-10-02  7:17   ` Christopher Baines via Development of GNU Guix and the GNU System distribution.
  2019-10-02  7:26   ` Christopher Baines
  0 siblings, 2 replies; 5+ messages in thread
From: Ludovic Courtès @ 2019-10-01  9:25 UTC (permalink / raw)
  To: Christopher Baines via Development of GNU Guix and the GNU System distribution.

Hello!

Christopher Baines via "Development of GNU Guix and the GNU System
distribution." <guix-devel@gnu.org> skribis:

> 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): Add new clause to match statement, to
> return build information by derivation file name.

[...]

> +    (("build" "gnu" "store" derivation-file-name)

Perhaps we can avoid /gnu/store in the URL, and…

> +     (let* ((full-derivation-file-name
> +             (string-append "/gnu/store/" derivation-file-name))

… use (%store-prefix) instead of "/gnu/store" here

Otherwise LGTM, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] http: Support fetching builds by derivation.
  2019-10-01  9:25 ` Ludovic Courtès
@ 2019-10-02  7:17   ` Christopher Baines via Development of GNU Guix and the GNU System distribution.
  2019-10-02  7:26   ` Christopher Baines
  1 sibling, 0 replies; 5+ messages in thread
From: Christopher Baines via Development of GNU Guix and the GNU System distribution. @ 2019-10-02  7:17 UTC (permalink / raw)
  To: guix-devel

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.
---
 src/cuirass/http.scm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 2da3637..b6a4358 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -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
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] http: Support fetching builds by derivation.
  2019-10-01  9:25 ` Ludovic Courtès
  2019-10-02  7:17   ` Christopher Baines via Development of GNU Guix and the GNU System distribution.
@ 2019-10-02  7:26   ` Christopher Baines
  2019-10-17 20:21     ` Christopher Baines
  1 sibling, 1 reply; 5+ messages in thread
From: Christopher Baines @ 2019-10-02  7:26 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 908 bytes --]


Ludovic Courtès <ludo@gnu.org> writes:

> Hello!
>
> Christopher Baines via "Development of GNU Guix and the GNU System
> distribution." <guix-devel@gnu.org> skribis:
>
>> 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): Add new clause to match statement, to
>> return build information by derivation file name.
>
> [...]
>
>> +    (("build" "gnu" "store" derivation-file-name)
>
> Perhaps we can avoid /gnu/store in the URL, and…
>
>> +     (let* ((full-derivation-file-name
>> +             (string-append "/gnu/store/" derivation-file-name))
>
> … use (%store-prefix) instead of "/gnu/store" here

Sure, I've sent another patch with these changes.

Thanks,

Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 962 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] http: Support fetching builds by derivation.
  2019-10-02  7:26   ` Christopher Baines
@ 2019-10-17 20:21     ` Christopher Baines
  0 siblings, 0 replies; 5+ messages in thread
From: Christopher Baines @ 2019-10-17 20:21 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1046 bytes --]


Christopher Baines <mail@cbaines.net> writes:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hello!
>>
>> Christopher Baines via "Development of GNU Guix and the GNU System
>> distribution." <guix-devel@gnu.org> skribis:
>>
>>> 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): Add new clause to match statement, to
>>> return build information by derivation file name.
>>
>> [...]
>>
>>> +    (("build" "gnu" "store" derivation-file-name)
>>
>> Perhaps we can avoid /gnu/store in the URL, and…
>>
>>> +     (let* ((full-derivation-file-name
>>> +             (string-append "/gnu/store/" derivation-file-name))
>>
>> … use (%store-prefix) instead of "/gnu/store" here
>
> Sure, I've sent another patch with these changes.

I've gone ahead and pushed this as
9acb0aa55b5787edef885bb812e2ee66d4401e80.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 962 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-17 20:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-29 18:15 [PATCH] http: Support fetching builds by derivation Christopher Baines via Development of GNU Guix and the GNU System distribution.
2019-10-01  9:25 ` Ludovic Courtès
2019-10-02  7:17   ` Christopher Baines via Development of GNU Guix and the GNU System distribution.
2019-10-02  7:26   ` Christopher Baines
2019-10-17 20:21     ` Christopher Baines

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).