From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH for-PVE-9.0/installer 5/5] assistant: add deprecation notice for snakecased parameters
Date: Mon, 17 Feb 2025 13:17:48 +0100 [thread overview]
Message-ID: <20250217121748.117222-6-d.kral@proxmox.com> (raw)
In-Reply-To: <20250217121748.117222-1-d.kral@proxmox.com>
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 <d.kral@proxmox.com>
---
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<Path> + fmt::Debug) -> Result<String> {
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<Path> + fmt::Debug) -> Result<Answer> {
let mut file = match fs::File::open(&path) {
Ok(file) => file,
@@ -594,6 +608,16 @@ fn parse_answer(path: impl AsRef<Path> + fmt::Debug) -> Result<Answer> {
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
next prev parent reply other threads:[~2025-02-17 12:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-17 12:17 [pve-devel] [PATCH installer 0/5] allow both snake- and kebab-cased property names in the answer file Daniel Kral
2025-02-17 12:17 ` [pve-devel] [PATCH installer 1/5] auto-installer: factor out field rename casing for network config mode Daniel Kral
2025-02-17 12:17 ` [pve-devel] [PATCH installer 2/5] auto-installer: first-boot: allow snake- and kebabcased property names Daniel Kral
2025-02-17 12:17 ` [pve-devel] [PATCH installer 3/5] auto-installer: allow snake- and kebabcased property names in answer files Daniel Kral
2025-02-17 12:17 ` [pve-devel] [PATCH installer 4/5] auto-installer: add redundant kebab-case renames to config structures Daniel Kral
2025-02-17 12:17 ` Daniel Kral [this message]
2025-02-24 12:05 ` [pve-devel] applied: [PATCH installer 0/5] allow both snake- and kebab-cased property names in the answer file Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250217121748.117222-6-d.kral@proxmox.com \
--to=d.kral@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal