PVE::CLIHandler::print_api_list - use all occuring properties

print_api_list falls back to the union of all properties occuring in data, if
none are provided explicitly, and the API method contains no returns property.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
Stoiko Ivanov 2018-06-22 20:21:07 +02:00 committed by Dietmar Maurer
parent e05f7cdd0c
commit 9b8f2f8f6e

View File

@ -510,7 +510,13 @@ sub print_api_list {
if (!defined($props_to_print)) { if (!defined($props_to_print)) {
$props_to_print = [ sort keys %$returnprops ]; $props_to_print = [ sort keys %$returnprops ];
if (!scalar(@$props_to_print)) { if (!scalar(@$props_to_print)) {
$props_to_print = [ sort keys %{$data->[0]} ]; my $all_props = {};
foreach my $obj (@{$data}) {
foreach my $key (keys %{$obj}) {
$all_props->{ $key } = 1;
}
}
$props_to_print = [ sort keys %{$all_props} ];
} }
die "unable to detect list properties\n" if !scalar(@$props_to_print); die "unable to detect list properties\n" if !scalar(@$props_to_print);
} }