mirror of
https://git.proxmox.com/git/pve-access-control
synced 2025-07-15 03:28:06 +00:00
domain sync: make options actually required
we want the api options to be optional, but only as long as there are default values set in the realm config since they are all marked as optional (else they would be required in the api) this check did not work as intended instead, set the result to the value of: * the parameter * the set default in the config * the api default in this order if it is undef after this, raise a parameter exception Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
782b702dbb
commit
055c54b5a2
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user