From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 4C82B1FF16E for ; Mon, 17 Feb 2025 13:18:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 52B931EB34; Mon, 17 Feb 2025 13:18:02 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Mon, 17 Feb 2025 13:17:46 +0100 Message-Id: <20250217121748.117222-4-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.008 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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 installer 3/5] auto-installer: allow snake- and kebabcased property names in answer files 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" 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 --- 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, + #[serde(alias = "root_password_hashed")] pub root_password_hashed: Option, - #[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, } #[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, } @@ -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, pub filter: Option>, + #[serde(alias = "filter_match")] pub filter_match: Option, pub zfs: Option, pub lvm: Option, @@ -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, pub ashift: Option, + #[serde(alias = "arc_max")] pub arc_max: Option, pub checksum: Option, pub compress: Option, -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel