[pdm-devel] [PATCH datacenter-manager v3 01/11] pdm-api-types: views: add ViewConfig type
Lukas Wagner
l.wagner at proxmox.com
Wed Nov 12 11:04:51 CET 2025
On Tue Nov 11, 2025 at 11:57 AM CET, Michael Köppl wrote:
> 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/<remote>/guest/<vmid>'.
>> + 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<Self, Self::Err> {
>> + 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?
>
Well, the plan is to define a schema and then use it for validation :D
It's not super critical to validate the format here (worst case, somebody
defines a rule which can never match a real resource), so I think this
can be done in a follow-up. In the follow-up the schema should then be
used in a few other places in the code as well.
More information about the pdm-devel
mailing list