[pve-devel] [PATCH v2 common 2/3] section config: implement array support
Wolfgang Bumiller
w.bumiller at proxmox.com
Mon May 15 11:07:57 CEST 2023
On Fri, May 12, 2023 at 02:23:49PM +0200, Dominik Csapak wrote:
> enables section configs in the style of:
>
> ----
> type: id
> property value
> property value2
> property value3
> ----
>
> can be combined with property strings
>
> the provided create and update schema just pass through the array type
> to the api, so the api call must always contain the complete array
>
> also adds a test case for such array fields
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> changes from v1:
> * don't special encode arrays anymore, but instead have always the whole
> array as parameter in the create/updateSchema
> src/PVE/SectionConfig.pm | 64 +++++++++++++++++++++++++++----------
> test/section_config_test.pl | 26 +++++++++++++++
> 2 files changed, 74 insertions(+), 16 deletions(-)
>
> diff --git a/src/PVE/SectionConfig.pm b/src/PVE/SectionConfig.pm
> index f36cede..03f6a52 100644
> --- a/src/PVE/SectionConfig.pm
> +++ b/src/PVE/SectionConfig.pm
> @@ -51,6 +51,17 @@ sub plugindata {
> return {};
> }
>
> +my $copy_property = sub {
If you're moving it, maybe *re*move it and change the single
caller of it to just do `{ %$src }`, since that's all this does ;-)
> + my ($src) = @_;
> +
> + my $res = {};
> + foreach my $k (keys %$src) {
> + $res->{$k} = $src->{$k};
> + }
> +
> + return $res;
> +};
> +
> sub createSchema {
> my ($class, $skip_type) = @_;
>
More information about the pve-devel
mailing list