[pve-devel] [PATCH common v7 1/2] JSONSchema: refactor tag regex

Dominik Csapak d.csapak at proxmox.com
Tue Jun 21 11:19:49 CEST 2022


we'll use that elsewhere too

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/JSONSchema.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index ab718f3..54c149d 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -696,12 +696,14 @@ register_standard_option('proxmox-remote', {
     type => 'string', format => 'proxmox-remote',
 });
 
+our $PVE_TAG_RE = qr/[a-z0-9_][a-z0-9_\-\+\.]*/i;
+
 # used for pve-tag-list in e.g., guest configs
 register_format('pve-tag', \&pve_verify_tag);
 sub pve_verify_tag {
     my ($value, $noerr) = @_;
 
-    return $value if $value =~ m/^[a-z0-9_][a-z0-9_\-\+\.]*$/i;
+    return $value if $value =~ m/^${PVE_TAG_RE}$/i;
 
     return undef if $noerr;
 
-- 
2.30.2





More information about the pve-devel mailing list