[pve-devel] [PATCH common 2/4] add the possibility to use a hash for parameter mapping
Dominik Csapak
d.csapak at proxmox.com
Fri Jun 15 15:28:42 CEST 2018
instead of writing:
['name', sub {...}, 'description', 1]
one can now use:
{
name => 'name',
func => sub { ... },
desc => 'desc',
interactive => 1,
}
which makes it more obvious what is what
(and allows later patches to easily override some things)
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/PVE/RESTHandler.pm | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/PVE/RESTHandler.pm b/src/PVE/RESTHandler.pm
index 7732157..3e536dc 100644
--- a/src/PVE/RESTHandler.pm
+++ b/src/PVE/RESTHandler.pm
@@ -549,6 +549,10 @@ my $compute_param_mapping_hash = sub {
my ($name, $func, $desc, $interactive);
if (ref($item) eq 'ARRAY') {
($name, $func, $desc, $interactive) = @$item;
+ } elsif (ref($item) eq 'HASH') {
+ # just use the hash
+ $res->{$item->{name}} = $item;
+ next;
} else {
$name = $item;
$func = sub { return PVE::Tools::file_get_contents($_[0]) };
--
2.11.0
More information about the pve-devel
mailing list