mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-13 19:42:12 +00:00
section config: add helper for deleting keys from a entry
This is a pattern that can be found often in Proxmox VE's API stack, so implement it centrally here for re-use. Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
6870afa455
commit
5028848d42
@ -543,4 +543,19 @@ sub assert_if_modified {
|
||||
PVE::Tools::assert_if_modified($cfg->{digest}, $digest);
|
||||
}
|
||||
|
||||
sub delete_from_config {
|
||||
my ($config, $option_schema, $new_options, $to_delete) = @_;
|
||||
|
||||
for my $k ($to_delete->@*) {
|
||||
my $d = $option_schema->{$k} || die "no such option '$k'\n";
|
||||
die "unable to delete required option '$k'\n" if !$d->{optional};
|
||||
die "unable to delete fixed option '$k'\n" if $d->{fixed};
|
||||
die "cannot set and delete property '$k' at the same time!\n"
|
||||
if defined($new_options->{$k});
|
||||
delete $config->{$k};
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user