diff options
author | John Estabrook <jestabro@vyos.io> | 2024-10-23 18:50:46 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2024-10-27 21:47:33 -0500 |
commit | bd17726d30991619eca09bfe478659915bc12fe4 (patch) | |
tree | ea957c5f2b154e4661c88baf50074f17488a9c58 /src/session.ml | |
parent | 75441a50c50f65f580d6919ed6c4f282fd842e49 (diff) | |
download | vyconf-bd17726d30991619eca09bfe478659915bc12fe4.tar.gz vyconf-bd17726d30991619eca09bfe478659915bc12fe4.zip |
T6718: add independent validate field and methods
Diffstat (limited to 'src/session.ml')
-rw-r--r-- | src/session.ml | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/session.ml b/src/session.ml index db3b039..a8eccad 100644 --- a/src/session.ml +++ b/src/session.ml @@ -64,9 +64,17 @@ let rec apply_changes changeset config = | [] -> config | c :: cs -> apply_changes cs (apply_cfg_op c config) +let validate w _s path = + try + RT.validate_path D.(w.dirs.validators) w.reference_tree path + with RT.Validation_error x -> raise (Session_error x) + +let split_path w _s path = + RT.split_path w.reference_tree path + let set w s path = - let path, value = RT.validate_path D.(w.dirs.validators) - w.reference_tree path in + let _ = validate w s path in + let path, value = split_path w s path in let refpath = RT.refpath w.reference_tree path in let value_behaviour = if RT.is_multi w.reference_tree refpath then CT.AddValue else CT.ReplaceValue in let op = CfgSet (path, value, value_behaviour) in @@ -74,8 +82,8 @@ let set w s path = {s with proposed_config=config; changeset=(op :: s.changeset)} let delete w s path = - let path, value = RT.validate_path D.(w.dirs.validators) - w.reference_tree path in + let _ = validate w s path in + let path, value = split_path w s path in let op = CfgDelete (path, value) in let config = apply_cfg_op op s.proposed_config in {s with proposed_config=config; changeset=(op :: s.changeset)} |