From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id DAFAD9D7B7
 for <pve-devel@lists.proxmox.com>; Mon,  5 Jun 2023 09:55:20 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id B890824771
 for <pve-devel@lists.proxmox.com>; Mon,  5 Jun 2023 09:54:50 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pve-devel@lists.proxmox.com>; Mon,  5 Jun 2023 09:54:50 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E6574489B6;
 Mon,  5 Jun 2023 09:54:49 +0200 (CEST)
Message-ID: <fec9228c-13b7-15a7-f6b0-1ab8583c9a5d@proxmox.com>
Date: Mon, 5 Jun 2023 09:54:49 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: Wolfgang Bumiller <w.bumiller@proxmox.com>
Cc: pve-devel@lists.proxmox.com
References: <20230512122355.3244212-1-d.csapak@proxmox.com>
 <20230512122355.3244212-5-d.csapak@proxmox.com>
 <rn7of3wm3kv5425aile3ejyjc7u4le35fzhyt26agtrg3caquc@gnzwzh7ryqhh>
Content-Language: en-US
From: Dominik Csapak <d.csapak@proxmox.com>
In-Reply-To: <rn7of3wm3kv5425aile3ejyjc7u4le35fzhyt26agtrg3caquc@gnzwzh7ryqhh>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.015 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
Subject: Re: [pve-devel] [PATCH manager 1/1] vzdump: prepare 'exclude-path'
 for array format
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 05 Jun 2023 07:55:20 -0000

On 6/5/23 09:36, Wolfgang Bumiller wrote:
> On Fri, May 12, 2023 at 02:23:51PM +0200, Dominik Csapak wrote:
>> we want to move the 'exclude-path' to an array format (from 'string-alist')
>> prepare the code that it can be either a string or a list
>>
>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>> ---
>>   PVE/VZDump.pm | 21 +++++++++++++++++----
>>   1 file changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
>> index a04837e7e..dde347562 100644
>> --- a/PVE/VZDump.pm
>> +++ b/PVE/VZDump.pm
>> @@ -279,7 +279,15 @@ sub read_vzdump_defaults {
>>       my $conf_schema = { type => 'object', properties => $confdesc_for_defaults };
>>       my $res = PVE::JSONSchema::parse_config($conf_schema, $fn, $raw);
>>       if (my $excludes = $res->{'exclude-path'}) {
>> -	$res->{'exclude-path'} = PVE::Tools::split_args($excludes);
>> +	if (ref($excludes) eq 'ARRAY') {
>> +	    my $list = [];
>> +	    for my $path ($excludes->@*) {
>> +		push $list->@*, PVE::Tools::split_args($path)->@*;
> 
> With this being an array, I don't think it makes sense to call
> `split_args()` on the individual items?

actually we have to do this to keep compatibility with current configs:

currently users can put things like this in the config:

exclude-path: /foo /bar

and both paths will be excluded

if we omit the splitting we'd have to rewrite the configs to:

exclude-path: /foo
exclude-path: /bar

while we could do that, i opted here for the simpler approach to handle
the lines the same, without need to break existing configs
and/or rewriting configs on upgrade

> 
>> +	    }
>> +	    $res->{'exclude-path'} = $list;
>> +	} else {
>> +	    $res->{'exclude-path'} = PVE::Tools::split_args($excludes);
>> +	}
>>       }
>>       if (defined($res->{mailto})) {
>>   	my @mailto = split_list($res->{mailto});
>> @@ -1339,10 +1347,15 @@ sub option_exists {
>>   sub parse_mailto_exclude_path {
>>       my ($param) = @_;
>>   
>> -    # exclude-path list need to be 0 separated
>> +    # exclude-path list need to be 0 separated or be an array
>>       if (defined($param->{'exclude-path'})) {
>> -	my @expaths = split(/\0/, $param->{'exclude-path'} || '');
>> -	$param->{'exclude-path'} = [ @expaths ];
>> +	my $expaths;
>> +	if (ref($param->{'exclude-path'}) eq 'ARRAY') {
>> +	    $expaths = $param->{'exclude-path'};
>> +	} else {
>> +	    $expaths = [split(/\0/, $param->{'exclude-path'} || '')];
>> +	}
>> +	$param->{'exclude-path'} = $expaths;
>>       }
>>   
>>       if (defined($param->{mailto})) {
>> -- 
>> 2.30.2