[pve-devel] [pve-common 10/11] cli: data_to_text: never render undefined values
Dietmar Maurer
dietmar at proxmox.com
Fri Jun 29 13:15:25 CEST 2018
To make it visible when the API return undefined values.
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
src/PVE/CLIFormatter.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm
index cbe6390..a6c4795 100644
--- a/src/PVE/CLIFormatter.pm
+++ b/src/PVE/CLIFormatter.pm
@@ -42,6 +42,8 @@ sub println_max {
sub data_to_text {
my ($data, $propdef) = @_;
+ return '' if !defined($data);
+
if (defined($propdef)) {
if (my $type = $propdef->{type}) {
if ($type eq 'boolean') {
@@ -57,7 +59,6 @@ sub data_to_text {
return $code->($data);
}
}
- return '' if !defined($data);
if (my $class = ref($data)) {
return to_json($data, { canonical => 1 });
--
2.11.0
More information about the pve-devel
mailing list