Skip to content

Commit 1959912

Browse files
committed
add endpoint to print current in-memory repo config
1 parent 1eab7b5 commit 1959912

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/action.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,11 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
350350
| Ok () ->
351351
match notification.event with
352352
| Link_shared event -> process_link_shared_event ctx event
353+
354+
(** debugging endpoint to return current in-memory repo config *)
355+
let print_config (ctx : Context.t) repo_url =
356+
log#info "finding config for repo_url: %s" repo_url;
357+
match Context.find_repo_config ctx repo_url with
358+
| None -> Lwt.return_error (`Not_found, Printf.sprintf "repo_url not found: %s" repo_url)
359+
| Some config -> Lwt.return_ok (Config_j.string_of_config config)
353360
end

src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(executable
22
(libraries lib base base.caml cmdliner devkit devkit.core extlib lwt.unix
3-
stdio uri)
3+
result stdio uri)
44
(preprocess
55
(pps lwt_ppx))
66
(public_name monorobot))

src/request_handler.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ let setup_http ~ctx ~signature ~port ~ip =
3434
in
3535
match request.meth, List.map Web.urldecode path with
3636
| _, [ "stats" ] -> ret @@ Lwt.return (sprintf "%s %s uptime\n" signature Devkit.Action.uptime#get_str)
37+
| `GET, [ "config" ] ->
38+
let repo_url = Arg.str "repo" |> Web.urldecode in
39+
( match%lwt Action.print_config ctx repo_url with
40+
| Error (code, msg) -> ret_err code msg
41+
| Ok res -> ret ~typ:"application/json" (Lwt.return res)
42+
)
3743
| _, [ "github" ] ->
3844
log#info "%s" request.body;
3945
let%lwt () = Action.process_github_notification ctx request.headers request.body in

0 commit comments

Comments
 (0)