From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id EA8FA1FF0E0 for ; Thu, 09 Jul 2026 14:01:47 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 2BE6D218AD; Thu, 09 Jul 2026 13:58:29 +0200 (CEST) From: Lukas Wagner To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com Subject: [PATCH proxmox-backup 21/29] api: notification: add 'migrate-to-expression' parameter to get_matcher Date: Thu, 9 Jul 2026 13:57:08 +0200 Message-ID: <20260709115716.299836-22-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260709115716.299836-1-l.wagner@proxmox.com> References: <20260709115716.299836-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1783598240142 X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: XQ3VCL5RYMTORAVOPL5PNLWJQVSQRDXR X-Message-ID-Hash: XQ3VCL5RYMTORAVOPL5PNLWJQVSQRDXR X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: If set, we return the matcher with any occurrences of the 'old' match-*, invert-match and mode keys to an equivalent expression. Signed-off-by: Lukas Wagner --- src/api2/config/notifications/matchers.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/api2/config/notifications/matchers.rs b/src/api2/config/notifications/matchers.rs index fba1859cf..504d26d40 100644 --- a/src/api2/config/notifications/matchers.rs +++ b/src/api2/config/notifications/matchers.rs @@ -40,6 +40,11 @@ pub fn list_matchers( properties: { name: { schema: ENTITY_NAME_SCHEMA, + }, + "migrate-to-expression": { + description: "Automatically translate existing 'match-*', 'invert-match' and 'mode' to an equivalent matching 'expression'", + optional: true, + default: false, } }, }, @@ -49,9 +54,18 @@ pub fn list_matchers( }, )] /// Get a notification matcher. -pub fn get_matcher(name: String, rpcenv: &mut dyn RpcEnvironment) -> Result { +pub fn get_matcher( + name: String, + migrate_to_expression: bool, + rpcenv: &mut dyn RpcEnvironment, +) -> Result { let config = pbs_config::notifications::config()?; - let matcher = proxmox_notify::api::matcher::get_matcher(&config, &name)?; + + let matcher = if migrate_to_expression { + proxmox_notify::api::matcher::get_matcher_as_expression(&config, &name)? + } else { + proxmox_notify::api::matcher::get_matcher(&config, &name)? + }; rpcenv["digest"] = hex::encode(config.digest()).into(); -- 2.47.3