From: Hannes Laimer <h.laimer@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH proxmox 2/3] pve-api-types: add regex for both storage- and bridge-pair
Date: Tue, 21 Oct 2025 15:50:16 +0200 [thread overview]
Message-ID: <20251021135018.88877-3-h.laimer@proxmox.com> (raw)
In-Reply-To: <20251021135018.88877-1-h.laimer@proxmox.com>
These are used for target storage and bridge mappings in remote
migrations. For the list items we don't really need a verifier function
so remove them and add regexes instead.
What this is not doing is check for uniqueness of mappings in the list,
but that is not really possible. Since we can't currently have verifiers
on fields that are not strings.
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
pve-api-types/generate.pl | 11 +++++++----
pve-api-types/src/types/verifiers.rs | 10 ----------
2 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/pve-api-types/generate.pl b/pve-api-types/generate.pl
index 75729b3c..9ea9aa4f 100644
--- a/pve-api-types/generate.pl
+++ b/pve-api-types/generate.pl
@@ -31,6 +31,9 @@ Schema2Rust::init_api($pve_api->{root}, \&lookup_format);
# From JSONSchema.pm, but we can't use perl-re directly, particularly `qr//`...
my $CONFIGID_RE = '^(?i:[a-z][a-z0-9_-]+)$';
+my $STORAGEID_RE = '(?i:[a-z][a-z0-9\-_.]*[a-z0-9])';
+my $BRIDGEID_RE = '[-_.\w\d]+';
+
# Disable `#[api]` generation for now, it's incomplete/untested.
#$Schema2Rust::API = 0;
@@ -41,7 +44,7 @@ Schema2Rust::register_format('ipv4mask' => { code => 'verifiers::verify_ipv4_mas
Schema2Rust::register_format('mac-addr' => { regex => '^(?i)[a-f0-9][02468ace](?::[a-f0-9]{2}){5}$' });
## Schema2Rust::register_format('pve-acme-alias' => { code => 'verify_pve_acme_alias' });
## Schema2Rust::register_format('pve-acme-domain' => { code => 'verify_pve_acme_domain' });
-Schema2Rust::register_format('pve-bridge-id' => { regex => '^[-_.\w\d]+$' });
+Schema2Rust::register_format('pve-bridge-id' => { regex => '^'.$BRIDGEID_RE.'$' });
Schema2Rust::register_format('pve-configid' => { regex => $CONFIGID_RE });
## Schema2Rust::register_format('pve-groupid' => { code => 'verify_pve_groupid' });
Schema2Rust::register_format('pve-userid' => { code => 'verify_pve_userid' });
@@ -59,7 +62,7 @@ Schema2Rust::register_format('pve-qm-bootdev' => { unchecked => 1 });
Schema2Rust::register_format('pve-qm-bootdisk' => { regex => '^(ide|sata|scsi|virtio|efidisk|tpmstate)\d+$' });
Schema2Rust::register_format('pve-qm-usb-device' => { unchecked => 1 });
Schema2Rust::register_format('pve-startup-order' => { unchecked => 1 });
-Schema2Rust::register_format('pve-storage-id' => { regex => '^(?i:[a-z][a-z0-9\-_.]*[a-z0-9])$' });
+Schema2Rust::register_format('pve-storage-id' => { regex => '^'.$STORAGEID_RE.'$' });
Schema2Rust::register_format('pve-storage-content' => { type => 'StorageContent' });
Schema2Rust::register_format('pve-tag' => { regex => '^(?i)[a-z0-9_][a-z0-9_\-+.]*$' });
Schema2Rust::register_format('pve-volume-id' => { code => 'verifiers::verify_volume_id' });
@@ -75,8 +78,8 @@ Schema2Rust::register_format('lxc-ip-with-ll-iface' => { code => 'verifiers::ver
Schema2Rust::register_format('pve-ct-timezone' => { regex => '^.*/.*$' });
Schema2Rust::register_format('pve-lxc-dev-string' => { code => 'verifiers::verify_pve_lxc_dev_string' });
##
-Schema2Rust::register_format('storage-pair' => { code => 'verifiers::verify_storage_pair' });
-Schema2Rust::register_format('bridge-pair' => { code => 'verifiers::verify_bridge_pair' });
+Schema2Rust::register_format('storage-pair' => { regex => '^'.$STORAGEID_RE.':'.$STORAGEID_RE.'|'.$STORAGEID_RE.'|1$' });
+Schema2Rust::register_format('bridge-pair' => { regex => '^'.$BRIDGEID_RE.':'.$BRIDGEID_RE.'|'.$BRIDGEID_RE.'|1$' });
Schema2Rust::register_format('pve-task-status-type' => { regex => '^(?i:ok|error|warning|unknown)$' });
diff --git a/pve-api-types/src/types/verifiers.rs b/pve-api-types/src/types/verifiers.rs
index caefba1a..092893b3 100644
--- a/pve-api-types/src/types/verifiers.rs
+++ b/pve-api-types/src/types/verifiers.rs
@@ -194,16 +194,6 @@ pub fn verify_ip_with_ll_iface(s: &str) -> Result<(), Error> {
verify_ip(s)
}
-pub fn verify_storage_pair(_s: &str) -> Result<(), Error> {
- // FIXME: Implement this!
- Ok(())
-}
-
-pub fn verify_bridge_pair(_s: &str) -> Result<(), Error> {
- // FIXME: Implement this!
- Ok(())
-}
-
pub fn verify_pve_lxc_dev_string(s: &str) -> Result<(), Error> {
if !s.starts_with("/dev") || s.ends_with("/..") || s.contains("/..") {
bail!("not a valid device string");
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-10-21 13:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-21 13:50 [pdm-devel] [PATCH proxmox{, -datacenter-manager} 0/4] generate Vec's for string-lists Hannes Laimer
2025-10-21 13:50 ` [pdm-devel] [PATCH proxmox 1/3] pve-api-types: schema2rust: generate arrays for types with format `-list` Hannes Laimer
2025-10-21 13:50 ` Hannes Laimer [this message]
2025-10-21 13:50 ` [pdm-devel] [PATCH proxmox 3/3] pve-api-types: regenerate Hannes Laimer
2025-10-21 13:50 ` [pdm-devel] [PATCH proxmox-datacenter-manager 1/1] server: use types indead of string for migration parameters Hannes Laimer
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=20251021135018.88877-3-h.laimer@proxmox.com \
--to=h.laimer@proxmox.com \
--cc=pdm-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.