summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-12-08 21:05:52 -0600
committerJohn Estabrook <jestabro@vyos.io>2025-12-17 21:13:45 -0600
commitb303da3489a24181eff531ea01423b697f24bed3 (patch)
tree5c94f49962f753bb78777a31567d40ecc8d603ff /src
parent52b0ff3942ce984a0b65e73b109fe05837323efb (diff)
downloadvyos1x-config-b303da3489a24181eff531ea01423b697f24bed3.tar.gz
vyos1x-config-b303da3489a24181eff531ea01423b697f24bed3.zip
T8061: add function get_default_value
Diffstat (limited to 'src')
-rw-r--r--src/reference_tree.ml11
-rw-r--r--src/reference_tree.mli4
2 files changed, 15 insertions, 0 deletions
diff --git a/src/reference_tree.ml b/src/reference_tree.ml
index c78529e..4532135 100644
--- a/src/reference_tree.ml
+++ b/src/reference_tree.ml
@@ -605,6 +605,17 @@ let get_completion_data reftree path =
in
List.map aux (Vytree.children_of_node @@ (Vytree.get[@alert "-exn"]) reftree path)
+let get_default_value reftree path =
+ (* raises:
+ [Vytree.Empty_path]
+ [Vytree.Nonexistent_path]
+ alert exn Vytree.get_data:
+ [Vytree.Empty_path] allow raise
+ [Vytree.Nonexistent_path] allow raise
+ *)
+ let data = (Vytree.get_data[@alert "-exn"]) reftree path in
+ data.default_value
+
(* Convert from config path to reference tree path *)
let refpath reftree path =
let check_existence p =
diff --git a/src/reference_tree.mli b/src/reference_tree.mli
index dd8230d..5bb74bc 100644
--- a/src/reference_tree.mli
+++ b/src/reference_tree.mli
@@ -107,6 +107,10 @@ val get_completion_data : t -> string list -> (node_type * bool * string) list
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Vytree.Nonexistent_path"]
+val get_default_value : t -> string list -> string option
+[@@alert exn "Vytree.Empty_path"]
+[@@alert exn "Vytree.Nonexistent_path"]
+
val refpath : t -> string list -> string list
val set_tag_data : t -> Config_tree.t -> string list -> Config_tree.t