[pdm-devel] [PATCH yew-comp v2 2/2] pve: lxc panels: prepare/add version feature gating

Dominik Csapak d.csapak at proxmox.com
Tue Dec 2 12:13:31 CET 2025


add the pve-manager version as property to the various lxc panels, and
use it on the options to display the new 'env' and 'entrypoint' options,
analogous to how we do it for the qemu panel.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/configuration/pve/lxc_dns_panel.rs        |  6 ++++
 src/configuration/pve/lxc_network_panel.rs    |  6 ++++
 src/configuration/pve/lxc_options_panel.rs    | 32 ++++++++++++++++---
 .../pve/lxc_resources_panel/mod.rs            |  6 ++++
 src/form/pve/lxc_property/mod.rs              | 11 +++++++
 src/form/pve/mod.rs                           | 10 +++---
 6 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/src/configuration/pve/lxc_dns_panel.rs b/src/configuration/pve/lxc_dns_panel.rs
index 303843a..d9bf89c 100644
--- a/src/configuration/pve/lxc_dns_panel.rs
+++ b/src/configuration/pve/lxc_dns_panel.rs
@@ -7,6 +7,7 @@ use serde_json::Value;
 use yew::html::IntoPropValue;
 use yew::virtual_dom::{VComp, VNode};
 
+use proxmox_deb_version::Version;
 use pwt::prelude::*;
 use pwt_macros::builder;
 
