fix: Fix opnsense test, Host.tll now optional and run cargo fmt

This commit is contained in:
Jean-Gabriel Gill-Couture 2025-05-06 12:00:56 -04:00
parent 1fb7132c64
commit e62ef001ed
7 changed files with 35 additions and 22 deletions

View File

@ -8,7 +8,7 @@ use harmony::{
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
// This here is the whole configuration to // This here is the whole configuration to
// - setup a local K3D cluster // - setup a local K3D cluster
// - Build a docker image with the PHP project builtin and production grade settings // - Build a docker image with the PHP project builtin and production grade settings
// - Deploy a mariadb database using a production grade helm chart // - Deploy a mariadb database using a production grade helm chart

View File

@ -6,8 +6,8 @@ lazy_static! {
.unwrap() .unwrap()
.data_dir() .data_dir()
.join("harmony"); .join("harmony");
pub static ref REGISTRY_URL: String = std::env::var("HARMONY_REGISTRY_URL") pub static ref REGISTRY_URL: String =
.unwrap_or_else(|_| "hub.nationtech.io".to_string()); std::env::var("HARMONY_REGISTRY_URL").unwrap_or_else(|_| "hub.nationtech.io".to_string());
pub static ref REGISTRY_PROJECT: String = pub static ref REGISTRY_PROJECT: String =
std::env::var("HARMONY_REGISTRY_PROJECT").unwrap_or_else(|_| "harmony".to_string()); std::env::var("HARMONY_REGISTRY_PROJECT").unwrap_or_else(|_| "harmony".to_string());
} }

View File

@ -370,10 +370,13 @@ mod tests {
let result = get_servers_for_backend(&backend, &haproxy); let result = get_servers_for_backend(&backend, &haproxy);
// Check the result // Check the result
assert_eq!(result, vec![BackendServer { assert_eq!(
address: "192.168.1.1".to_string(), result,
port: 80, vec![BackendServer {
},]); address: "192.168.1.1".to_string(),
port: 80,
},]
);
} }
#[test] #[test]
fn test_get_servers_for_backend_no_linked_servers() { fn test_get_servers_for_backend_no_linked_servers() {
@ -430,15 +433,18 @@ mod tests {
// Call the function // Call the function
let result = get_servers_for_backend(&backend, &haproxy); let result = get_servers_for_backend(&backend, &haproxy);
// Check the result // Check the result
assert_eq!(result, vec![ assert_eq!(
BackendServer { result,
address: "some-hostname.test.mcd".to_string(), vec![
port: 80, BackendServer {
}, address: "some-hostname.test.mcd".to_string(),
BackendServer { port: 80,
address: "192.168.1.2".to_string(), },
port: 8080, BackendServer {
}, address: "192.168.1.2".to_string(),
]); port: 8080,
},
]
);
} }
} }

View File

@ -166,7 +166,11 @@ impl DhcpInterpret {
InterpretStatus::SUCCESS, InterpretStatus::SUCCESS,
format!( format!(
"Dhcp Interpret Set next boot to [{:?}], boot_filename to [{:?}], filename to [{:?}], filename64 to [{:?}], filenameipxe to [:{:?}]", "Dhcp Interpret Set next boot to [{:?}], boot_filename to [{:?}], filename to [{:?}], filename64 to [{:?}], filenameipxe to [:{:?}]",
self.score.boot_filename, self.score.boot_filename, self.score.filename, self.score.filename64, self.score.filenameipxe self.score.boot_filename,
self.score.boot_filename,
self.score.filename,
self.score.filename64,
self.score.filenameipxe
), ),
)) ))
} }

View File

@ -3,6 +3,7 @@ pub mod dns;
pub mod dummy; pub mod dummy;
pub mod helm; pub mod helm;
pub mod http; pub mod http;
pub mod ipxe;
pub mod k3d; pub mod k3d;
pub mod k8s; pub mod k8s;
pub mod lamp; pub mod lamp;
@ -10,4 +11,3 @@ pub mod load_balancer;
pub mod okd; pub mod okd;
pub mod opnsense; pub mod opnsense;
pub mod tftp; pub mod tftp;
pub mod ipxe;

View File

@ -46,7 +46,10 @@ impl OKDBootstrapDhcpScore {
None, // To allow UEFI boot we cannot provide a legacy file None, // To allow UEFI boot we cannot provide a legacy file
Some("undionly.kpxe".to_string()), Some("undionly.kpxe".to_string()),
Some("ipxe.efi".to_string()), Some("ipxe.efi".to_string()),
Some(format!("http://{}:8080/boot.ipxe", topology.router.get_gateway())), Some(format!(
"http://{}:8080/boot.ipxe",
topology.router.get_gateway()
)),
), ),
} }
} }

View File

@ -1223,7 +1223,7 @@ pub struct Host {
pub rr: String, pub rr: String,
pub mxprio: MaybeString, pub mxprio: MaybeString,
pub mx: MaybeString, pub mx: MaybeString,
pub ttl: MaybeString, pub ttl: Option<MaybeString>,
pub server: String, pub server: String,
pub description: Option<String>, pub description: Option<String>,
} }
@ -1238,7 +1238,7 @@ impl Host {
rr, rr,
server, server,
mxprio: MaybeString::default(), mxprio: MaybeString::default(),
ttl: MaybeString::default(), ttl: Some(MaybeString::default()),
mx: MaybeString::default(), mx: MaybeString::default(),
description: None, description: None,
} }