From 7ccdc805e366aa6f62ea0542de9e8bdc95e78b8c Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 17 Nov 2023 09:05:36 +0100 Subject: [PATCH] section config: avoid unamed boolean parameter use hash Even with just one param it's extra work to check what it refers too, with named ones in a hash one hasn't that issue even with many params. Signed-off-by: Thomas Lamprecht --- src/PVE/SectionConfig.pm | 12 ++++++++++-- test/section_config_property_isolation_test.pl | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/PVE/SectionConfig.pm b/src/PVE/SectionConfig.pm index fb1192b..a18e9d8 100644 --- a/src/PVE/SectionConfig.pm +++ b/src/PVE/SectionConfig.pm @@ -61,7 +61,7 @@ use PVE::Tools; # calling init with `1` as its parameter like this: # # ``` -# PVE::Dummy::BasePlugin->init(1); +# PVE::Dummy::BasePlugin->init(property_isolation => 1); # ``` # # With this, each plugin get's their own isolated list of properties which it @@ -326,8 +326,16 @@ sub updateSchema { }; } +# the %param hash controls some behavior of the section config, currently the following options are +# understood: +# +# - property_isolation: if set, each child-plugin has a fully isolated property (schema) namespace. +# By default this is off, meaning all child-plugins share the schema of properties with the same +# name. Normally one wants to use oneOf schema's when enabling isolation. sub init { - my ($class, $property_isolation) = @_; + my ($class, %param) = @_; + + my $property_isolation = $param{property_isolation}; my $pdata = $class->private(); diff --git a/test/section_config_property_isolation_test.pl b/test/section_config_property_isolation_test.pl index bf86a91..4bade3b 100755 --- a/test/section_config_property_isolation_test.pl +++ b/test/section_config_property_isolation_test.pl @@ -172,7 +172,7 @@ use Test::More; Conf::One->register(); Conf::Two->register(); -Conf->init(1); +Conf->init(property_isolation => 1); # FIXME: allow development debug warnings?! local $SIG{__WARN__} = sub { die @_; }; -- 2.39.5