From 885641fb6a52ce2095180d912070af378026d631 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sun, 19 Feb 2017 11:17:34 +0100 Subject: [PATCH] SectionConfig: allow to get class specific updateSchema() Useful when you have different section types, and you want to have separate update API methods. --- src/PVE/SectionConfig.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PVE/SectionConfig.pm b/src/PVE/SectionConfig.pm index a6301e2..6273afa 100644 --- a/src/PVE/SectionConfig.pm +++ b/src/PVE/SectionConfig.pm @@ -104,7 +104,7 @@ sub createSchema { } sub updateSchema { - my ($class) = @_; + my ($class, $single_class) = @_; my $pdata = $class->private(); my $propertyList = $pdata->{propertyList}; @@ -112,8 +112,15 @@ sub updateSchema { my $props = {}; + my $filter_type = $class->type() if $single_class; + foreach my $p (keys %$propertyList) { next if $p eq 'type'; + + my $copts = $class->options(); + + next if defined($filter_type) && !defined($copts->{$p}); + if (!$propertyList->{$p}->{optional}) { $props->{$p} = $propertyList->{$p}; next; @@ -121,7 +128,6 @@ sub updateSchema { my $modifyable = 0; - my $copts = $class->options(); $modifyable = 1 if defined($copts->{$p}) && !$copts->{$p}->{fixed}; foreach my $t (keys %$plugins) { -- 2.39.2