From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id C54C31FF161 for ; Wed, 20 Nov 2024 19:24:26 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 154BB15F10; Wed, 20 Nov 2024 19:24:26 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Wed, 20 Nov 2024 19:24:13 +0100 Message-Id: <20241120182414.125789-2-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241120182414.125789-1-d.kral@proxmox.com> References: <20241120182414.125789-1-d.kral@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.002 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [options.rs] Subject: [pve-devel] [PATCH installer 2/3] common: allow lowercase and uppercase btrfs raid levels 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" Allows the BTRFS RAID levels to be either lowercase or uppercase when deserializing them from string values, i.e. currently only the config value of `btrfs.raid` in auto-installer answer files. Signed-off-by: Daniel Kral --- When we're already at it, let's do the same for btrfs... Here's the output from `cargo expand` again, first for deserialization: ``` fn visit_str<__E>( self, __value: &str, ) -> _serde::__private::Result where __E: _serde::de::Error, { match __value { "RAID0" | "raid0" => _serde::__private::Ok(__Field::__field0), "RAID1" | "raid1" => _serde::__private::Ok(__Field::__field1), "RAID10" | "raid10" => { _serde::__private::Ok(__Field::__field2) } _ => { _serde::__private::Err( _serde::de::Error::unknown_variant(__value, VARIANTS), ) } } } ``` and second for serialization: ``` impl _serde::Serialize for BtrfsRaidLevel { fn serialize<__S>( &self, __serializer: __S, ) -> _serde::__private::Result<__S::Ok, __S::Error> where __S: _serde::Serializer, { match *self { BtrfsRaidLevel::Raid0 => { _serde::Serializer::serialize_unit_variant( __serializer, "BtrfsRaidLevel", 0u32, "RAID0", ) } BtrfsRaidLevel::Raid1 => { _serde::Serializer::serialize_unit_variant( __serializer, "BtrfsRaidLevel", 1u32, "RAID1", ) } BtrfsRaidLevel::Raid10 => { _serde::Serializer::serialize_unit_variant( __serializer, "BtrfsRaidLevel", 2u32, "RAID10", ) } } } } ``` On some error (`btrfs.raid = "rAID10"`), the message is: ``` proxmox-auto-install-assistant validate-answer answer.toml Error: Error parsing answer file: TOML parse error at line 21, column 14 | 21 | btrfs.raid = "rAID10" | ^^^^^^^^ unknown variant `rAID10`, expected one of `raid0`, `raid1`, `raid10` ``` proxmox-installer-common/src/options.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/proxmox-installer-common/src/options.rs b/proxmox-installer-common/src/options.rs index 434ce26..58fadf8 100644 --- a/proxmox-installer-common/src/options.rs +++ b/proxmox-installer-common/src/options.rs @@ -14,8 +14,11 @@ use crate::utils::{CidrAddress, Fqdn}; #[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] #[serde(rename_all(deserialize = "lowercase", serialize = "UPPERCASE"))] pub enum BtrfsRaidLevel { + #[serde(alias = "RAID0")] Raid0, + #[serde(alias = "RAID1")] Raid1, + #[serde(alias = "RAID10")] Raid10, } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel