Skip to content

Commit

Permalink
NOCDEV-14336: fix deleting keys from json fragment configs (#55)
Browse files Browse the repository at this point in the history
Currently we can not delete top level keys from json fragment
configs, because we can not match acl pointer to empty dict.
Fixed by deleting mathing part from the old config

Co-authored-by: Vlad Starostin <[email protected]>
  • Loading branch information
drtyrsa and Vlad Starostin authored Jul 9, 2024
1 parent 20067f0 commit baf961a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion annet/annlib/jsontools.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def apply_json_fragment(
try:
new_value = pointer.get(new_fragment)
except jsonpointer.JsonPointerException:
# no value found in new_fragment by the pointer, skip the ACL item
# no value found in new_fragment by the pointer,
# try to delete it from the new config
doc, part = pointer.to_last(full_new_config)
if isinstance(doc, dict) and isinstance(part, str):
doc.pop(part, None)
continue

_ensure_pointer_exists(full_new_config, pointer)
Expand Down

0 comments on commit baf961a

Please sign in to comment.