[pve-devel] [PATCH common v7 2/2] JSONSchema: pve-tag: add syntax for 'admin' tags
Dominik Csapak
d.csapak at proxmox.com
Tue Jun 21 11:19:50 CEST 2022
by prefixing the tag with '+'
these can be useful to distinguish tags set by a 'normal' user, and an
admin. This patch is only useful with additional patches that
check those permissions while setting the tags though.
i chose a syntax that was invalid before, but does not add
unnecessary overhead. Additionally, the character was allowed (but not
as first), so there should problem arise from that.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/PVE/JSONSchema.pm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 54c149d..bf2c9ca 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -696,7 +696,7 @@ register_standard_option('proxmox-remote', {
type => 'string', format => 'proxmox-remote',
});
-our $PVE_TAG_RE = qr/[a-z0-9_][a-z0-9_\-\+\.]*/i;
+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);
@@ -710,6 +710,13 @@ sub pve_verify_tag {
die "invalid characters in tag\n";
}
+sub is_admin_pve_tag {
+ my ($tag) = @_;
+ return undef if !defined($tag);
+ return 1 if $tag =~ m/^\+/;
+ return 0;
+}
+
sub pve_parse_startup_order {
my ($value) = @_;
--
2.30.2
More information about the pve-devel
mailing list