@@ -21,6 +22,11 @@ pub struct LxcDnsPanel {
     vmid: u32,
     node: AttrValue,
 
+    #[prop_or_default]
+    #[builder(IntoPropValue, into_prop_value)]
+    /// The nodes pve-manager version, used to feature gate some entries
+    pve_manager_version: Option<Version>,
+
     /// Use Proxmox Datacenter Manager API endpoints
     #[builder(IntoPropValue, into_prop_value)]
     #[prop_or_default]
diff --git a/src/configuration/pve/lxc_network_panel.rs b/src/configuration/pve/lxc_network_panel.rs
index 613448a..953edba 100644
--- a/src/configuration/pve/lxc_network_panel.rs
+++ b/src/configuration/pve/lxc_network_panel.rs
@@ -12,6 +12,7 @@ use pwt::widget::{Button, Column, Container, Fa, List, ListTile, Toolbar};
 use yew::html::IntoPropValue;
 use yew::virtual_dom::{Key, VComp, VNode};
 
+use proxmox_deb_version::Version;
 use pwt::prelude::*;
 use pwt::props::{ExtractPrimaryKey, SubmitCallback};
 use pwt::state::{Selection, Store};
@@ -32,6 +33,11 @@ pub struct LxcNetworkPanel {
     vmid: u32,
     node: AttrValue,
 
+    #[prop_or_default]
+    #[builder(IntoPropValue, into_prop_value)]
+    /// The nodes pve-manager version, used to feature gate some entries
+    pve_manager_version: Option<Version>,
+
     /// Use Proxmox Datacenter Manager API endpoints
     #[builder(IntoPropValue, into_prop_value)]
     #[prop_or_default]
diff --git a/src/configuration/pve/lxc_options_panel.rs b/src/configuration/pve/lxc_options_panel.rs
index a2d9760..8669764 100644
--- a/src/configuration/pve/lxc_options_panel.rs
+++ b/src/configuration/pve/lxc_options_panel.rs
@@ -6,6 +6,7 @@ use serde_json::Value;
 use yew::html::IntoPropValue;
 use yew::virtual_dom::{VComp, VNode};
 
+use proxmox_deb_version::Version;
 use pwt::prelude::*;
 
 use crate::configuration::{guest_config_url, guest_pending_url};
@@ -19,12 +20,20 @@ use pve_api_types::LxcConfig;
 
 use pwt_macros::builder;
 
+// newest known pve-manager version we care for
+const NEWEST_KNOWN_VERSION: &str = "9.1.2";
+
 #[derive(Clone, PartialEq, Properties)]
 #[builder]
 pub struct LxcOptionsPanel {
     vmid: u32,
     node: AttrValue,
 
+    #[prop_or_default]
+    #[builder(IntoPropValue, into_prop_value)]
+    /// The nodes pve-manager version, used to feature gate some entries
+    pve_manager_version: Option<Version>,
+
     /// Use Proxmox Datacenter Manager API endpoints
     #[builder(IntoPropValue, into_prop_value)]
     #[prop_or_default]
@@ -54,8 +63,13 @@ pub struct PveLxcOptionsPanel {
     properties: Rc<Vec<EditableProperty>>,
 }
 
-fn properties(_node: &str, _vmid: u32, mobile: bool) -> Vec<EditableProperty> {
-    vec![
+fn properties(
+    _node: &str,
+    _vmid: u32,
+    pve_manager_version: Option<Version>,
+    mobile: bool,
+) -> Vec<EditableProperty> {
+    let mut properties = vec![
         //crate::form::pve::Lxc_name_property(vmid, mobile),
         crate::form::pve::qemu_onboot_property(mobile),
         crate::form::pve::qemu_startup_property(mobile),
@@ -68,7 +82,16 @@ fn properties(_node: &str, _vmid: u32, mobile: bool) -> Vec<EditableProperty> {
         crate::form::pve::lxc_unpriviledged_property(),
         crate::form::pve::lxc_features_property(mobile),
         crate::form::pve::lxc_hookscript_property(),
-    ]
+    ];
+
+    let version = pve_manager_version.unwrap_or(Version::new(NEWEST_KNOWN_VERSION, None));
+
+    if version >= Version::new("9.1", None) {
+        properties.push(crate::form::pve::lxc_entrypoint_property());
+        properties.push(crate::form::pve::lxc_env_property());
+    }
+
+    properties
 }
 
 impl Component for PveLxcOptionsPanel {
@@ -77,8 +100,9 @@ impl Component for PveLxcOptionsPanel {
 
     fn create(ctx: &Context<Self>) -> Self {
         let props = ctx.props();
+        let version = props.pve_manager_version.clone();
         Self {
-            properties: Rc::new(properties(&props.node, props.vmid, props.mobile)),
+            properties: Rc::new(properties(&props.node, props.vmid, version, props.mobile)),
         }
     }
 
diff --git a/src/configuration/pve/lxc_resources_panel/mod.rs b/src/configuration/pve/lxc_resources_panel/mod.rs
index 54e66aa..ecc9861 100644
--- a/src/configuration/pve/lxc_resources_panel/mod.rs
+++ b/src/configuration/pve/lxc_resources_panel/mod.rs
@@ -12,6 +12,7 @@ use yew::virtual_dom::{VComp, VNode};
 
 use pve_api_types::LxcConfig;
 
+use proxmox_deb_version::Version;
 use pwt::prelude::*;
 use pwt::props::SubmitCallback;
 use pwt_macros::builder;
@@ -35,6 +36,11 @@ pub struct LxcResourcesPanel {
     vmid: u32,
     node: AttrValue,
 
+    #[prop_or_default]
+    #[builder(IntoPropValue, into_prop_value)]
+    /// The nodes pve-manager version, used to feature gate some entries
+    pve_manager_version: Option<Version>,
+
     /// Use Proxmox Datacenter Manager API endpoints
     #[builder(IntoPropValue, into_prop_value)]
     #[prop_or_default]
diff --git a/src/form/pve/lxc_property/mod.rs b/src/form/pve/lxc_property/mod.rs
index 2864359..54d175d 100644
--- a/src/form/pve/lxc_property/mod.rs
+++ b/src/form/pve/lxc_property/mod.rs
@@ -119,6 +119,17 @@ pub fn lxc_hookscript_property() -> EditableProperty {
     EditableProperty::new("hookscript", tr!("Hookscript"))
 }
 
+pub fn lxc_entrypoint_property() -> EditableProperty {
+    EditableProperty::new("entrypoint", tr!("Entrypoint"))
+}
+
+pub fn lxc_env_property() -> EditableProperty {
+    EditableProperty::new("env", tr!("Environment")).renderer(|_name, value, _data| match value {
+        Value::String(env) => env.split('\0').collect::<Vec<_>>().join(" ").into(),
+        _ => value.into(),
+    })
+}
+
 pub fn lxc_tty_count_property(mobile: bool) -> EditableProperty {
     let title = tr!("TTY count");
     EditableProperty::new("tty", title.clone())
diff --git a/src/form/pve/mod.rs b/src/form/pve/mod.rs
index fc0e2c5..0be5e6f 100644
--- a/src/form/pve/mod.rs
+++ b/src/form/pve/mod.rs
@@ -54,11 +54,11 @@ pub use lxc_mount_options_selector::LxcMountOptionsSelector;
 mod lxc_property;
 pub use lxc_property::{
     extract_used_mount_points, first_unused_mount_point, lxc_architecture_property,
-    lxc_console_mode_property, lxc_console_property, lxc_cores_property, lxc_features_property,
-    lxc_hookscript_property, lxc_hostname_property, lxc_memory_property, lxc_mount_point_property,
-    lxc_nameserver_property, lxc_network_property, lxc_ostype_property, lxc_rootfs_property,
-    lxc_searchdomain_property, lxc_swap_property, lxc_tty_count_property,
-    lxc_unpriviledged_property, lxc_unused_volume_property,
+    lxc_console_mode_property, lxc_console_property, lxc_cores_property, lxc_entrypoint_property,
+    lxc_env_property, lxc_features_property, lxc_hookscript_property, lxc_hostname_property,
+    lxc_memory_property, lxc_mount_point_property, lxc_nameserver_property, lxc_network_property,
+    lxc_ostype_property, lxc_rootfs_property, lxc_searchdomain_property, lxc_swap_property,
+    lxc_tty_count_property, lxc_unpriviledged_property, lxc_unused_volume_property,
 };
 
 mod qemu_property;
-- 
2.47.3





More information about the pdm-devel mailing list