style: apply rustfmt to client.rs and vm.rs
Some checks failed
PR Review Automation / review (pull_request) Has been cancelled
Test / frontend-tests (pull_request) Successful in 1m41s
Test / frontend-typecheck (pull_request) Successful in 1m53s
Test / rust-fmt-check (pull_request) Successful in 12m3s
Test / rust-clippy (pull_request) Successful in 13m49s
Test / rust-tests (pull_request) Successful in 15m45s
Some checks failed
PR Review Automation / review (pull_request) Has been cancelled
Test / frontend-tests (pull_request) Successful in 1m41s
Test / frontend-typecheck (pull_request) Successful in 1m53s
Test / rust-fmt-check (pull_request) Successful in 12m3s
Test / rust-clippy (pull_request) Successful in 13m49s
Test / rust-tests (pull_request) Successful in 15m45s
This commit is contained in:
parent
c8399bcdeb
commit
c1885ffc2b
@ -136,7 +136,11 @@ impl ProxmoxClient {
|
|||||||
|
|
||||||
/// Build request headers with authentication.
|
/// Build request headers with authentication.
|
||||||
/// `include_csrf` should be true for POST / PUT / DELETE requests.
|
/// `include_csrf` should be true for POST / PUT / DELETE requests.
|
||||||
fn build_headers(&self, ticket: Option<&str>, include_csrf: bool) -> reqwest::header::HeaderMap {
|
fn build_headers(
|
||||||
|
&self,
|
||||||
|
ticket: Option<&str>,
|
||||||
|
include_csrf: bool,
|
||||||
|
) -> reqwest::header::HeaderMap {
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
let mut headers = reqwest::header::HeaderMap::new();
|
||||||
|
|
||||||
if let Some(token) = &self.api_token {
|
if let Some(token) = &self.api_token {
|
||||||
@ -395,7 +399,11 @@ mod tests {
|
|||||||
|
|
||||||
let headers = client.build_headers(Some("my-ticket"), true);
|
let headers = client.build_headers(Some("my-ticket"), true);
|
||||||
assert!(headers.contains_key("CSRFPreventionToken"));
|
assert!(headers.contains_key("CSRFPreventionToken"));
|
||||||
let csrf_val = headers.get("CSRFPreventionToken").unwrap().to_str().unwrap();
|
let csrf_val = headers
|
||||||
|
.get("CSRFPreventionToken")
|
||||||
|
.unwrap()
|
||||||
|
.to_str()
|
||||||
|
.unwrap();
|
||||||
assert_eq!(csrf_val, "my-csrf");
|
assert_eq!(csrf_val, "my-csrf");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -151,8 +151,15 @@ pub async fn list_vms(
|
|||||||
if resource_type != "qemu" {
|
if resource_type != "qemu" {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let name = r.get("name").and_then(|n| n.as_str()).map(|s| s.to_string());
|
let name = r
|
||||||
let status = r.get("status").and_then(|s| s.as_str()).unwrap_or("unknown").to_string();
|
.get("name")
|
||||||
|
.and_then(|n| n.as_str())
|
||||||
|
.map(|s| s.to_string());
|
||||||
|
let status = r
|
||||||
|
.get("status")
|
||||||
|
.and_then(|s| s.as_str())
|
||||||
|
.unwrap_or("unknown")
|
||||||
|
.to_string();
|
||||||
// cpu may be absent for stopped VMs
|
// cpu may be absent for stopped VMs
|
||||||
let cpu = r.get("cpu").and_then(|c| c.as_f64()).unwrap_or(0.0);
|
let cpu = r.get("cpu").and_then(|c| c.as_f64()).unwrap_or(0.0);
|
||||||
|
|
||||||
@ -166,7 +173,10 @@ pub async fn list_vms(
|
|||||||
uptime: r.get("uptime").and_then(|u| u.as_u64()).unwrap_or(0),
|
uptime: r.get("uptime").and_then(|u| u.as_u64()).unwrap_or(0),
|
||||||
node,
|
node,
|
||||||
template: r.get("template").and_then(|t| t.as_bool()),
|
template: r.get("template").and_then(|t| t.as_bool()),
|
||||||
agent: r.get("agent").and_then(|a| a.as_str()).map(|s| s.to_string()),
|
agent: r
|
||||||
|
.get("agent")
|
||||||
|
.and_then(|a| a.as_str())
|
||||||
|
.map(|s| s.to_string()),
|
||||||
mem: r.get("mem").and_then(|m| m.as_u64()),
|
mem: r.get("mem").and_then(|m| m.as_u64()),
|
||||||
max_mem: r.get("maxmem").and_then(|m| m.as_u64()),
|
max_mem: r.get("maxmem").and_then(|m| m.as_u64()),
|
||||||
max_disk: r.get("maxdisk").and_then(|d| d.as_u64()),
|
max_disk: r.get("maxdisk").and_then(|d| d.as_u64()),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user