]> git.proxmox.com Git - pve-installer.git/commitdiff
tui: use network domain as default administrator email domain
authorChristoph Heiss <c.heiss@proxmox.com>
Tue, 20 Jun 2023 08:51:26 +0000 (10:51 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Jun 2023 09:09:39 +0000 (11:09 +0200)
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
proxmox-tui-installer/src/main.rs
proxmox-tui-installer/src/options.rs

index 0588f9fd7d8e87cd8109da856fd2a6c7f9d995c1..d985642c0e9d5f19395c697c620da8745526047f 100644 (file)
@@ -177,7 +177,7 @@ fn main() {
         options: InstallerOptions {
             bootdisk: BootdiskOptions::defaults_from(&runtime_info.disks[0]),
             timezone: TimezoneOptions::defaults_from(&runtime_info, &locales),
-            password: PasswordOptions::default(),
+            password: PasswordOptions::defaults_from(&runtime_info),
             network: NetworkOptions::from(&runtime_info.network),
             reboot: false,
         },
index 64437e6ffafc88dba89960b800353336dcf7cf07..9f6408c9064b3a76a4dd31788d8a3f99f4f437ca 100644 (file)
@@ -318,10 +318,18 @@ pub struct PasswordOptions {
     pub root_password: String,
 }
 
-impl Default for PasswordOptions {
-    fn default() -> Self {
+impl PasswordOptions {
+    pub fn defaults_from(info: &RuntimeInfo) -> Self {
+        let domain = info
+            .network
+            .dns
+            .domain
+            .clone()
+            // Safety: The provided default domain will always be valid.
+            .unwrap_or_else(|| Fqdn::from("example.invalid").unwrap());
+
         Self {
-            email: "mail@example.invalid".to_owned(),
+            email: format!("mail@{domain}"),
             root_password: String::new(),
         }
     }