]> git.proxmox.com Git - pve-common.git/commitdiff
section config: avoid unamed boolean parameter use hash
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 17 Nov 2023 08:05:36 +0000 (09:05 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 17 Nov 2023 08:58:01 +0000 (09:58 +0100)
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 <t.lamprecht@proxmox.com>
src/PVE/SectionConfig.pm
test/section_config_property_isolation_test.pl

index fb1192b8182d8cc1428299c34cb170c8bc3c1863..a18e9d877850dd0e0fcca6e4967e2bc14c3dec8e 100644 (file)
@@ -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();
 
index bf86a91f183c34a02d865dee81a942ab1ee9d756..4bade3b92dbacdf8df5a7fe1d7633296ed12b426 100755 (executable)
@@ -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 @_; };