]> git.proxmox.com Git - pve-common.git/commitdiff
PVE/JSONSchema: add pve-task-status-type
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 24 Jun 2021 07:10:10 +0000 (09:10 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 28 Jun 2021 12:47:53 +0000 (14:47 +0200)
to have a format that contains the possible worker task states

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/PVE/JSONSchema.pm

index 6297fff0e24abe6f3f79b98e8c2484ef007b0545..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) = @_;