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 066AB1FF16F for ; Thu, 16 Jan 2025 10:22:32 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 44B621B984; Thu, 16 Jan 2025 10:22:30 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Thu, 16 Jan 2025 10:22:26 +0100 Message-Id: <20250116092227.991075-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pdm-devel] [PATCH datacenter-manager 1/2] ui: use better schema handling of `keyAlias` property strings X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" proxmox-schema can now handle that and we can remove the empty ObjectSchema hack. Signed-off-by: Dominik Csapak --- ui/src/widget/pve_migrate_mapping.rs | 39 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/ui/src/widget/pve_migrate_mapping.rs b/ui/src/widget/pve_migrate_mapping.rs index 79d15cf..928b746 100644 --- a/ui/src/widget/pve_migrate_mapping.rs +++ b/ui/src/widget/pve_migrate_mapping.rs @@ -4,7 +4,7 @@ use anyhow::{bail, Error}; use serde_json::Value; use yew::{html::IntoPropValue, virtual_dom::Key, AttrValue, Properties}; -use proxmox_schema::{ObjectSchema, Schema}; +use proxmox_schema::property_string::PropertyString; use pwt::{ props::{ContainerBuilder, CssBorderBuilder, ExtractPrimaryKey, FieldBuilder, WidgetBuilder}, state::Store, @@ -19,7 +19,7 @@ use pwt::{ }; use pwt_macros::{builder, widget}; -use pdm_client::types::StorageContent; +use pdm_client::types::{LxcConfigNet, QemuConfigNet, StorageContent}; use crate::pve::{ utils::{foreach_drive_lxc, foreach_drive_qemu}, @@ -115,11 +115,6 @@ pub struct PveMigrateMapComp { _async_pool: AsyncPool, } -// HACK!, our rust schema does not support `keyAlias` yet, so we parse it into a generic value` -static NET_WORKAROUND_SCHEMA: Schema = ObjectSchema::new("", &[]) - .additional_properties(true) - .schema(); - impl PveMigrateMapComp { async fn load_storages( remote: AttrValue, @@ -158,12 +153,15 @@ impl PveMigrateMapComp { let mut networks = HashSet::new(); - let nets = serde_json::to_value(&config.net)?; - for (_key, net) in nets.as_object().unwrap() { - let net = NET_WORKAROUND_SCHEMA.parse_property_string(net.as_str().unwrap())?; - - if let Some(bridge) = net.get("bridge") { - networks.insert(bridge.as_str().unwrap().to_string()); + for (idx, net) in config.net.iter() { + let key = format!("net{idx}"); + match net.parse::>() { + Ok(net) => { + if let Some(bridge) = net.into_inner().bridge { + networks.insert(bridge); + } + } + Err(err) => log::error!("could not parse {key}: {err}"), } } @@ -204,12 +202,15 @@ impl PveMigrateMapComp { let mut networks = HashSet::new(); - let nets = serde_json::to_value(&config.net)?; - for (_key, net) in nets.as_object().unwrap() { - let net = NET_WORKAROUND_SCHEMA.parse_property_string(net.as_str().unwrap())?; - - if let Some(bridge) = net.get("bridge") { - networks.insert(bridge.as_str().unwrap().to_string()); + for (idx, net) in (&*config.net).into_iter() { + let key = format!("net{idx}"); + match net.parse::>() { + Ok(net) => { + if let Some(bridge) = net.into_inner().bridge { + networks.insert(bridge); + } + } + Err(err) => log::error!("could not parse {key}: {err}"), } } -- 2.39.5 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel