summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-08-19 08:49:24 -0500
committerGitHub <noreply@github.com>2025-08-19 08:49:24 -0500
commit88d926d30b4219c50bbb1167ab58d60c5c5d2bbb (patch)
tree70c091e37ea90e8bc42e9a812a086804a20fb777 /src
parent29e73893a0fc942a96abc06dfa037afd71778d27 (diff)
parentc652a90ef4a5b4a78b48a390e59370b73b591f50 (diff)
downloadvyconf-88d926d30b4219c50bbb1167ab58d60c5c5d2bbb.tar.gz
vyconf-88d926d30b4219c50bbb1167ab58d60c5c5d2bbb.zip
Merge pull request #29 from jestabro/validate-tree
T7718: use revised validate_tree
Diffstat (limited to 'src')
-rw-r--r--src/session.ml24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/session.ml b/src/session.ml
index 5cd5027..31bd411 100644
--- a/src/session.ml
+++ b/src/session.ml
@@ -75,17 +75,8 @@ let validate w _s path =
RT.validate_path D.(w.dirs.validators) w.reference_tree path
with RT.Validation_error x -> raise (Session_error x)
-let validate_tree w' t =
- let validate_path w out path =
- let res =
- try
- RT.validate_path D.(w.dirs.validators) w.reference_tree path;
- out
- with RT.Validation_error x -> out ^ x
- in res
- in
- let paths = CT.value_paths_of_tree t in
- let out = List.fold_left (validate_path w') "" paths in
+let validate_tree w t =
+ let out = RT.validate_tree D.(w.dirs.validators) w.reference_tree t in
match out with
| "" -> ()
| _ -> raise (Session_error out)
@@ -110,22 +101,13 @@ let set w s path =
in
{s with proposed_config=config; changeset=(op :: s.changeset)}
-let prune_del_path node path =
- if CT.is_tag_value node path then
- let tag_path = Vyos1x.Util.drop_last path in
- let terminal = VT.is_terminal_path node tag_path in
- match terminal with
- | true -> CT.delete node tag_path None
- | false -> node
- else node
-
let delete w s path =
let path, value = split_path w s path in
let op = CfgDelete (path, value) in
let config =
try
apply_cfg_op op s.proposed_config |>
- (fun c -> prune_del_path c path)
+ (fun c -> CT.prune_delete c path)
with
| VT.Nonexistent_path | CT.No_such_value -> s.proposed_config
in