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-url.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-url.el')
| -rw-r--r-- | build-farm-url.el | 89 |
1 files changed, 54 insertions, 35 deletions
diff --git a/build-farm-url.el b/build-farm-url.el index cc21150..1c566df 100644 --- a/build-farm-url.el +++ b/build-farm-url.el @@ -23,6 +23,7 @@ ;;; Code: (require 'url-handlers) +(require 'url-expand) (require 'json) (require 'build-farm-utils) @@ -76,17 +77,18 @@ Arbitrarily choosing `%S' type for this URL." url type) type))) -(defun build-farm-url (&rest url-parts) - "Return build farm URL using URL-PARTS. -URL-PARTS are added to `build-farm-url'." - (apply #'concat build-farm-url "/" url-parts)) +(defun build-farm-url (&optional root-url &rest url-parts) + "Return build farm ROOT-URL with URL-PARTS concatenated to it. +If ROOT-URL is nil, `build-farm-url' variable is used." + (url-expand-file-name (mapconcat #'identity url-parts "") + (or root-url build-farm-url))) -(defun build-farm-api-url (type args) +(cl-defun build-farm-api-url (type args &key root-url) "Return URL for receiving data using build farm API. +See `build-farm-url' for the meaning of ROOT-URL. TYPE is the name of an allowed method. ARGS is alist of (KEY . VALUE) pairs. Skip ARG, if VALUE is nil or an empty string." - (declare (indent 1)) (let* ((fields (mapcar (lambda (arg) (pcase arg @@ -98,46 +100,63 @@ Skip ARG, if VALUE is nil or an empty string." (_ (error "Wrong argument '%s'" arg)))) args)) (fields (mapconcat #'identity (delq nil fields) "&"))) - (build-farm-url "api/" type "?" fields))) + (build-farm-url root-url "api/" type "?" fields))) -(defun build-farm-build-url (id) - "Return URL of a build ID." - (build-farm-url "build/" (number-to-string id))) +(cl-defun build-farm-build-url (id &key root-url) + "Return URL of a build ID. +See `build-farm-url' for the meaning of ROOT-URL." + (build-farm-url root-url "build/" (number-to-string id))) -(defun build-farm-build-log-url (id) - "Return URL of the log file of a build ID." - (concat (build-farm-build-url id) "/log/raw")) +(cl-defun build-farm-build-log-url (id &key root-url) + "Return URL of the log file of a build ID. +See `build-farm-url' for the meaning of ROOT-URL." + (concat (build-farm-build-url id :root-url root-url) + "/log/raw")) (cl-defun build-farm-build-latest-api-url - (number &key project jobset job system) - "Return API URL to receive latest NUMBER of builds." - (build-farm-api-url "latestbuilds" - `(("nr" . ,number) - ("project" . ,project) - ("jobset" . ,jobset) - ("job" . ,job) - ("system" . ,system)))) + (number &key root-url project jobset job system) + "Return API URL to receive latest NUMBER of builds. +See `build-farm-url' for the meaning of ROOT-URL." + (build-farm-api-url + "latestbuilds" + `(("nr" . ,number) + ("project" . ,project) + ("jobset" . ,jobset) + ("job" . ,job) + ("system" . ,system)) + :root-url root-url)) -(defun build-farm-build-queue-api-url (number) - "Return API URL to receive the NUMBER of queued builds." - (build-farm-api-url "queue" - `(("nr" . ,number)))) +(cl-defun build-farm-build-queue-api-url (number &key root-url) + "Return API URL to receive the NUMBER of queued builds. +See `build-farm-url' for the meaning of ROOT-URL." + (build-farm-api-url + "queue" + `(("nr" . ,number)) + :root-url root-url)) -(cl-defun build-farm-jobset-url (&key project jobset jobset-id) +(cl-defun build-farm-jobset-url (&key root-url project jobset jobset-id) "Return URL of a PROJECT's JOBSET. -You should specify either a single JOBSET-ID argument (it should have -a form 'project/jobset') or PROJECT and JOBSET arguments." - (build-farm-url "jobset/" +Above that, you should specify either a single JOBSET-ID +argument (it should have a form 'project/jobset') or PROJECT and +JOBSET arguments. +See `build-farm-url' for the meaning of ROOT-URL." + (build-farm-url root-url "/jobset/" (or jobset-id (concat project "/" jobset)))) -(defun build-farm-jobset-api-url (project) - "Return API URL for jobsets by PROJECT." - (build-farm-api-url "jobsets" - `(("project" . ,project)))) +(cl-defun build-farm-jobset-api-url (project &key root-url) + "Return API URL for jobsets by PROJECT. +See `build-farm-url' for the meaning of ROOT-URL." + (build-farm-api-url + "jobsets" + `(("project" . ,project)) + :root-url root-url)) -;; Projects are received from the root build farm page. -(defalias 'build-farm-project-url #'build-farm-url) +(cl-defun build-farm-project-url (&key root-url) + "Return URL with bulid farm projects. +See `build-farm-url' for the meaning of ROOT-URL." + ;; Projects are received from the root build farm page. + (build-farm-url root-url)) ;;; Receiving data from a build farm |
