public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] api: serde-rename deleteable properties to kebab-case
@ 2023-01-19 15:52 Lukas Wagner
  2023-01-20  7:48 ` [pbs-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Wagner @ 2023-01-19 15:52 UTC (permalink / raw)
  To: pbs-devel

In former commit, the enum members were renamed to be CamelCase, in
accordance with the usual Rust style guide. However, this broke the
GUI in some places due to failing JSON property deserialization.
To fix this, some serde(rename = "kebab-case") directives were added.

Some properties were also serde-renamed to snake_case, otherwise
it would have been necessary to also modify proxmox-widget-toolkit
as well as PVE source code. This can follow in a later commit if so
desired.

Fixes: a2055c38 fix non-camel-case enums
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 src/api2/config/media_pool.rs | 1 +
 src/api2/config/remote.rs     | 1 +
 src/api2/node/dns.rs          | 1 +
 src/api2/node/network.rs      | 5 ++++-
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/api2/config/media_pool.rs b/src/api2/config/media_pool.rs
index 79e2e9c5..4a4cec56 100644
--- a/src/api2/config/media_pool.rs
+++ b/src/api2/config/media_pool.rs
@@ -103,6 +103,7 @@ pub fn get_config(name: String) -> Result<MediaPoolConfig, Error> {
 
 #[api()]
 #[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
 /// Deletable property name
 pub enum DeletableProperty {
     /// Delete media set allocation policy.
diff --git a/src/api2/config/remote.rs b/src/api2/config/remote.rs
index fb97b3e1..2f02d121 100644
--- a/src/api2/config/remote.rs
+++ b/src/api2/config/remote.rs
@@ -133,6 +133,7 @@ pub fn read_remote(
 
 #[api()]
 #[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
 /// Deletable property name
 pub enum DeletableProperty {
     /// Delete the comment property.
diff --git a/src/api2/node/dns.rs b/src/api2/node/dns.rs
index 6804a102..4f6822d8 100644
--- a/src/api2/node/dns.rs
+++ b/src/api2/node/dns.rs
@@ -22,6 +22,7 @@ static RESOLV_CONF_FN: &str = "/etc/resolv.conf";
 
 #[api()]
 #[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
 /// Deletable property name
 pub enum DeletableProperty {
     /// Delete first nameserver entry
diff --git a/src/api2/node/network.rs b/src/api2/node/network.rs
index fef0a6cb..ade6fe40 100644
--- a/src/api2/node/network.rs
+++ b/src/api2/node/network.rs
@@ -400,6 +400,7 @@ pub fn create_interface(
 
 #[api()]
 #[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
 /// Deletable property name
 pub enum DeletableProperty {
     /// Delete the IPv4 address property.
@@ -423,15 +424,17 @@ pub enum DeletableProperty {
     /// Delete autostart flag
     Autostart,
     /// Delete bridge ports (set to 'none')
+    #[serde(rename = "bridge_ports")]
     BridgePorts,
     /// Delete bridge-vlan-aware flag
+    #[serde(rename = "bridge_vlan_aware")]
     BridgeVlanAware,
     /// Delete bond-slaves (set to 'none')
     Slaves,
     /// Delete bond-primary
-    #[serde(rename = "bond-primary")]
     BondPrimary,
     /// Delete bond transmit hash policy
+    #[serde(rename = "bond_xmit_hash_policy")]
     BondXmitHashPolicy,
 }
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup] api: serde-rename deleteable properties to kebab-case
  2023-01-19 15:52 [pbs-devel] [PATCH proxmox-backup] api: serde-rename deleteable properties to kebab-case Lukas Wagner
@ 2023-01-20  7:48 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-01-20  7:48 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Lukas Wagner

Am 19/01/2023 um 16:52 schrieb Lukas Wagner:
> In former commit, the enum members were renamed to be CamelCase, in
> accordance with the usual Rust style guide. However, this broke the
> GUI in some places due to failing JSON property deserialization.
> To fix this, some serde(rename = "kebab-case") directives were added.
> 
> Some properties were also serde-renamed to snake_case, otherwise
> it would have been necessary to also modify proxmox-widget-toolkit
> as well as PVE source code. This can follow in a later commit if so
> desired.
> 
> Fixes: a2055c38 fix non-camel-case enums
> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
> ---
>  src/api2/config/media_pool.rs | 1 +
>  src/api2/config/remote.rs     | 1 +
>  src/api2/node/dns.rs          | 1 +
>  src/api2/node/network.rs      | 5 ++++-
>  4 files changed, 7 insertions(+), 1 deletion(-)
> 
>

applied, thanks!

Wonder if we could have some sane checks for catching that; e.g., a rust test that
reads a in-git saved schema and diffs it with the current one, with noting/warning
newly added properties and throwing an error if existing ones change, so that the
dev needs to record such changes explicitly with the patch they're modifying it, if
it's a wanted change that is.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-20  7:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-19 15:52 [pbs-devel] [PATCH proxmox-backup] api: serde-rename deleteable properties to kebab-case Lukas Wagner
2023-01-20  7:48 ` [pbs-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal