]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/JSONSchema.pm
safe_read_from: bump default size limit to 1 MiB to match pmxcfs
[pve-common.git] / src / PVE / JSONSchema.pm
index 0b2db2dcb4563f320e9110fc33eca34f26cef1ed..71df690b56d846795d556583509639ed8d01461f 100644 (file)
@@ -689,6 +689,18 @@ sub pve_verify_tfa_secret {
     die "unable to decode TFA secret\n";
 }
 
+
+PVE::JSONSchema::register_format('pve-task-status-type', \&verify_task_status_type);
+sub verify_task_status_type {
+    my ($value, $noerr) = @_;
+
+    return $value if $value =~ m/^(ok|error|warning|unknown)$/i;
+
+    return undef if $noerr;
+
+    die "invalid status '$value'\n";
+}
+
 sub check_format {
     my ($format, $value, $path) = @_;
 
@@ -714,13 +726,14 @@ sub check_format {
        if $format_type ne 'none' && ref($registered) ne 'CODE';
 
     if ($format_type eq 'list') {
+       $parsed = [];
        # Note: we allow empty lists
        foreach my $v (split_list($value)) {
-           $parsed = $registered->($v);
+           push @{$parsed}, $registered->($v);
        }
     } elsif ($format_type eq 'opt') {
        $parsed = $registered->($value) if $value;
-   } else {
+    } else {
        if (ref($registered) eq 'HASH') {
            # Note: this is the only case where a validator function could be
            # attached, hence it's safe to handle that in parse_property_string.