api types: add remote acl path method for BackupNamespace

Add a `remote_acl_path` helper method for creating acl paths for
remote namespaces, to be used by the priv checks on remote datastore
namespaces for e.g. the sync job in push direction.

Factor out the common path extension into a dedicated method.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2024-11-11 16:43:30 +01:00 committed by Fabian Grünbichler
parent aa273905d7
commit ae56a50b9d

View File

@ -722,9 +722,7 @@ impl BackupNamespace {
Ok(())
}
pub fn acl_path<'a>(&'a self, store: &'a str) -> Vec<&'a str> {
let mut path: Vec<&str> = vec!["datastore", store];
fn acl_path_extend<'a>(&'a self, mut path: Vec<&'a str>) -> Vec<&'a str> {
if self.is_root() {
path
} else {
@ -733,6 +731,14 @@ impl BackupNamespace {
}
}
pub fn acl_path<'a>(&'a self, store: &'a str) -> Vec<&'a str> {
self.acl_path_extend(vec!["datastore", store])
}
pub fn remote_acl_path<'a>(&'a self, remote: &'a str, store: &'a str) -> Vec<&'a str> {
self.acl_path_extend(vec!["remote", remote, store])
}
/// Check whether this namespace contains another namespace.
///
/// If so, the depth is returned.