]> git.proxmox.com Git - pve-common.git/commitdiff
cli: data_to_text: never render undefined values
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 29 Jun 2018 11:15:25 +0000 (13:15 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 29 Jun 2018 12:39:48 +0000 (14:39 +0200)
To make it visible when the API return undefined values.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
src/PVE/CLIFormatter.pm

index cbe63907241c378dff6e78d4bf201455ccb94829..a6c47952fecf16b8d852c2ac1a6b579c836ec262 100644 (file)
@@ -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 });