From 8a9e9190e6f7af175c111013608729cbf43fc693 Mon Sep 17 00:00:00 2001 From: git-echo Date: Fri, 29 May 2026 11:11:07 -0500 Subject: [PATCH] style: fix cargo fmt formatting issues --- src/config/loader.rs | 57 ++++++++++++++++++++------------------------ src/config/mod.rs | 2 +- src/main.rs | 13 ++++++---- 3 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/config/loader.rs b/src/config/loader.rs index ad2a49e..0ef4734 100644 --- a/src/config/loader.rs +++ b/src/config/loader.rs @@ -175,18 +175,11 @@ pub enum CertStatus { /// All certificates are valid and not expiring soon. Valid, /// Certificates are valid but expiring within the threshold. - ExpiringSoon { - not_after: OffsetDateTime, - }, + ExpiringSoon { not_after: OffsetDateTime }, /// One or more certificate files are missing. - Missing { - paths: Vec, - }, + Missing { paths: Vec }, /// A certificate file exists but cannot be parsed as valid PEM. - Corrupt { - path: PathBuf, - error: String, - }, + Corrupt { path: PathBuf, error: String }, /// A certificate has expired (not_after is in the past). Expired { path: PathBuf, @@ -312,9 +305,7 @@ pub fn validate_certs(config: &AppConfig) -> Result { let threshold = time::Duration::days(i64::from(threshold_days)); // Check CA cert expiry - let ca_der = ca_certs - .first() - .expect("ca_certs verified non-empty above"); + let ca_der = ca_certs.first().expect("ca_certs verified non-empty above"); match x509_parser::parse_x509_certificate(ca_der.as_ref()) { Ok((_, ca_cert)) => { let ca_not_after = ca_cert.validity().not_after.to_datetime(); @@ -337,24 +328,25 @@ pub fn validate_certs(config: &AppConfig) -> Result { let server_der = server_certs .first() .expect("server_certs verified non-empty above"); - let server_not_after: OffsetDateTime = match x509_parser::parse_x509_certificate(server_der.as_ref()) { - Ok((_, cert)) => { - let not_after = cert.validity().not_after.to_datetime(); - if not_after < now { - return Ok(CertStatus::Expired { - path: cert_path.clone(), - not_after, - }); + let server_not_after: OffsetDateTime = + match x509_parser::parse_x509_certificate(server_der.as_ref()) { + Ok((_, cert)) => { + let not_after = cert.validity().not_after.to_datetime(); + if not_after < now { + return Ok(CertStatus::Expired { + path: cert_path.clone(), + not_after, + }); + } + not_after } - not_after - } - Err(e) => { - return Ok(CertStatus::Corrupt { - path: cert_path, - error: format!("Failed to parse server certificate DER: {}", e), - }) - } - }; + Err(e) => { + return Ok(CertStatus::Corrupt { + path: cert_path, + error: format!("Failed to parse server certificate DER: {}", e), + }) + } + }; // Check if expiring soon let expires_soon = server_not_after < now + threshold; @@ -613,7 +605,10 @@ cert_renewal_threshold_days: 14 assert!(config.effective_manager_url().is_none()); config.manager_url = Some("https://manager.example.com".to_string()); - assert_eq!(config.effective_manager_url(), Some("https://manager.example.com")); + assert_eq!( + config.effective_manager_url(), + Some("https://manager.example.com") + ); config.manager_url = Some("".to_string()); assert!(config.effective_manager_url().is_none()); diff --git a/src/config/mod.rs b/src/config/mod.rs index 78c2289..d443176 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -6,6 +6,6 @@ //! - Auto-reload on file change via notify watcher pub mod loader; -pub use loader::{AppConfig, CertStatus, EnrollmentConfig, validate_certs}; +pub use loader::{validate_certs, AppConfig, CertStatus, EnrollmentConfig}; pub mod validator; pub mod watcher; diff --git a/src/main.rs b/src/main.rs index e5ab9bb..6db3b7f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -150,7 +150,9 @@ async fn main() -> Result<()> { match enroll::run_enrollment(&manager_url, &mut config, &args.config).await { Ok(()) => { - info!("Certificate renewal complete. Start service: systemctl start linux-patch-api"); + info!( + "Certificate renewal complete. Start service: systemctl start linux-patch-api" + ); std::process::exit(ExitCode::Clean as i32); } Err(e) => { @@ -208,7 +210,8 @@ async fn main() -> Result<()> { status, manager_url ); - match enroll::run_enrollment(&manager_url, &mut config, &args.config).await { + match enroll::run_enrollment(&manager_url, &mut config, &args.config).await + { Ok(()) => { info!("Auto-enrollment complete - continuing to server startup"); // Re-load config to pick up any changes from enrollment @@ -374,9 +377,9 @@ async fn main() -> Result<()> { .set_reuse_address(true) .map_err(|e| anyhow::anyhow!("Failed to set SO_REUSEADDR: {}", e))?; - let bind_addr: std::net::SocketAddr = bind_address - .parse() - .map_err(|e| anyhow::anyhow!("Invalid bind address '{}': {}", bind_address, e))?; + let bind_addr: std::net::SocketAddr = bind_address.parse().map_err(|e| { + anyhow::anyhow!("Invalid bind address '{}': {}", bind_address, e) + })?; socket .bind(&socket2::SockAddr::from(bind_addr))