diff options
| author | Alex Kost <alezost@gmail.com> | 2018-07-18 22:34:12 +0300 |
|---|---|---|
| committer | Alex Kost <alezost@gmail.com> | 2018-07-27 12:14:24 +0300 |
| commit | 64ba3161c90b67926dcfd2592e3b1e562d9cb2ef (patch) | |
| tree | 150afee3c575dec9456b1fdcc6ab76e5df27ff5a /build-farm.el | |
| parent | Add and use 'build-farm-get-display' (diff) | |
| download | emacs-build-farm-64ba3161c90b67926dcfd2592e3b1e562d9cb2ef.tar.gz | |
Use per-buffer build farm URL
Previously, a single global 'build-farm-url' variable was used
everywhere. But this is not correct: when you change this url, it
should take effect only for the future requests, and the existing Farm
buffers should use the previous url. So this root url should be local
for every build/jobset/project list/info, which is accomplished by this
commit.
* build-farm-url.el (build-farm-url): Add 'root-url' argument.
(build-farm-api-url, build-farm-build-url, build-farm-build-log-url)
(build-farm-build-latest-api-url, build-farm-build-queue-api-url)
(build-farm-jobset-url, build-farm-jobset-api-url)
(build-farm-project-url): Add 'root-url' keyword argument.
* build-farm.el: Define accessors for entry args. Specifically...
(build-farm-current-url): New function.
(build-farm-get-entries, build-farm-get-display, build-farm-message)
(build-farm-search-url): New 'root-url' argument.
* build-farm-build.el: Adjust to use 'root-url' arguments where appropriate.
* build-farm-jobset.el: Likewise.
* build-farm-project.el: Likewise.
Diffstat (limited to 'build-farm.el')
| -rw-r--r-- | build-farm.el | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/build-farm.el b/build-farm.el index ecaec17..46cb3e0 100644 --- a/build-farm.el +++ b/build-farm.el @@ -96,27 +96,35 @@ If URL is nil, use `build-farm-url'." "Return job name specification by NAME and VERSION." (concat name "-" version)) -(defun build-farm-get-entries (entry-type search-type &rest args) +(bui-define-current-args-accessors build-farm-current + url search-type search-args) + +(defun build-farm-get-entries (root-url entry-type search-type + &rest args) "Receive ENTRY-TYPE entries from build farm. -See `build-farm-search-url' for the meaning of SEARCH-TYPE and ARGS." +See `build-farm-search-url' for the meaning of ROOT-URL, +SEARCH-TYPE and ARGS." (unless (eq search-type 'fake) (let* ((url (apply #'build-farm-search-url - entry-type search-type args)) + root-url entry-type search-type args)) (raw-entries (build-farm-receive-data url)) (entries (apply #'build-farm-modify-objects raw-entries (build-farm-filters entry-type)))) entries))) -(defun build-farm-get-display (entry-type search-type &rest args) +(defun build-farm-get-display (root-url entry-type search-type + &rest args) "Search for ENTRY-TYPE entries and show results. ENTRY-TYPE should be `build', `jobset', etc. -See `build-farm-search-url' for the meaning of SEARCH-TYPE and ARGS." +See `build-farm-search-url' for the meaning of ROOT-URL, +SEARCH-TYPE and ARGS." (apply #'bui-list-get-display-entries (build-farm-symbol entry-type) + root-url search-type args)) -(defun build-farm-message (entries search-type &rest _) +(defun build-farm-message (entries _root-url search-type &rest _) "Display a message after showing ENTRIES of SEARCH-TYPE." ;; XXX Add more messages maybe. (when (null entries) @@ -131,7 +139,7 @@ See `build-farm-search-url' for the meaning of SEARCH-TYPE and ARGS." (bui-current-entry-type) 'info ;; Hydra and Cuirass do not provide an API to receive builds/jobsets ;; by IDs/names, so we use a 'fake' search type. - '(fake) + (list (build-farm-current-url) 'fake) 'add)) @@ -200,14 +208,18 @@ Where '...' is made from SYMBOLS." "Return SYMBOL's value for ENTRY-TYPE." (symbol-value (build-farm-symbol entry-type symbol))) -(defun build-farm-search-url (entry-type search-type &rest args) +(defun build-farm-search-url (root-url entry-type search-type + &rest args) "Return URL to receive ENTRY-TYPE entries from build farm. +ROOT-URL is the url of the build farm (from `build-farm-url-alist'). SEARCH-TYPE is one of the types defined by `build-farm-define-entry-type'. ARGS are passed to the according URL function." (apply (bui-assq-value (build-farm-symbol-value entry-type 'search-types) search-type) - args)) + ;; `:root-url' should be the last argument because `args' may + ;; contain non-keyword arguments. + (append args `(:root-url ,root-url)))) (defun build-farm-filters (entry-type) "Return a list of filters for ENTRY-TYPE." @@ -311,13 +323,13 @@ Run `build-farm-filter-names' with `%S' variable." (setq ,filters-var (cons ',filter-names-fun ,filters-var))))) - (defun ,get-fun (search-type &rest args) + (defun ,get-fun (root-url search-type &rest args) ,(format "\ Receive '%s' entries. See `build-farm-get-entries' for details." entry-type-str) (apply #'build-farm-get-entries - ',entry-type search-type args)) + root-url ',entry-type search-type args)) (bui-define-groups ,full-entry-type :parent-group build-farm |
