From 63e5cd0970a92408b51a9294ae0d2109c32023b6 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 3 Jan 2023 16:08:21 +0100 Subject: [PATCH] fix #1295: add config schema to control pending update notifications For now allow a simple selection of `auto` (current behavior), `always` (if updates are available) or `never`. Signed-off-by: Thomas Lamprecht --- data/PVE/DataCenterConfig.pm | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/data/PVE/DataCenterConfig.pm b/data/PVE/DataCenterConfig.pm index 6bd47b1..7a24870 100644 --- a/data/PVE/DataCenterConfig.pm +++ b/data/PVE/DataCenterConfig.pm @@ -37,6 +37,20 @@ my $migration_format = { }, }; +my $notification_format = { + 'package-updates' => { + type => 'string', + enum => ['auto', 'always', 'never'], + description => "Control when the daily update job should send out notification mails.", + verbose_description => "Control how often the daily update job should send out notification mails:\n" + ."* 'auto' daily for systems with a valid subscription, as those are assumed to be " + ." production-ready and thus should know about pending updates.\n" + ."* 'always' every update, if there are new pending updates.\n" + ."* 'never' never send a notification for new pending updates.\n", + default => 'auto', + }, +}; + my $ha_format = { shutdown_policy => { type => 'string', @@ -190,10 +204,10 @@ my $user_tag_privs_format = { verbose_description => "Controls which tags can be set or deleted on resources a user " ."controls (such as guests). Users with the `Sys.Modify` privilege on `/` are always " ." unrestricted. " - ."'none' no tags are usable. " - ."'list' tags from 'user-allow-list' are usable. " - ."'existing' like list, but already existing tags of resources are also usable." - ."'free' no tag restrictions." + ."* 'none' no tags are usable. " + ."* 'list' tags from 'user-allow-list' are usable. " + ."* 'existing' like list, but already existing tags of resources are also usable." + ."* 'free' no tag restrictions.", }, 'user-allow-list' => { optional => 1, @@ -315,6 +329,11 @@ my $datacenter_schema = { format => 'mac-prefix', description => 'Prefix for autogenerated MAC addresses.', }, + notify => { + optional => 1, + type => 'string', format => $notification_format, + description => "Cluster-wide notification settings.", + }, bwlimit => PVE::JSONSchema::get_standard_option('bwlimit'), u2f => { optional => 1, @@ -394,6 +413,9 @@ sub parse_datacenter_config { if (my $ha = $res->{ha}) { $res->{ha} = parse_property_string($ha_format, $ha); } + if (my $notify = $res->{notify}) { + $res->{notify} = parse_property_string($notification_format, $notify); + } if (my $u2f = $res->{u2f}) { $res->{u2f} = parse_property_string($u2f_format, $u2f); @@ -474,6 +496,9 @@ sub write_datacenter_config { if (ref(my $ha = $cfg->{ha})) { $cfg->{ha} = PVE::JSONSchema::print_property_string($ha, $ha_format); } + if (ref(my $notify = $cfg->{notify})) { + $cfg->{notify} = PVE::JSONSchema::print_property_string($notify, $notification_format); + } if (ref(my $u2f = $cfg->{u2f})) { $cfg->{u2f} = PVE::JSONSchema::print_property_string($u2f, $u2f_format); -- 2.39.2