[pve-devel] [RFC PATCH for-9.0 installer 2/2] auto: answer: drop deprecated snake_case keys
Christoph Heiss
c.heiss at proxmox.com
Wed Apr 30 13:25:50 CEST 2025
This has been deprecated in PVE 8.4-1 and PBS 3.4-1, respectively. No
PMG release to date with this change.
The kebab-case style is preferred for all new things.
Migration for users is pretty simple, for both hand-written answer files
as well as on-the-fly generated ones by automated provisioning tools and
such - basically a s/_/-/.
Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
Would be nice to drop them with the next major release, but if there are
reasons for keeping it around for another major, disregard this patch.
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 add5053..fc8e9b2 100644
--- a/proxmox-auto-install-assistant/src/main.rs
+++ b/proxmox-auto-install-assistant/src/main.rs
@@ -299,7 +299,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("_", "-")
);
@@ -318,8 +318,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 d0d5b78..c631b1b 100644
--- a/proxmox-auto-installer/src/answer.rs
+++ b/proxmox-auto-installer/src/answer.rs
@@ -10,9 +10,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
@@ -51,15 +48,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>,
}
@@ -110,7 +105,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>,
}
@@ -168,7 +162,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>,
}
@@ -262,10 +255,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>,
@@ -385,7 +377,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 at no.invalid"
+timezone = "Europe/Vienna"
+root_password = "12345678"
+
+[network]
+source = "from-dhcp"
+
+[disk-setup]
+filesystem = "ext4"
+disk_list = ["sda"]
--
2.49.0
More information about the pve-devel
mailing list