all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH common 3/3] JSONSchema: disable '-alist' format
Date: Fri, 12 May 2023 14:23:50 +0200	[thread overview]
Message-ID: <20230512122355.3244212-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20230512122355.3244212-1-d.csapak@proxmox.com>

this should not be needed anymore since we can now use a simple array
in the api instead

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
this breaks all packages which have an '-alist' format defined
 src/PVE/JSONSchema.pm | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 526fc2b..b148ce9 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -795,7 +795,7 @@ sub check_format {
     return if $format eq 'regex';
 
     my $parsed;
-    $format =~ m/^(.*?)(?:-a?(list|opt))?$/;
+    $format =~ m/^(.*?)(?:-(list|opt))?$/;
     my ($format_name, $format_type) = ($1, $2 // 'none');
     my $registered = get_format($format_name);
     die "undefined format '$format'\n" if !$registered;
@@ -1707,7 +1707,7 @@ sub get_options {
 	} elsif ($pd->{type} eq 'boolean') {
 	    push @getopt, "$prop:s";
 	} else {
-	    if ($pd->{format} && $pd->{format} =~ m/-a?list/) {
+	    if ($pd->{format} && $pd->{format} =~ m/-list/) {
 		push @getopt, "$prop=s@";
 	    } elsif ($pd->{type} eq 'array') {
 		push @getopt, "$prop=s@";
@@ -1812,16 +1812,6 @@ sub get_options {
 		    # allow --vmid 100 --vmid 101 and --vmid 100,101
 		    # allow --dow mon --dow fri and --dow mon,fri
 		    $opts->{$p} = join(",", @{$opts->{$p}}) if ref($opts->{$p}) eq 'ARRAY';
-		} elsif ($pd->{format} =~ m/-alist/) {
-		    # we encode array as \0 separated strings
-		    # Note: CGI.pm also use this encoding
-		    if (scalar(@{$opts->{$p}}) != 1) {
-			$opts->{$p} = join("\0", @{$opts->{$p}});
-		    } else {
-			# st that split_list knows it is \0 terminated
-			my $v = $opts->{$p}->[0];
-			$opts->{$p} = "$v\0";
-		    }
 		}
 	    }
 	}
-- 
2.30.2





  parent reply	other threads:[~2023-05-12 12:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12 12:23 [pve-devel] [PATCH common/manager/http/guest/qemu-server] schema/config array support Dominik Csapak
2023-05-12 12:23 ` [pve-devel] [PATCH common 1/3] JSONSchema: add support for array parameter in api calls, cli and config Dominik Csapak
2023-06-05  8:36   ` Wolfgang Bumiller
2023-05-12 12:23 ` [pve-devel] [PATCH v2 common 2/3] section config: implement array support Dominik Csapak
2023-05-15  9:07   ` Wolfgang Bumiller
2023-05-15  9:19     ` Dominik Csapak
2023-05-12 12:23 ` Dominik Csapak [this message]
2023-06-05  8:36   ` [pve-devel] [PATCH common 3/3] JSONSchema: disable '-alist' format Wolfgang Bumiller
2023-05-12 12:23 ` [pve-devel] [PATCH manager 1/1] vzdump: prepare 'exclude-path' for array format Dominik Csapak
2023-06-05  7:36   ` Wolfgang Bumiller
2023-06-05  7:54     ` Dominik Csapak
2023-06-05  7:59       ` Wolfgang Bumiller
2023-06-05  8:03   ` [pve-devel] applied: " Wolfgang Bumiller
2023-05-12 12:23 ` [pve-devel] [PATCH http-server 1/2] proxy request: forward json content type and parameters Dominik Csapak
2023-06-05  8:42   ` Wolfgang Bumiller
2023-05-12 12:23 ` [pve-devel] [PATCH http-server 2/2] use proper arrays for array parameter Dominik Csapak
2023-05-12 12:23 ` [pve-devel] [PATCH guest-common 1/1] vzdump: change 'exclude-path' from alist to an array format Dominik Csapak
2023-06-05  8:37   ` [pve-devel] [PATCH guest-common 1/1] vzdump: change 'exclude-path' from alist to an array formaty Wolfgang Bumiller
2023-05-12 12:23 ` [pve-devel] [PATCH qemu-server 1/1] api: switch agent api call to 'array' type Dominik Csapak
2023-06-05  8:38   ` Wolfgang Bumiller

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=20230512122355.3244212-4-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal