diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-11-20 07:51:45 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-20 07:51:45 -0600 |
| commit | b5a3d62714bc47f5187a10c8ad0773c9e655e9e4 (patch) | |
| tree | 31b946b5ecc48fa17851f3d2ae02acd482c9f0c9 /src | |
| parent | 591dd5ee3dc353655a3c9b17eababaf0864c5514 (diff) | |
| parent | 954c63727874b33fc221197b60042439330d13bd (diff) | |
| download | vyconf-b5a3d62714bc47f5187a10c8ad0773c9e655e9e4.tar.gz vyconf-b5a3d62714bc47f5187a10c8ad0773c9e655e9e4.zip | |
Merge pull request #35 from jestabro/show-config
T7988: return difference of running and proposed config for show_config
Diffstat (limited to 'src')
| -rw-r--r-- | src/session.ml | 36 | ||||
| -rw-r--r-- | src/session.mli | 2 | ||||
| -rw-r--r-- | src/vyconfd.ml | 3 |
3 files changed, 13 insertions, 28 deletions
diff --git a/src/session.ml b/src/session.ml index 46f1b36..03c5f91 100644 --- a/src/session.ml +++ b/src/session.ml @@ -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 diff --git a/src/session.mli b/src/session.mli index f8327db..cb3f37a 100644 --- a/src/session.mli +++ b/src/session.mli @@ -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 diff --git a/src/vyconfd.ml b/src/vyconfd.ml index dee5535..c09c4f4 100644 --- a/src/vyconfd.ml +++ b/src/vyconfd.ml @@ -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)} |
