* [pdm-devel] [PATCH datacenter-manager 1/2] ui: use better schema handling of `keyAlias` property strings
@ 2025-01-16 9:22 Dominik Csapak
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
0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2025-01-16 9:22 UTC (permalink / raw)
To: pdm-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pdm-devel] [PATCH datacenter-manager 2/2] ui: use new `iter()` method of ArrayMap properties
2025-01-16 9:22 [pdm-devel] [PATCH datacenter-manager 1/2] ui: use better schema handling of `keyAlias` property strings Dominik Csapak
@ 2025-01-16 9:22 ` 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
1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2025-01-16 9:22 UTC (permalink / raw)
To: pdm-devel
they now can be directly referenced with that, instead of going over the
ArrayMap `Deref` and using `.into_iter()`.
Makes the code a bit clearer since the ref/deref syntax looks a bit
strange.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
ui/src/pve/utils.rs | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/ui/src/pve/utils.rs b/ui/src/pve/utils.rs
index 3cb45a9..bb02f56 100644
--- a/ui/src/pve/utils.rs
+++ b/ui/src/pve/utils.rs
@@ -152,7 +152,7 @@ pub fn foreach_drive_qemu<F>(config: &QemuConfig, mut f: F)
where
F: FnMut(&str, Result<PveDriveQemu, Error>),
{
- for (idx, value) in (&*config.ide).into_iter() {
+ for (idx, value) in config.ide.iter() {
let key = format!("ide{idx}");
let res = value
.parse::<PropertyString<PveQmIde>>()
@@ -160,7 +160,7 @@ where
f(&key, res.map_err(Error::from));
}
- for (idx, value) in (&*config.sata).into_iter() {
+ for (idx, value) in config.sata.iter() {
let key = format!("sata{idx}");
let res = value
.parse::<PropertyString<QemuConfigSata>>()
@@ -168,7 +168,7 @@ where
f(&key, res.map_err(Error::from));
}
- for (idx, value) in (&*config.scsi).into_iter() {
+ for (idx, value) in config.scsi.iter() {
let key = format!("scsi{idx}");
let res = value
.parse::<PropertyString<QemuConfigScsi>>()
@@ -176,7 +176,7 @@ where
f(&key, res.map_err(Error::from));
}
- for (idx, value) in (&*config.virtio).into_iter() {
+ for (idx, value) in config.virtio.iter() {
let key = format!("virtio{idx}");
let res = value
.parse::<PropertyString<QemuConfigVirtio>>()
@@ -184,7 +184,7 @@ where
f(&key, res.map_err(Error::from));
}
- for (idx, value) in (&*config.unused).into_iter() {
+ for (idx, value) in config.unused.iter() {
let key = format!("unused{idx}");
let res = value
.parse::<PropertyString<QemuConfigUnused>>()
@@ -224,7 +224,7 @@ where
f(key, res.map_err(Error::from));
}
- for (idx, value) in (&*config.mp).into_iter() {
+ for (idx, value) in config.mp.iter() {
let key = format!("mp{idx}");
let res = value
.parse::<PropertyString<LxcConfigMp>>()
@@ -232,7 +232,7 @@ where
f(&key, res.map_err(Error::from));
}
- for (idx, value) in (&*config.unused).into_iter() {
+ for (idx, value) in config.unused.iter() {
let key = format!("unused{idx}");
let res = value
.parse::<PropertyString<LxcConfigUnused>>()
--
2.39.5
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pdm-devel] applied: [PATCH datacenter-manager 1/2] ui: use better schema handling of `keyAlias` property strings
2025-01-16 9:22 [pdm-devel] [PATCH datacenter-manager 1/2] ui: use better schema handling of `keyAlias` property strings Dominik Csapak
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 ` Dietmar Maurer
1 sibling, 0 replies; 3+ messages in thread
From: Dietmar Maurer @ 2025-01-16 9:58 UTC (permalink / raw)
To: Proxmox Datacenter Manager development discussion, Dominik Csapak
applied both patches
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-16 9:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-16 9:22 [pdm-devel] [PATCH datacenter-manager 1/2] ui: use better schema handling of `keyAlias` property strings Dominik Csapak
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
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.