Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 11 additions & 25 deletions src/session.ml
Original file line number Diff line number Diff line change
Expand Up @@ -499,29 +499,15 @@ let exists w s path =
else let c = get_proposed_config w s in
(VT.exists[@alert "-exn"]) c path

let show_config w s path fmt =
(* alert exn VT.exists:
[Vytree.Empty_path] non-empty in conditional
alert exn CT.render_at_level:
[Vytree.Nonexistent_path] checked by VT.exists
alert exn VT.get:
[Vytree.Empty_path] non-empty in pattern match
[Vytree.Nonexistent_path] checked by VT.exists
*)
let open Vyconf_connect.Vyconf_pbt in
let c = get_proposed_config w s in
if (path <> []) && not ((VT.exists[@alert "-exn"]) c path) then
raise (Session_error ("Path does not exist"))
let show_config w s path =
let proposed_config = get_proposed_config w s in
if (path <> []) && not ((VT.exists[@alert "-exn"]) proposed_config path)
then raise (Session_error "Path does not exist")
else
let node = c in
match fmt with
| Curly -> (CT.render_at_level[@alert "-exn"]) node path
| Json ->
let node =
begin
match path with
| [] -> c
| _ as ps -> (VT.get[@alert "-exn"]) c ps
end
in
CT.to_yojson node |> Yojson.Safe.pretty_to_string
let res =
(CD.diff_show[@alert "-exn"])
w.reference_tree
path
w.running_config
proposed_config
in res
2 changes: 1 addition & 1 deletion src/session.mli
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ val get_config : world -> session_data -> string -> string

val cleanup_config : world -> string -> unit

val show_config : world -> session_data -> string list -> Vyconf_connect.Vyconf_pbt.request_config_format -> string
val show_config : world -> session_data -> string list -> string
3 changes: 1 addition & 2 deletions src/vyconfd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ let list_children world token (req: request_list_children) =

let show_config world token (req: request_show_config) =
try
let fmt = Option.value req.format ~default:Curly in
let conf_str = Session.show_config world (find_session token) req.path fmt in
let conf_str = Session.show_config world (find_session token) req.path in
{response_tmpl with output=(Some conf_str)}
with Session.Session_error msg -> {response_tmpl with status=Fail; error=(Some msg)}

Expand Down