public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 3/5] auto-installer: allow snake- and kebabcased property names in answer files
Date: Mon, 17 Feb 2025 13:17:46 +0100	[thread overview]
Message-ID: <20250217121748.117222-4-d.kral@proxmox.com> (raw)
In-Reply-To: <20250217121748.117222-1-d.kral@proxmox.com>

The default case for property names in TOML configuration files is de
facto snake_case. The answer file for the auto-installer adapted this,
but this causes inconsistencies with the property names in other Proxmox
config file formats, which are preferably in kebab-case.

To gradually migrate from snake_cased to kebab-cased property names in
answer files, allow both cases for the time being and deprecate the
snake_cased variant of all properties in a future major version.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
 proxmox-auto-installer/src/answer.rs | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/proxmox-auto-installer/src/answer.rs b/proxmox-auto-installer/src/answer.rs
index e8614d2..c834591 100644
--- a/proxmox-auto-installer/src/answer.rs
+++ b/proxmox-auto-installer/src/answer.rs
@@ -10,6 +10,9 @@ 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
 
@@ -40,27 +43,30 @@ impl Answer {
 }
 
 #[derive(Clone, Deserialize, Debug)]
-#[serde(deny_unknown_fields)]
+#[serde(rename_all = "kebab-case", deny_unknown_fields)]
 pub struct Global {
     pub country: String,
     pub fqdn: Fqdn,
     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(default)]
+    #[serde(alias = "reboot_on_error", default)]
     pub reboot_on_error: bool,
-    #[serde(default)]
+    #[serde(alias = "root_ssh_keys", default)]
     pub root_ssh_keys: Vec<String>,
 }
 
 #[derive(Clone, Deserialize, Debug)]
-#[serde(deny_unknown_fields)]
+#[serde(rename_all = "kebab-case", deny_unknown_fields)]
 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>,
 }
 
@@ -209,12 +215,13 @@ pub struct NetworkManual {
 }
 
 #[derive(Clone, Debug, Deserialize)]
-#[serde(deny_unknown_fields)]
+#[serde(rename_all = "kebab-case", deny_unknown_fields)]
 pub struct DiskSetup {
     pub filesystem: Filesystem,
-    #[serde(default)]
+    #[serde(alias = "disk_list", 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>,
@@ -330,10 +337,11 @@ pub enum Filesystem {
 }
 
 #[derive(Clone, Copy, Default, Deserialize, Debug)]
-#[serde(deny_unknown_fields)]
+#[serde(rename_all = "kebab-case", deny_unknown_fields)]
 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>,
-- 
2.39.5



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


  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 ` Daniel Kral [this message]
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 ` [pve-devel] [PATCH for-PVE-9.0/installer 5/5] assistant: add deprecation notice for snakecased parameters Daniel Kral
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-4-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