* [pve-devel] [PATCH installer v2 0/2] auto: answer: answer file serde cleanups
@ 2025-07-07 10:08 Christoph Heiss
2025-07-07 10:08 ` [pve-devel] [PATCH installer v2 1/2] auto: answer: drop unneeded #[serde(default)] attributes Christoph Heiss
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christoph Heiss @ 2025-07-07 10:08 UTC (permalink / raw)
To: pve-devel
Two small, mostly trivial patches simplifying the serde definitions for
the answer file.
History
=======
v1: https://lore.proxmox.com/pve-devel/20250429132025.1543199-1-c.heiss@proxmox.com/T/
Changes v1 -> v2:
* rebased on latest master
Diffstat
========
Christoph Heiss (2):
auto: answer: drop unneeded #[serde(default)] attributes
auto: answer: simplify `BTreeMap` handling in deserialization
proxmox-auto-installer/src/answer.rs | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
--
2.49.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH installer v2 1/2] auto: answer: drop unneeded #[serde(default)] attributes
2025-07-07 10:08 [pve-devel] [PATCH installer v2 0/2] auto: answer: answer file serde cleanups Christoph Heiss
@ 2025-07-07 10:08 ` Christoph Heiss
2025-07-07 10:08 ` [pve-devel] [PATCH installer v2 2/2] auto: answer: simplify `BTreeMap` handling in deserialization Christoph Heiss
2025-07-07 12:40 ` [pve-devel] applied-series: [PATCH installer v2 0/2] auto: answer: answer file serde cleanups Thomas Lamprecht
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Heiss @ 2025-07-07 10:08 UTC (permalink / raw)
To: pve-devel
For `Option<>`s, serde automatically defaults to `None` for
deserialization in case the key is missing in the source.
No functional changes.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v1 -> v2:
* no changes
proxmox-auto-installer/src/answer.rs | 2 --
1 file changed, 2 deletions(-)
diff --git a/proxmox-auto-installer/src/answer.rs b/proxmox-auto-installer/src/answer.rs
index aafe38f..c500933 100644
--- a/proxmox-auto-installer/src/answer.rs
+++ b/proxmox-auto-installer/src/answer.rs
@@ -22,9 +22,7 @@ pub struct Answer {
pub network: Network,
#[serde(rename = "disk-setup")]
pub disks: Disks,
- #[serde(default)]
pub post_installation_webhook: Option<PostNotificationHookInfo>,
- #[serde(default)]
pub first_boot: Option<FirstBootHookInfo>,
}
--
2.49.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH installer v2 2/2] auto: answer: simplify `BTreeMap` handling in deserialization
2025-07-07 10:08 [pve-devel] [PATCH installer v2 0/2] auto: answer: answer file serde cleanups Christoph Heiss
2025-07-07 10:08 ` [pve-devel] [PATCH installer v2 1/2] auto: answer: drop unneeded #[serde(default)] attributes Christoph Heiss
@ 2025-07-07 10:08 ` Christoph Heiss
2025-07-07 12:40 ` [pve-devel] applied-series: [PATCH installer v2 0/2] auto: answer: answer file serde cleanups Thomas Lamprecht
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Heiss @ 2025-07-07 10:08 UTC (permalink / raw)
To: pve-devel
Instead of using an `Option<BTreeMap<..>>`, we can use a `BTreeMap`
directly and let serde default to an empty map.
No functional changes.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v1 -> v2:
* rebased on latest master
proxmox-auto-installer/src/answer.rs | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/proxmox-auto-installer/src/answer.rs b/proxmox-auto-installer/src/answer.rs
index c500933..b461976 100644
--- a/proxmox-auto-installer/src/answer.rs
+++ b/proxmox-auto-installer/src/answer.rs
@@ -185,7 +185,8 @@ struct NetworkInAnswer {
pub cidr: Option<CidrAddress>,
pub dns: Option<IpAddr>,
pub gateway: Option<IpAddr>,
- pub filter: Option<BTreeMap<String, String>>,
+ #[serde(default)]
+ pub filter: BTreeMap<String, String>,
}
#[derive(Clone, Deserialize, Debug)]
@@ -208,7 +209,7 @@ impl TryFrom<NetworkInAnswer> for Network {
if network.gateway.is_none() {
return Err("Field 'gateway' must be set.");
}
- if network.filter.is_none() {
+ if network.filter.is_empty() {
return Err("Field 'filter' must be set.");
}
@@ -217,7 +218,7 @@ impl TryFrom<NetworkInAnswer> for Network {
cidr: network.cidr.unwrap(),
dns: network.dns.unwrap(),
gateway: network.gateway.unwrap(),
- filter: network.filter.unwrap(),
+ filter: network.filter,
}),
})
} else {
@@ -230,7 +231,7 @@ impl TryFrom<NetworkInAnswer> for Network {
if network.gateway.is_some() {
return Err("Field 'gateway' not supported for 'from-dhcp' config.");
}
- if network.filter.is_some() {
+ if !network.filter.is_empty() {
return Err("Field 'filter' not supported for 'from-dhcp' config.");
}
@@ -261,7 +262,8 @@ pub struct DiskSetup {
pub filesystem: Filesystem,
#[serde(alias = "disk_list", default)]
pub disk_list: Vec<String>,
- pub filter: Option<BTreeMap<String, String>>,
+ #[serde(default)]
+ pub filter: BTreeMap<String, String>,
#[serde(alias = "filter_match")]
pub filter_match: Option<FilterMatch>,
pub zfs: Option<ZfsOptions>,
@@ -282,17 +284,17 @@ impl TryFrom<DiskSetup> for Disks {
type Error = &'static str;
fn try_from(source: DiskSetup) -> Result<Self, Self::Error> {
- if source.disk_list.is_empty() && source.filter.is_none() {
+ if source.disk_list.is_empty() && source.filter.is_empty() {
return Err("Need either 'disk-list' or 'filter' set");
}
- if !source.disk_list.is_empty() && source.filter.is_some() {
+ if !source.disk_list.is_empty() && !source.filter.is_empty() {
return Err("Cannot use both, 'disk-list' and 'filter'");
}
let disk_selection = if !source.disk_list.is_empty() {
DiskSelection::Selection(source.disk_list.clone())
} else {
- DiskSelection::Filter(source.filter.clone().unwrap())
+ DiskSelection::Filter(source.filter.clone())
};
let lvm_checks = |source: &DiskSetup| -> Result<(), Self::Error> {
--
2.49.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] applied-series: [PATCH installer v2 0/2] auto: answer: answer file serde cleanups
2025-07-07 10:08 [pve-devel] [PATCH installer v2 0/2] auto: answer: answer file serde cleanups Christoph Heiss
2025-07-07 10:08 ` [pve-devel] [PATCH installer v2 1/2] auto: answer: drop unneeded #[serde(default)] attributes Christoph Heiss
2025-07-07 10:08 ` [pve-devel] [PATCH installer v2 2/2] auto: answer: simplify `BTreeMap` handling in deserialization Christoph Heiss
@ 2025-07-07 12:40 ` Thomas Lamprecht
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2025-07-07 12:40 UTC (permalink / raw)
To: pve-devel, Christoph Heiss
On Mon, 07 Jul 2025 12:08:12 +0200, Christoph Heiss wrote:
> Two small, mostly trivial patches simplifying the serde definitions for
> the answer file.
>
> History
> =======
>
> v1: https://lore.proxmox.com/pve-devel/20250429132025.1543199-1-c.heiss@proxmox.com/T/
>
> [...]
Applied, thanks!
[1/2] auto: answer: drop unneeded #[serde(default)] attributes
commit: ea24d31b9d0f452c621e23cb0952f42975424979
[2/2] auto: answer: simplify `BTreeMap` handling in deserialization
commit: 9eebb9c42e1fc2095384f466748a0770589b960c
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-07 12:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-07 10:08 [pve-devel] [PATCH installer v2 0/2] auto: answer: answer file serde cleanups Christoph Heiss
2025-07-07 10:08 ` [pve-devel] [PATCH installer v2 1/2] auto: answer: drop unneeded #[serde(default)] attributes Christoph Heiss
2025-07-07 10:08 ` [pve-devel] [PATCH installer v2 2/2] auto: answer: simplify `BTreeMap` handling in deserialization Christoph Heiss
2025-07-07 12:40 ` [pve-devel] applied-series: [PATCH installer v2 0/2] auto: answer: answer file serde cleanups Thomas Lamprecht
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.