[pve-devel] [PATCH installer 1/6] auto: utils: avoid a force unwrap()

Christoph Heiss c.heiss at proxmox.com
Thu Mar 27 16:17:12 CET 2025


At this point, this value will definitely be set & valid and *should*
never be `None`. Still, better be safe than sorry and just unwrap_or()
with a sane default value instead.

Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
 proxmox-auto-installer/src/utils.rs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/proxmox-auto-installer/src/utils.rs b/proxmox-auto-installer/src/utils.rs
index 1789fd8..655fecb 100644
--- a/proxmox-auto-installer/src/utils.rs
+++ b/proxmox-auto-installer/src/utils.rs
@@ -424,7 +424,11 @@ pub fn parse_answer(
 
         mngmt_nic: network_settings.ifname,
 
-        hostname: network_settings.fqdn.host().unwrap().to_string(),
+        hostname: network_settings
+            .fqdn
+            .host()
+            .unwrap_or(setup_info.config.product.default_hostname())
+            .to_string(),
         domain: network_settings.fqdn.domain(),
         cidr: network_settings.address,
         gateway: network_settings.gateway,
-- 
2.48.1





More information about the pve-devel mailing list