parse_sync_opts: code cleanup

avoid confusion between fmt default and cfg default

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-04-25 18:54:45 +02:00
parent 38691d98c8
commit 6c42a1034b

View File

@ -371,16 +371,17 @@ my $parse_sync_opts = sub {
my $sync_opts_fmt = PVE::JSONSchema::get_format('realm-sync-options'); my $sync_opts_fmt = PVE::JSONSchema::get_format('realm-sync-options');
my $res = {}; my $cfg_defaults = {};
my $defaults = {};
if (defined(my $cfg_opts = $realmconfig->{'sync-defaults-options'})) { if (defined(my $cfg_opts = $realmconfig->{'sync-defaults-options'})) {
$defaults = PVE::JSONSchema::parse_property_string($sync_opts_fmt, $cfg_opts); $cfg_defaults = PVE::JSONSchema::parse_property_string($sync_opts_fmt, $cfg_opts);
} }
my $res = {};
for my $opt (sort keys %$sync_opts_fmt) { for my $opt (sort keys %$sync_opts_fmt) {
my $fmt = $sync_opts_fmt->{$opt}; my $fmt = $sync_opts_fmt->{$opt};
$res->{$opt} = $param->{$opt} // $defaults->{$opt} // $fmt->{default}; $res->{$opt} = $param->{$opt} // $cfg_defaults->{$opt} // $fmt->{default};
raise_param_exc({ raise_param_exc({
"$opt" => 'Not passed as parameter and not defined in realm default sync options.' "$opt" => 'Not passed as parameter and not defined in realm default sync options.'
}) if !defined($res->{$opt}); }) if !defined($res->{$opt});