From: Dominik Csapak <d.csapak@proxmox.com>
To: "Proxmox VE development discussion" <pve-devel@lists.proxmox.com>,
"Fabian Grünbichler" <f.gruenbichler@proxmox.com>
Subject: Re: [pve-devel] [PATCH v2 proxmox-backup 03/10] BackupGroup: add filter helper
Date: Thu, 16 Sep 2021 16:46:48 +0200 [thread overview]
Message-ID: <77163464-e42c-bc65-231e-3c3d319ed967@proxmox.com> (raw)
In-Reply-To: <20210915134157.19762-4-f.gruenbichler@proxmox.com>
On 9/15/21 15:41, Fabian Grünbichler wrote:
> to have a single implementation of "group is matched by group filter".
>
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
>
> Notes:
> there might be a better place for this if we want to support more complex
> filters in the future (like, exists in local datastore, or has > X snapshots,
> ..)
>
> pbs-datastore/src/backup_info.rs | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/pbs-datastore/src/backup_info.rs b/pbs-datastore/src/backup_info.rs
> index f77098ee..416a5e32 100644
> --- a/pbs-datastore/src/backup_info.rs
> +++ b/pbs-datastore/src/backup_info.rs
> @@ -1,5 +1,6 @@
> use std::os::unix::io::RawFd;
> use std::path::{Path, PathBuf};
> +use std::str::FromStr;
>
> use anyhow::{bail, format_err, Error};
>
> @@ -10,6 +11,7 @@ use pbs_api_types::{
> GROUP_PATH_REGEX,
> SNAPSHOT_PATH_REGEX,
> BACKUP_FILE_REGEX,
> + GroupFilter,
> };
>
> use super::manifest::MANIFEST_BLOB_NAME;
> @@ -153,6 +155,14 @@ impl BackupGroup {
>
> Ok(last)
> }
> +
> + pub fn filter(&self, filter: &GroupFilter) -> bool {
> + match filter {
> + GroupFilter::Group(backup_group) => &BackupGroup::from_str(&backup_group).unwrap() == self,
if you'd parse the backup group already in the api type, this would not
be necessary
> + GroupFilter::BackupType(backup_type) => self.backup_type() == backup_type,
> + GroupFilter::Regex(regex) => regex.is_match(&format!("{}", self)),
wouldn't &self.to_string() not better?
> + }
> + }
> }
>
> impl std::fmt::Display for BackupGroup {
>
next prev parent reply other threads:[~2021-09-16 14:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 13:41 [pve-devel] [PATCH v2 proxmox-backup 00/10] pull/sync group filter Fabian Grünbichler
2021-09-15 13:41 ` [pve-devel] [PATCH v2 proxmox-backup 01/10] api-types: add schema for backup group Fabian Grünbichler
2021-09-15 13:41 ` [pve-devel] [PATCH v2 proxmox-backup 02/10] api: add GroupFilter(List) type Fabian Grünbichler
2021-09-16 14:46 ` Dominik Csapak
2021-09-17 6:39 ` Fabian Grünbichler
2021-09-15 13:41 ` [pve-devel] [PATCH v2 proxmox-backup 03/10] BackupGroup: add filter helper Fabian Grünbichler
2021-09-16 14:46 ` Dominik Csapak [this message]
2021-09-15 13:41 ` [pve-devel] [PATCH v2 proxmox-backup 04/10] pull: use BackupGroup consistently Fabian Grünbichler
2021-09-15 13:41 ` [pve-devel] [PATCH v2 proxmox-backup 05/10] pull: allow pulling groups selectively Fabian Grünbichler
2021-09-15 13:41 ` [pve-devel] [PATCH v2 proxmox-backup 06/10] sync: add group filtering Fabian Grünbichler
2021-09-16 7:19 ` Thomas Lamprecht
2021-09-16 7:44 ` Fabian Grünbichler
2021-09-17 12:33 ` Dominik Csapak
2021-09-15 13:41 ` [pve-devel] [PATCH v2 proxmox-backup 07/10] remote: add backup group scanning Fabian Grünbichler
2021-09-15 13:41 ` [pve-devel] [PATCH v2 proxmox-backup 08/10] manager: extend sync/pull completion Fabian Grünbichler
2021-09-15 13:41 ` [pve-devel] [PATCH v2 proxmox-backup 09/10] manager: render group filter properly Fabian Grünbichler
2021-09-15 13:41 ` [pve-devel] [PATCH v2 proxmox-backup 10/10] docs: mention group filter in sync docs Fabian Grünbichler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=77163464-e42c-bc65-231e-3c3d319ed967@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=f.gruenbichler@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox