From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 2/3] common: allow lowercase and uppercase btrfs raid levels
Date: Wed, 20 Nov 2024 19:24:13 +0100 [thread overview]
Message-ID: <20241120182414.125789-2-d.kral@proxmox.com> (raw)
In-Reply-To: <20241120182414.125789-1-d.kral@proxmox.com>
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 <d.kral@proxmox.com>
---
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<Self::Value, __E>
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
next prev parent reply other threads:[~2024-11-20 18:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 18:24 [pve-devel] [PATCH installer 1/3] common: allow lowercase and uppercase zfs " Daniel Kral
2024-11-20 18:24 ` Daniel Kral [this message]
2024-11-20 18:24 ` [pve-devel] [PATCH installer 3/3] common: make btrfs disk options uppercase for consistency Daniel Kral
2024-11-20 19:09 ` [pve-devel] applied-series: [PATCH installer 1/3] common: allow lowercase and uppercase zfs raid levels 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=20241120182414.125789-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.