public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer v2 2/2] [for-9.0] auto: answer: drop deprecated snake_case keys
Date: Tue, 24 Jun 2025 13:40:54 +0200	[thread overview]
Message-ID: <20250624114102.901342-2-c.heiss@proxmox.com> (raw)
In-Reply-To: <20250624114102.901342-1-c.heiss@proxmox.com>

This has been deprecated in PVE 8.4-1 and PBS 3.4-1, respectively. The
kebab-case style is preferred for all new things.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v1 -> v2:
  * rebased on latest master

Would be nice to drop them with the next major release, if there are no
good reasons to keep them around for another major release.

The migration/fix for users is pretty simple too, for both hand-written
answer files as well as on-the-fly generated ones from automated
provisioning tools and such - basically a s/_/-/.

 proxmox-auto-install-assistant/src/main.rs      |  6 +++---
 proxmox-auto-installer/src/answer.rs            | 17 ++++-------------
 proxmox-auto-installer/tests/parse-answer.rs    |  3 ++-
 .../parse_answer_fail/underscore_keys.json      |  3 +++
 .../parse_answer_fail/underscore_keys.toml      | 14 ++++++++++++++
 5 files changed, 26 insertions(+), 17 deletions(-)
 create mode 100644 proxmox-auto-installer/tests/resources/parse_answer_fail/underscore_keys.json
 create mode 100644 proxmox-auto-installer/tests/resources/parse_answer_fail/underscore_keys.toml

