]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
mgr/smb: replace cross check if-block with singledispatch
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 2 Jul 2025 18:06:21 +0000 (14:06 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 2 Jul 2025 20:29:41 +0000 (16:29 -0400)
commitf0ffb26b80627931096d2e8283613a9310fbca9c
tree6a21cc9ce1f5627d6a3568e68706f03dbf6c1065
parent978e92fb68a1717a2713017382bfb5fbe9a24e63
mgr/smb: replace cross check if-block with singledispatch

The previous code relied on a cascading block of if-isintance statements
that was dense and somwehat error prone as I found out during an
experiment to add a new top level resource type. Refactor the cross
check function to use singledispatch:
  https://docs.python.org/3.9/library/functools.html#functools.singledispatch

Now instead of correctly adding check function(s) and updating the
if-block, only new check functions using the register decorator is
needed.

Note that making this checking more generic is difficult as each
different resource type really has different cross checking needs.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/staging.py