chore: Cargo fmt

This commit is contained in:
Jean-Gabriel Gill-Couture 2025-04-18 23:36:39 -04:00
parent 15785dd219
commit 2229e9d7af
7 changed files with 24 additions and 15 deletions

View File

@ -14,10 +14,10 @@ use super::DnsServer;
use super::Firewall; use super::Firewall;
use super::HttpServer; use super::HttpServer;
use super::IpAddress; use super::IpAddress;
use super::K8sclient;
use super::LoadBalancer; use super::LoadBalancer;
use super::LoadBalancerService; use super::LoadBalancerService;
use super::LogicalHost; use super::LogicalHost;
use super::K8sclient;
use super::Router; use super::Router;
use super::TftpServer; use super::TftpServer;
@ -48,7 +48,9 @@ impl Topology for HAClusterTopology {
todo!() todo!()
} }
async fn ensure_ready(&self) -> Result<Outcome, InterpretError> { async fn ensure_ready(&self) -> Result<Outcome, InterpretError> {
todo!("ensure_ready, not entirely sure what it should do here, probably something like verify that the hosts are reachable and all services are up and ready.") todo!(
"ensure_ready, not entirely sure what it should do here, probably something like verify that the hosts are reachable and all services are up and ready."
)
} }
} }

View File

@ -5,7 +5,11 @@ use log::{info, warn};
use tokio::sync::OnceCell; use tokio::sync::OnceCell;
use crate::{ use crate::{
interpret::{InterpretError, Outcome}, inventory::Inventory, maestro::Maestro, modules::k3d::K3DInstallationScore, topology::LocalhostTopology interpret::{InterpretError, Outcome},
inventory::Inventory,
maestro::Maestro,
modules::k3d::K3DInstallationScore,
topology::LocalhostTopology,
}; };
use super::{Topology, k8s::K8sClient}; use super::{Topology, k8s::K8sClient};

View File

@ -15,6 +15,8 @@ impl Topology for LocalhostTopology {
} }
async fn ensure_ready(&self) -> Result<Outcome, InterpretError> { async fn ensure_ready(&self) -> Result<Outcome, InterpretError> {
Ok(Outcome::success("Localhost is Chuck Norris, always ready.".to_string())) Ok(Outcome::success(
"Localhost is Chuck Norris, always ready.".to_string(),
))
} }
} }

View File

@ -3,10 +3,10 @@ mod host_binding;
mod http; mod http;
mod k8s_anywhere; mod k8s_anywhere;
mod localhost; mod localhost;
pub use localhost::*;
pub use k8s_anywhere::*; pub use k8s_anywhere::*;
mod load_balancer; pub use localhost::*;
pub mod k8s; pub mod k8s;
mod load_balancer;
mod router; mod router;
mod tftp; mod tftp;
use async_trait::async_trait; use async_trait::async_trait;

View File

@ -1,3 +1,2 @@
mod install; mod install;
pub use install::*; pub use install::*;

View File

@ -2,10 +2,10 @@ pub mod dhcp;
pub mod dns; pub mod dns;
pub mod dummy; pub mod dummy;
pub mod http; pub mod http;
pub mod k3d;
pub mod k8s; pub mod k8s;
pub mod lamp; pub mod lamp;
pub mod load_balancer; pub mod load_balancer;
pub mod okd; pub mod okd;
pub mod opnsense; pub mod opnsense;
pub mod tftp; pub mod tftp;
pub mod k3d;

View File

@ -142,20 +142,20 @@ mod tests {
TEST_SERVER.get_or_init(|| { TEST_SERVER.get_or_init(|| {
let listener = TcpListener::bind(format!("127.0.0.1:{}", TEST_SERVER_PORT)).unwrap(); let listener = TcpListener::bind(format!("127.0.0.1:{}", TEST_SERVER_PORT)).unwrap();
thread::spawn(move || { thread::spawn(move || {
for stream in listener.incoming() { for stream in listener.incoming() {
thread::spawn(move || { thread::spawn(move || {
let mut stream = stream.expect("Stream opened correctly"); let mut stream = stream.expect("Stream opened correctly");
let mut buffer = [0; 1024]; let mut buffer = [0; 1024];
let _ = stream.read(&mut buffer); let _ = stream.read(&mut buffer);
let response = format!( let response = format!(
"HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nContent-Length: {}\r\n\r\n{}", "HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nContent-Length: {}\r\n\r\n{}",
TEST_CONTENT.len(), TEST_CONTENT.len(),
TEST_CONTENT TEST_CONTENT
); );
stream.write_all(response.as_bytes()).expect("Can write to stream"); stream.write_all(response.as_bytes()).expect("Can write to stream");
stream.flush().expect("Can flush stream"); stream.flush().expect("Can flush stream");
}); });
@ -203,7 +203,7 @@ mod tests {
let folder = PathBuf::from(&test.download_path); let folder = PathBuf::from(&test.download_path);
let result = asset.download_to_path(folder).await.unwrap(); let result = asset.download_to_path(folder).await.unwrap();
let downloaded_content = std::fs::read_to_string(result).unwrap(); let downloaded_content = std::fs::read_to_string(result).unwrap();
assert_eq!(downloaded_content, TEST_CONTENT); assert_eq!(downloaded_content, TEST_CONTENT);
} }
@ -212,7 +212,7 @@ mod tests {
async fn test_download_to_path_already_exists() { async fn test_download_to_path_already_exists() {
let test = setup_test(); let test = setup_test();
let folder = PathBuf::from(&test.download_path); let folder = PathBuf::from(&test.download_path);
let asset = DownloadableAsset { let asset = DownloadableAsset {
url: Url::parse(&format!("http://{}/test.txt", test.domain)).unwrap(), url: Url::parse(&format!("http://{}/test.txt", test.domain)).unwrap(),
file_name: "test.txt".to_string(), file_name: "test.txt".to_string(),
@ -230,14 +230,16 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn test_download_to_path_failure() { async fn test_download_to_path_failure() {
let test = setup_test(); let test = setup_test();
let asset = DownloadableAsset { let asset = DownloadableAsset {
url: Url::parse("http://127.0.0.1:9999/test.txt").unwrap(), url: Url::parse("http://127.0.0.1:9999/test.txt").unwrap(),
file_name: "test.txt".to_string(), file_name: "test.txt".to_string(),
checksum: "some_checksum".to_string(), checksum: "some_checksum".to_string(),
}; };
let result = asset.download_to_path(PathBuf::from(&test.download_path)).await; let result = asset
.download_to_path(PathBuf::from(&test.download_path))
.await;
assert!(result.is_err()); assert!(result.is_err());
} }
} }