39 lines
1.2 KiB
Rust
Raw Normal View History

2025-12-10 10:11:45 +01:00
use testing_framework_core::topology::generation::GeneratedTopology;
use tracing::{debug, info};
use crate::{
errors::ComposeRunnerError,
2025-12-10 15:26:34 +01:00
infrastructure::{
environment::StackEnvironment,
ports::{HostPortMapping, discover_host_ports},
},
2025-12-10 10:11:45 +01:00
};
pub struct PortManager;
impl PortManager {
pub async fn prepare(
environment: &mut StackEnvironment,
descriptors: &GeneratedTopology,
) -> Result<HostPortMapping, ComposeRunnerError> {
debug!("resolving host ports for compose services");
match discover_host_ports(environment, descriptors).await {
Ok(mapping) => {
info!(
validator_ports = ?mapping.validator_api_ports(),
executor_ports = ?mapping.executor_api_ports(),
prometheus_port = environment.prometheus_port(),
"resolved container host ports"
);
Ok(mapping)
}
Err(err) => {
environment
.fail("failed to determine container host ports")
.await;
Err(err)
}
}
}
}