diff --git a/proxmox-auto-install-assistant/src/main.rs b/proxmox-auto-install-assistant/src/main.rs
index 320de2d..7e1f780 100644
--- a/proxmox-auto-install-assistant/src/main.rs
+++ b/proxmox-auto-install-assistant/src/main.rs
@@ -519,7 +519,7 @@ fn validate_answer_file_keys(path: impl AsRef<Path> + fmt::Debug) -> Result<bool
             for (k, v) in t {
                 if k.contains('_') {
                     eprintln!(
-                        "Warning: Section [{}] contains deprecated key `{k}`, use `{}` instead.",
+                        "Error: Section [{}] contains key `{k}` which has been removed, use `{}` instead.",
                         section.join("."),
                         k.replace("_", "-")
                     );
@@ -538,8 +538,8 @@ fn validate_answer_file_keys(path: impl AsRef<Path> + fmt::Debug) -> Result<bool
         Ok(true)
     } else {
         eprintln!(
-            "Warning: Answer file is using deprecated underscore keys. \
-            Since PVE 8.4-1 and PBS 3.4-1, kebab-case style keys are now preferred."
+            "Error: Answer file is using underscore keys, which have been removed. \
+            Since PVE 8.4-1 and PBS 3.4-1, kebab-case style keys are now preferred and mandantory since PVE 9.0-1."
         );
         Ok(false)
     }
diff --git a/proxmox-auto-installer/src/answer.rs b/proxmox-auto-installer/src/answer.rs
index aafe38f..0097200 100644
--- a/proxmox-auto-installer/src/answer.rs
+++ b/proxmox-auto-installer/src/answer.rs
@@ -9,9 +9,6 @@ use proxmox_installer_common::{
 use serde::{Deserialize, Serialize};
 use std::{collections::BTreeMap, io::BufRead, net::IpAddr};
 
-// NOTE New answer file properties must use kebab-case, but should allow snake_case for backwards
-// compatibility. TODO Remove the snake_cased variants in a future major version (e.g. PVE 10).
-
 // BTreeMap is used to store filters as the order of the filters will be stable, compared to
 // storing them in a HashMap
 
@@ -50,15 +47,13 @@ pub struct Global {
     pub keyboard: KeyboardLayout,
     pub mailto: String,
     pub timezone: String,
-    #[serde(alias = "root_password")]
     pub root_password: Option<String>,
-    #[serde(alias = "root_password_hashed")]
     pub root_password_hashed: Option<String>,
-    #[serde(alias = "reboot_on_error", default)]
+    #[serde(default)]
     pub reboot_on_error: bool,
-    #[serde(alias = "reboot_mode", default)]
+    #[serde(default)]
     pub reboot_mode: RebootMode,
-    #[serde(alias = "root_ssh_keys", default)]
+    #[serde(default)]
     pub root_ssh_keys: Vec<String>,
 }
 
@@ -109,7 +104,6 @@ pub struct PostNotificationHookInfo {
     /// URL to send a POST request to
     pub url: String,
     /// SHA256 cert fingerprint if certificate pinning should be used.
-    #[serde(alias = "cert_fingerprint")]
     pub cert_fingerprint: Option<String>,
 }
 
@@ -167,7 +161,6 @@ pub struct FirstBootHookInfo {
     /// Retrieve the post-install script from a URL, if source == "from-url".
     pub url: Option<String>,
     /// SHA256 cert fingerprint if certificate pinning should be used, if source == "from-url".
-    #[serde(alias = "cert_fingerprint")]
     pub cert_fingerprint: Option<String>,
 }
 
@@ -261,10 +254,9 @@ pub struct NetworkManual {
 #[serde(rename_all = "kebab-case", deny_unknown_fields)]
 pub struct DiskSetup {
     pub filesystem: Filesystem,
-    #[serde(alias = "disk_list", default)]
+    #[serde(default)]
     pub disk_list: Vec<String>,
     pub filter: Option<BTreeMap<String, String>>,
-    #[serde(alias = "filter_match")]
     pub filter_match: Option<FilterMatch>,
     pub zfs: Option<ZfsOptions>,
     pub lvm: Option<LvmOptions>,
@@ -387,7 +379,6 @@ pub enum Filesystem {
 pub struct ZfsOptions {
     pub raid: Option<ZfsRaidLevel>,
     pub ashift: Option<usize>,
-    #[serde(alias = "arc_max")]
     pub arc_max: Option<usize>,
     pub checksum: Option<ZfsChecksumOption>,
     pub compress: Option<ZfsCompressOption>,
diff --git a/proxmox-auto-installer/tests/parse-answer.rs b/proxmox-auto-installer/tests/parse-answer.rs
index 34bc969..f4c3ae8 100644
--- a/proxmox-auto-installer/tests/parse-answer.rs
+++ b/proxmox-auto-installer/tests/parse-answer.rs
@@ -146,7 +146,8 @@ mod tests {
             fqdn_hostname_only,
             no_fqdn_from_dhcp,
             no_root_password_set,
-            short_password
+            short_password,
+            underscore_keys
         );
     }
 }
diff --git a/proxmox-auto-installer/tests/resources/parse_answer_fail/underscore_keys.json b/proxmox-auto-installer/tests/resources/parse_answer_fail/underscore_keys.json
new file mode 100644
index 0000000..484279d
--- /dev/null
+++ b/proxmox-auto-installer/tests/resources/parse_answer_fail/underscore_keys.json
@@ -0,0 +1,3 @@
+{
+    "parse-error": "error parsing answer.toml: unknown field `root_password`, expected one of `country`, `fqdn`, `keyboard`, `mailto`, `timezone`, `root-password`, `root-password-hashed`, `reboot-on-error`, `reboot-mode`, `root-ssh-keys`"
+}
diff --git a/proxmox-auto-installer/tests/resources/parse_answer_fail/underscore_keys.toml b/proxmox-auto-installer/tests/resources/parse_answer_fail/underscore_keys.toml
new file mode 100644
index 0000000..16f355c
--- /dev/null
+++ b/proxmox-auto-installer/tests/resources/parse_answer_fail/underscore_keys.toml
@@ -0,0 +1,14 @@
+[global]
+keyboard = "de"
+country = "at"
+fqdn = "pveauto.testinstall"
+mailto = "mail@no.invalid"
+timezone = "Europe/Vienna"
+root_password = "12345678"
+
+[network]
+source = "from-dhcp"
+
+[disk-setup]
+filesystem = "ext4"
+disk_list = ["sda"]
-- 
2.49.0



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-06-24 11:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24 11:40 [pve-devel] [PATCH installer v2 1/2] assistant: validate: warn if answer file contains old " Christoph Heiss
2025-06-24 11:40 ` Christoph Heiss [this message]
2025-06-24 14:53   ` [pve-devel] [PATCH installer v2 2/2] [for-9.0] auto: answer: drop deprecated " Thomas Lamprecht
2025-06-24 14:54 ` [pve-devel] applied: [PATCH installer v2 1/2] assistant: validate: warn if answer file contains old " 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=20250624114102.901342-2-c.heiss@proxmox.com \
    --to=c.heiss@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