From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 2F39A1FF16E for ; Mon, 17 Feb 2025 13:18:44 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 926D11EBC1; Mon, 17 Feb 2025 13:18:33 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Mon, 17 Feb 2025 13:17:48 +0100 Message-Id: <20250217121748.117222-6-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250217121748.117222-1-d.kral@proxmox.com> References: <20250217121748.117222-1-d.kral@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.010 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH for-PVE-9.0/installer 5/5] assistant: add deprecation notice for snakecased parameters X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Print a deprecation notice if the auto-installer-assistant detects any snakecased parameters while parsing the answer file, which is deprecated and users should change them to kebab-cased parameters. This includes all parameters except the filter match rules (e.g. "ID_MODEL") as those correspond to the output of udevadm. The detection is best effort since the TOML format allows many ways to parse keys (e.g. '=' are allowed in quoted keys, whitespaces is allowed around the seperating dot '.'), but should cover the relevant cases used by our users. Signed-off-by: Daniel Kral --- proxmox-auto-install-assistant/src/main.rs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/proxmox-auto-install-assistant/src/main.rs b/proxmox-auto-install-assistant/src/main.rs index 969922c..c6e4249 100644 --- a/proxmox-auto-install-assistant/src/main.rs +++ b/proxmox-auto-install-assistant/src/main.rs @@ -584,6 +584,20 @@ fn get_udev_properties(path: impl AsRef + fmt::Debug) -> Result { Ok(String::from_utf8(udev_output.stdout)?) } +fn get_deprecated_properties(s: &str) -> Vec<&str> { + s.lines() + .map(|line| line.trim()) + .filter(|line| line.contains('=')) + // Ignore commented out config lines + .filter(|line| !line.starts_with('#')) + .filter_map(|line| line.split_once('=')) + .filter(|(key, _)| key.contains('_')) + // Ignore keys for udev filter rules + .filter(|(key, _)| !key.starts_with("filter.")) + .map(|(key, _)| key.trim()) + .collect() +} + fn parse_answer(path: impl AsRef + fmt::Debug) -> Result { let mut file = match fs::File::open(&path) { Ok(file) => file, @@ -594,6 +608,16 @@ fn parse_answer(path: impl AsRef + fmt::Debug) -> Result { bail!("Reading from file {path:?} failed: {err}"); } + let deprecated_props = get_deprecated_properties(&contents); + if !deprecated_props.is_empty() { + let prop_list = deprecated_props.join(", "); + println!("The answer file contains the following snake_cased parameters: {prop_list}."); + println!( + "Snakecased parameters are deprecated in favor of kebab-cased parameters and \ + support will be removed in the next major release.\n" + ); + } + match toml::from_str(&contents) { Ok(answer) => { verify_locale_settings(&answer, &serde_json::from_str(LOCALE_INFO)?)?; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel