[pve-devel] [PATCH v4 proxmox-perl-rs 34/69] notify: add context for getting http_proxy from datacenter.cfg
Lukas Wagner
l.wagner at proxmox.com
Thu Jul 20 16:32:01 CEST 2023
Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
pve-rs/src/notify.rs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/pve-rs/src/notify.rs b/pve-rs/src/notify.rs
index 5fc11b2..5ab0ef5 100644
--- a/pve-rs/src/notify.rs
+++ b/pve-rs/src/notify.rs
@@ -62,6 +62,11 @@ impl Context for PVEContext {
.and_then(|content| lookup_datacenter_config_key(&content, "mail_from"))
.unwrap_or_else(|| String::from("root"))
}
+
+ fn http_proxy_config(&self) -> Option<String> {
+ let content = attempt_file_read("/etc/pve/datacenter.cfg");
+ content.and_then(|content| lookup_datacenter_config_key(&content, "http_proxy"))
+ }
}
#[cfg(test)]
@@ -89,6 +94,7 @@ user:no-mail at pve:1:0::::::
const DC_CONFIG: &str = "
email_from: user at example.com
+http_proxy: http://localhost:1234
keyboard: en-us
";
#[test]
@@ -97,6 +103,11 @@ keyboard: en-us
lookup_datacenter_config_key(DC_CONFIG, "email_from"),
Some("user at example.com".to_string())
);
+ assert_eq!(
+ lookup_datacenter_config_key(DC_CONFIG, "http_proxy"),
+ Some("http://localhost:1234".to_string())
+ );
+ assert_eq!(lookup_datacenter_config_key(DC_CONFIG, "foo"), None);
}
}
--
2.39.2
More information about the pve-devel
mailing list