summaryrefslogtreecommitdiff
path: root/src/reference_tree.ml
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2026-05-11 14:46:45 +0100
committerGitHub <noreply@github.com>2026-05-11 14:46:45 +0100
commite80771d973fc249ab04fd20a6bb2463698194880 (patch)
treed3526b7b77046cd7eaee0978d7f93eda0cc9d754 /src/reference_tree.ml
parente6a61be086172b7a4a53d99931c0e0057e6b5916 (diff)
parentf858e82c5d1ee62110911183f6b5efb50564dc62 (diff)
downloadvyos1x-config-e80771d973fc249ab04fd20a6bb2463698194880.tar.gz
vyos1x-config-e80771d973fc249ab04fd20a6bb2463698194880.zip
Merge pull request #68 from jestabro/mask-exclusive
T8488: add mask exclusive and supporting utilitlies
Diffstat (limited to 'src/reference_tree.ml')
-rw-r--r--src/reference_tree.ml27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/reference_tree.ml b/src/reference_tree.ml
index 8ff7b54..dead1be 100644
--- a/src/reference_tree.ml
+++ b/src/reference_tree.ml
@@ -648,6 +648,33 @@ let refpath reftree path =
| _, [] -> acc
in aux [] path
+(* Convert from partial config path to reference tree path.
+ 'Partial' here means that there may or may not be intervening tag node
+ values.
+ *)
+let refpath_from_partial reftree path =
+ let check_existence p =
+ match p with
+ | [] -> false
+ | _ -> (Vytree.exists[@alert "-exn"]) reftree p
+ in
+ let rec aux acc p =
+ match acc, p with
+ | [], h :: tl ->
+ if check_existence [h] then aux [h] tl else []
+ | _, [h] ->
+ let p = acc @ [h] in
+ if check_existence p then p else
+ if is_tag reftree acc then acc else []
+ | _, h :: h' :: tl ->
+ let p = acc @ [h] in
+ if check_existence p then aux p ([h'] @ tl) else
+ let p = acc @ [h'] in
+ if is_tag reftree acc && check_existence p then aux p tl
+ else []
+ | _, [] -> acc
+ in aux [] path
+
let set_tag_data rtree ctree path =
(* raises:
[Vytree.Empty_path],