From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 1/2] ui: use better schema handling of `keyAlias` property strings
Date: Thu, 16 Jan 2025 10:22:26 +0100 [thread overview]
Message-ID: <20250116092227.991075-1-d.csapak@proxmox.com> (raw)
proxmox-schema can now handle that and we can remove the empty
ObjectSchema hack.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
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::<PropertyString<QemuConfigNet>>() {
+ 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::<PropertyString<LxcConfigNet>>() {
+ 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
next reply other threads:[~2025-01-16 9:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 9:22 Dominik Csapak [this message]
2025-01-16 9:22 ` [pdm-devel] [PATCH datacenter-manager 2/2] ui: use new `iter()` method of ArrayMap properties Dominik Csapak
2025-01-16 9:58 ` [pdm-devel] applied: [PATCH datacenter-manager 1/2] ui: use better schema handling of `keyAlias` property strings Dietmar Maurer
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=20250116092227.991075-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-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.