From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 5F8581FF187 for ; Tue, 2 Dec 2025 11:00:02 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B8816A8A7; Tue, 2 Dec 2025 11:00:23 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Tue, 2 Dec 2025 11:00:01 +0100 Message-ID: <20251202100012.1328096-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251202100012.1328096-1-d.csapak@proxmox.com> References: <20251202100012.1328096-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.120 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 POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_2 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_4 0.1 random spam to be learned in bayes 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 yew-comp 2/2] pve: lxc panels: prepare/add version feature gating 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" 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 --- src/configuration/pve/lxc_dns_panel.rs | 5 +++ src/configuration/pve/lxc_network_panel.rs | 5 +++ src/configuration/pve/lxc_options_panel.rs | 33 ++++++++++++++++--- .../pve/lxc_resources_panel/mod.rs | 5 +++ src/form/pve/lxc_property/mod.rs | 11 +++++++ src/form/pve/mod.rs | 10 +++--- 6 files changed, 60 insertions(+), 9 deletions(-) diff --git a/src/configuration/pve/lxc_dns_panel.rs b/src/configuration/pve/lxc_dns_panel.rs index 303843a..1e3a969 100644 --- a/src/configuration/pve/lxc_dns_panel.rs +++ b/src/configuration/pve/lxc_dns_panel.rs @@ -21,6 +21,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, + /// 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..de78ff9 100644 --- a/src/configuration/pve/lxc_network_panel.rs +++ b/src/configuration/pve/lxc_network_panel.rs @@ -32,6 +32,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, + /// 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..96edd00 100644 --- a/src/configuration/pve/lxc_options_panel.rs +++ b/src/configuration/pve/lxc_options_panel.rs @@ -1,5 +1,7 @@ +use std::cmp::Ordering; use std::rc::Rc; +use proxmox_deb_version::cmp_versions; use pwt::props::SubmitCallback; use serde_json::Value; @@ -19,12 +21,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, + /// Use Proxmox Datacenter Manager API endpoints #[builder(IntoPropValue, into_prop_value)] #[prop_or_default] @@ -54,8 +64,13 @@ pub struct PveLxcOptionsPanel { properties: Rc>, } -fn properties(_node: &str, _vmid: u32, mobile: bool) -> Vec { - vec![ +fn properties( + _node: &str, + _vmid: u32, + pve_manager_version: Option<&str>, + mobile: bool, +) -> Vec { + 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 +83,16 @@ fn properties(_node: &str, _vmid: u32, mobile: bool) -> Vec { 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(NEWEST_KNOWN_VERSION); + + if cmp_versions(version, "9.1") != Ok(Ordering::Less) { + properties.push(crate::form::pve::lxc_entrypoint_property()); + properties.push(crate::form::pve::lxc_env_property()); + } + + properties } impl Component for PveLxcOptionsPanel { @@ -77,8 +101,9 @@ impl Component for PveLxcOptionsPanel { fn create(ctx: &Context) -> Self { let props = ctx.props(); + let version = props.pve_manager_version.as_deref(); 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..31eb859 100644 --- a/src/configuration/pve/lxc_resources_panel/mod.rs +++ b/src/configuration/pve/lxc_resources_panel/mod.rs @@ -35,6 +35,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, + /// 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::>().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 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel