summaryrefslogtreecommitdiff
path: root/src/session.ml
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-11-20 07:51:45 -0600
committerGitHub <noreply@github.com>2025-11-20 07:51:45 -0600
commitb5a3d62714bc47f5187a10c8ad0773c9e655e9e4 (patch)
tree31b946b5ecc48fa17851f3d2ae02acd482c9f0c9 /src/session.ml
parent591dd5ee3dc353655a3c9b17eababaf0864c5514 (diff)
parent954c63727874b33fc221197b60042439330d13bd (diff)
downloadvyconf-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/session.ml')
-rw-r--r--src/session.ml36
1 files changed, 11 insertions, 25 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