[pve-devel] [pve-common 3/3] print_api_result: skip undefined object values

Dietmar Maurer dietmar at proxmox.com
Tue Jul 10 13:43:05 CEST 2018


We use objects to return VM configurations, so we uónly want to display
defined values.

Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 src/PVE/CLIFormatter.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm
index 927e5a6..7a92f7a 100644
--- a/src/PVE/CLIFormatter.pm
+++ b/src/PVE/CLIFormatter.pm
@@ -393,6 +393,7 @@ sub print_api_result {
 	    $props_to_print = [ sort keys %$data ] if !scalar(@$props_to_print);
 	    my $kvstore = [];
 	    foreach my $key (@$props_to_print) {
+		next if !defined($data->{$key});
 		push @$kvstore, { key => $key, value => data_to_text($data->{$key}, $result_schema->{properties}->{$key}, $options) };
 	    }
 	    my $schema = { type => 'array', items => { type => 'object' }};
-- 
2.11.0




More information about the pve-devel mailing list