From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 525121FF17A for ; Tue, 11 Nov 2025 11:57:13 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9E5FC6898; Tue, 11 Nov 2025 11:57:59 +0100 (CET) Date: Tue, 11 Nov 2025 11:57:56 +0100 Message-Id: From: =?utf-8?q?Michael_K=C3=B6ppl?= To: "Proxmox Datacenter Manager development discussion" Cc: "pdm-devel" Mime-Version: 1.0 X-Mailer: aerc 0.21.0 References: <20251106134353.263598-1-l.wagner@proxmox.com> <20251106134353.263598-2-l.wagner@proxmox.com> In-Reply-To: <20251106134353.263598-2-l.wagner@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762858653185 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.037 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pdm-devel] [PATCH datacenter-manager v3 01/11] pdm-api-types: views: add ViewConfig type X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" On Thu Nov 6, 2025 at 2:43 PM CET, Lukas Wagner wrote: > +#[derive(Clone, Debug, PartialEq)] > +/// Filter rule for includes/excludes. > +pub enum FilterRule { > + /// Match a resource type. > + ResourceType(ResourceType), > + /// Match a resource pools (for PVE guests). > + ResourcePool(String), > + /// Match a (global) resource ID, e.g. 'remote//guest/'. > + ResourceId(String), > + /// Match a tag (for PVE guests). > + Tag(String), > + /// Match a remote. > + Remote(String), > +} > + > +impl FromStr for FilterRule { > + type Err = anyhow::Error; > + > + fn from_str(s: &str) -> Result { > + Ok(match s.split_once(':') { > + Some(("resource-type", value)) => FilterRule::ResourceType(value.parse()?), > + Some(("resource-pool", value)) => { > + if !SAFE_ID_FORMAT.unwrap_pattern_format().is_match(value) { > + bail!("invalid tag value: {value}"); > + } > + FilterRule::ResourcePool(value.to_string()) > + } > + Some(("resource-id", value)) => { > + // TODO: Define schema and use it to validate. Can't use SAFE_ID_FORMAT since it does > + // not allow '/'. Is there a plan for this TODO? > + if value.is_empty() { > + bail!("empty resource-id rule not allowed"); > + } > + FilterRule::ResourceId(value.to_string()) > + } > + Some(("tag", value)) => { > + if !SAFE_ID_FORMAT.unwrap_pattern_format().is_match(value) { > + bail!("invalid tag value: {value}"); > + } > + FilterRule::Tag(value.to_string()) > + } > + Some(("remote", value)) => { > + let _ = REMOTE_ID_SCHEMA.parse_simple_value(value)?; > + FilterRule::Remote(value.to_string()) > + } > + Some((ty, _)) => bail!("invalid type: {ty}"), > + None => bail!("invalid filter rule: {s}"), > + }) > + } > +} _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel