2025-12-10 08:39:32 +01:00
|
|
|
use std::env;
|
|
|
|
|
|
2025-12-11 10:08:49 +01:00
|
|
|
use tracing::debug;
|
|
|
|
|
|
2025-12-10 08:39:32 +01:00
|
|
|
/// Select the compose image and optional platform, honoring
|
|
|
|
|
/// NOMOS_TESTNET_IMAGE.
|
|
|
|
|
pub fn resolve_image() -> (String, Option<String>) {
|
2025-12-10 15:15:34 +01:00
|
|
|
let image = env::var("NOMOS_TESTNET_IMAGE")
|
|
|
|
|
.unwrap_or_else(|_| String::from("logos-blockchain-testing:local"));
|
2025-12-10 08:39:32 +01:00
|
|
|
let platform = (image == "ghcr.io/logos-co/nomos:testnet").then(|| "linux/amd64".to_owned());
|
2025-12-11 10:08:49 +01:00
|
|
|
debug!(image, platform = ?platform, "resolved compose image");
|
2025-12-10 08:39:32 +01:00
|
|
|
(image, platform)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Optional extra hosts entry for host networking.
|
|
|
|
|
pub fn host_gateway_entry() -> Option<String> {
|
|
|
|
|
if let Ok(value) = env::var("COMPOSE_RUNNER_HOST_GATEWAY") {
|
|
|
|
|
if value.eq_ignore_ascii_case("disable") || value.is_empty() {
|
|
|
|
|
return None;
|
|
|
|
|
}
|
|
|
|
|
return Some(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if let Ok(gateway) = env::var("DOCKER_HOST_GATEWAY") {
|
|
|
|
|
if !gateway.is_empty() {
|
|
|
|
|
return Some(format!("host.docker.internal:{gateway}"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Some("host.docker.internal:host-gateway".into())
|
|
|
|
|
}
|