]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/API2/Domains.pm
domain sync: make options actually required
[pve-access-control.git] / PVE / API2 / Domains.pm
index b3c3ac49f830312827bbbcd562039b234af2f82c..e1398692ce216f3f7e32fa2ac1f0f54348d0b79a 100644 (file)
@@ -372,21 +372,18 @@ my $parse_sync_opts = sub {
     my $sync_opts_fmt = PVE::JSONSchema::get_format('realm-sync-options');
 
     my $res = {};
+    my $defaults = {};
     if (defined(my $cfg_opts = $realmconfig->{'sync-defaults-options'})) {
-       $res = PVE::JSONSchema::parse_property_string($sync_opts_fmt, $cfg_opts);
+       $defaults = PVE::JSONSchema::parse_property_string($sync_opts_fmt, $cfg_opts);
     }
 
     for my $opt (sort keys %$sync_opts_fmt) {
        my $fmt = $sync_opts_fmt->{$opt};
 
-       if (exists $param->{$opt}) {
-           $res->{$opt} = $param->{$opt};
-       } elsif (!exists $res->{$opt}) {
-           raise_param_exc({
-               "$opt" => 'Not passed as parameter and not defined in realm default sync options.'
-           }) if !$fmt->{optional};
-           $res->{$opt} = $fmt->{default} if exists $fmt->{default};
-       }
+       $res->{$opt} = $param->{$opt} // $defaults->{$opt} // $fmt->{default};
+       raise_param_exc({
+           "$opt" => 'Not passed as parameter and not defined in realm default sync options.'
+       }) if !defined($res->{$opt});
     }
     return $res;
 };