aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/datastore.scm
blob: 389bc7c3008b611ba9fbd385a579e9007907f60b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
(define-module (guix-build-coordinator datastore)
  #:use-module (srfi srfi-1)
  #:use-module (oop goops)
  #:use-module (guix-build-coordinator datastore abstract)
  #:use-module (guix-build-coordinator datastore sqlite)
  #:use-module (guix-build-coordinator datastore postgresql)
  #:duplicates (merge-generics)
  #:export (database-uri->datastore
            datastore-find-build-output))

(re-export datastore-store-derivation)
(re-export datastore-store-build)
(re-export datastore-new-agent)
(re-export datastore-list-agents)
(re-export datastore-find-agent)
(re-export datastore-count-build-results)
(re-export datastore-store-build-result)
(re-export datastore-count-setup-failures)
(re-export datastore-fetch-setup-failures)
(re-export datastore-list-build-outputs)
(re-export datastore-list-related-derivations-with-no-build)
(re-export datastore-store-setup-failure)
(re-export datastore-store-setup-failure/missing-inputs)
(re-export datastore-list-setup-failure-missing-inputs)
(re-export datastore-new-agent-password)
(re-export datastore-agent-password-exists?)
(re-export datastore-count-builds)
(re-export datastore-find-build)
(re-export datastore-list-builds-for-derivation)
(re-export datastore-list-unprocessed-builds)
(re-export datastore-list-agent-builds)
(re-export datastore-find-derivation-outputs)
(re-export datastore-find-derivation-system)
(re-export datastore-find-derivation-inputs)
(re-export datastore-list-builds-for-output)
(re-export datastore-agent-for-build)
(re-export datastore-count-build-allocation-plan-entries)
(re-export datastore-replace-build-allocation-plan)
(re-export datastore-count-allocated-builds)
(re-export datastore-allocate-builds-to-agent)
(re-export datastore-list-allocation-plan-builds)

(define (database-uri->datastore database)
  (cond
   ((string-prefix? "pg://" database)
    (postgresql-datastore database))
   ((string-prefix? "sqlite://" database)
    (sqlite-datastore database))
   (else
    (error
     (simple-format #f "Unknown database ~A" database)))))

(define (datastore-find-build-output datastore build-id output-name)
  (let* ((build (datastore-find-build datastore build-id))
         (outputs (datastore-find-derivation-outputs
                   datastore
                   (assq-ref build 'derivation-name))))
    (any (lambda (output)
           (if (string=? (assq-ref output 'name) output-name)
               (assq-ref output 'output)
               #f))
         outputs)))