From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id A39B01FF09C for ; Mon, 02 Nov 2026 13:50:49 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C4A342187D; Mon, 02 Nov 2026 13:50:37 +0100 (CET) From: Christoph Heiss To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 4/5] ui: auto-installer: use .to_string() instead of manual serde variant Date: Mon, 2 Nov 2026 13:49:36 +0100 Message-ID: <20261102124939.1023342-5-c.heiss@proxmox.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261102124939.1023342-1-c.heiss@proxmox.com> References: <20261102124939.1023342-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793623810040 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.175 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 55XK5CYFCWJR47O2MNWZXWAVLHAGDZEI X-Message-ID-Hash: 55XK5CYFCWJR47O2MNWZXWAVLHAGDZEI X-MailFrom: c.heiss@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: No functional changes. Signed-off-by: Christoph Heiss --- lib/pdm-api-types/src/auto_installer.rs | 1 + ui/Cargo.toml | 2 +- .../auto_installer/prepared_answer_form.rs | 41 +++++++------------ 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/lib/pdm-api-types/src/auto_installer.rs b/lib/pdm-api-types/src/auto_installer.rs index 4a2dce13..858bd0c2 100644 --- a/lib/pdm-api-types/src/auto_installer.rs +++ b/lib/pdm-api-types/src/auto_installer.rs @@ -87,6 +87,7 @@ pub enum DiskSelectionMode { } serde_plain::derive_fromstr_from_deserialize!(DiskSelectionMode); +serde_plain::derive_display_from_serialize!(DiskSelectionMode); const_regex! { /// Regex for matching the key of udev filters. diff --git a/ui/Cargo.toml b/ui/Cargo.toml index 99ff5619..d3053802 100644 --- a/ui/Cargo.toml +++ b/ui/Cargo.toml @@ -38,7 +38,7 @@ proxmox-acme-api = "1" proxmox-deb-version = "0.1" proxmox-client = "1" proxmox-human-byte = "1" -proxmox-installer-types = "0.2" +proxmox-installer-types = "0.3" proxmox-login = "1" proxmox-network-types = "1.1" proxmox-schema = "5" diff --git a/ui/src/remotes/auto_installer/prepared_answer_form.rs b/ui/src/remotes/auto_installer/prepared_answer_form.rs index 960decae..0b01baf1 100644 --- a/ui/src/remotes/auto_installer/prepared_answer_form.rs +++ b/ui/src/remotes/auto_installer/prepared_answer_form.rs @@ -2,7 +2,7 @@ //! edit window, as well as some utility to collect and prepare the form data for submission. use anyhow::{Result, anyhow, bail}; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; use serde_json::{Value, json}; use std::{collections::BTreeMap, ops::Deref, rc::Rc, sync::LazyLock}; @@ -248,7 +248,7 @@ pub fn render_global_options_form( .items(Rc::new( KEYBOARD_LAYOUTS .iter() - .map(|l| serde_variant_name(l).expect("valid variant").into()) + .map(|l| l.to_string().into()) .collect(), )) .render_value(|v: &AttrValue| { @@ -257,7 +257,7 @@ pub fn render_global_options_form( .unwrap_or_default() .into() }) - .value(serde_variant_name(config.keyboard)) + .value(config.keyboard.to_string()) .filter(|item: &AttrValue, query: &str| { let query = query.to_string().to_lowercase(); let item = item.to_string(); @@ -317,7 +317,7 @@ pub fn render_global_options_form( .items(Rc::new( [RebootMode::Reboot, RebootMode::PowerOff] .iter() - .map(|opt| serde_variant_name(opt).expect("valid variant").into()) + .map(|m| m.to_string().into()) .collect(), )) .render_value(|v: &AttrValue| match v.parse::() { @@ -325,7 +325,7 @@ pub fn render_global_options_form( Ok(RebootMode::PowerOff) => tr!("Power off").into(), _ => v.into(), }) - .value(serde_variant_name(config.reboot_mode)) + .value(config.reboot_mode.to_string()) .required(true), ) .with_field( @@ -482,7 +482,7 @@ pub fn render_disk_setup_form( .items(Rc::new( FILESYSTEM_TYPE_OPTIONS .iter() - .map(|opt| serde_variant_name(opt).expect("valid variant").into()) + .map(|opt| opt.to_string().into()) .collect(), )) .render_value(|v: &AttrValue| { @@ -491,7 +491,7 @@ pub fn render_disk_setup_form( .unwrap_or_default() .into() }) - .value(serde_variant_name(config.filesystem.to_type())) + .value(config.filesystem.to_type().to_string()) .required(true) .show_filter(false), ) @@ -508,7 +508,7 @@ pub fn render_disk_setup_form( _ => v.into(), }) .required(true) - .value(serde_variant_name(config.disk_mode)), + .value(config.disk_mode.to_string()), ) .with_field( tr!("Disk Names"), @@ -528,7 +528,7 @@ pub fn render_disk_setup_form( .items(Rc::new( [FilterMatch::Any, FilterMatch::All] .iter() - .map(|opt| serde_variant_name(opt).expect("valid variant").into()) + .map(|opt| opt.to_string().into()) .collect(), )) .render_value(|v: &AttrValue| match v.parse::() { @@ -536,8 +536,8 @@ pub fn render_disk_setup_form( Ok(FilterMatch::All) => tr!("Match All Filters").into(), _ => v.into(), }) - .default(serde_variant_name(FilterMatch::default())) - .value(config.disk_filter_match.and_then(serde_variant_name)) + .default(FilterMatch::default().to_string()) + .value(config.disk_filter_match.map(|v| v.to_string())) .disabled(disk_mode != DiskSelectionMode::Filter), ) .with_large_field( @@ -729,7 +729,7 @@ fn add_zfs_advanced_form_fields(panel: &mut InputPanel, fs_opts: &ZfsOptions) { .items(Rc::new( ZFS_CHECKSUM_OPTIONS .iter() - .map(|opt| serde_variant_name(opt).expect("valid variant").into()) + .map(|opt| opt.to_string().into()) .collect(), )) .render_value(|v: &AttrValue| { @@ -751,7 +751,7 @@ fn add_zfs_advanced_form_fields(panel: &mut InputPanel, fs_opts: &ZfsOptions) { .items(Rc::new( ZFS_COMPRESS_OPTIONS .iter() - .map(|opt| serde_variant_name(opt).expect("valid variant").into()) + .map(|opt| opt.to_string().into()) .collect(), )) .render_value(|v: &AttrValue| { @@ -789,7 +789,7 @@ fn add_btrfs_advanced_form_fields(panel: &mut InputPanel, fs_opts: &BtrfsOptions .items(Rc::new( BTRFS_COMPRESS_OPTIONS .iter() - .map(|opt| serde_variant_name(opt).expect("valid variant").into()) + .map(|opt| opt.to_string().into()) .collect(), )) .render_value(|v: &AttrValue| { @@ -1223,19 +1223,6 @@ fn kv_list_to_template_counter_map_validate(v: &Vec<(String, Value)>) -> Result< Ok(serde_json::to_value(map)?) } -fn serde_variant_name(ty: T) -> Option { - match serde_json::to_value(ty) { - Ok(Value::String(s)) => Some(s), - other => { - log::warn!( - "expected string of type {}, got {other:?}", - std::any::type_name::() - ); - None - } - } -} - const KEYBOARD_LAYOUTS: &[KeyboardLayout] = { use KeyboardLayout::*; &[ -- 2.55.0