]> git.proxmox.com Git - pve-installer.git/commitdiff
tui: do not fail completely on invalid domain names
authorChristoph Heiss <c.heiss@proxmox.com>
Wed, 21 Jun 2023 09:40:44 +0000 (11:40 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 21 Jun 2023 10:20:41 +0000 (12:20 +0200)
Since we already handly non-present domain names, invalid names can be
handled the same way, as not to completely fail the installation.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
proxmox-tui-installer/src/setup.rs

index 7f70b57cc646532f127726a3c92c2baf2eddb84b..1faa5fead5da834f5e68954788c725950586c3e2 100644 (file)
@@ -359,6 +359,7 @@ pub struct NetworkInfo {
 
 #[derive(Clone, Deserialize)]
 pub struct Dns {
+    #[serde(deserialize_with = "deserialize_invalid_value_as_none")]
     pub domain: Option<Fqdn>,
 
     /// List of stringified IP addresses.
@@ -396,3 +397,11 @@ pub struct Interface {
     #[serde(deserialize_with = "deserialize_cidr_list")]
     pub addresses: Option<Vec<CidrAddress>>,
 }
+
+fn deserialize_invalid_value_as_none<'de, D, T>(deserializer: D) -> Result<Option<T>, D::Error>
+where
+    D: Deserializer<'de>,
+    T: Deserialize<'de>,
+{
+    Ok(Deserialize::deserialize(deserializer).ok())
+}