| 272 | |
| 273 | #[async_trait] |
| 274 | pub trait DockerClient: Send + Sync { |
| 275 | async fn create_container( |
| 276 | &self, |
| 277 | options: Option<CreateContainerOptions>, |
| 278 | config: ContainerCreateBody, |
| 279 | ) -> Result<String, String>; |
| 280 | |
| 281 | async fn start_container(&self, id: &str) -> Result<(), String>; |
| 282 | |
| 283 | async fn wait_container(&self, id: &str) -> Result<i64, String>; |
| 284 | |
| 285 | async fn kill_container(&self, id: &str) -> Result<(), String>; |
| 286 | |
| 287 | /// Get container logs as a single string |
| 288 | /// |
| 289 | /// Used by test utilities and debugging tools |
| 290 | #[allow(dead_code)] // Used by test implementations |
| 291 | async fn logs(&self, id: &str, options: Option<LogsOptions>) -> Result<String, String>; |
| 292 | |
| 293 | async fn logs_stream( |
| 294 | &self, |
| 295 | id: &str, |
| 296 | options: Option<LogsOptions>, |
| 297 | ) -> Result<Box<dyn futures_util::Stream<Item = Result<String, String>> + Send + Unpin>, String>; |
| 298 | |
| 299 | async fn remove_container( |
| 300 | &self, |
| 301 | id: &str, |
| 302 | options: Option<RemoveContainerOptions>, |
| 303 | ) -> Result<(), String>; |
| 304 | |
| 305 | async fn create_network(&self, name: &str) -> Result<String, String>; |
| 306 | |
| 307 | async fn network_exists(&self, name: &str) -> Result<bool, String>; |
| 308 | |
| 309 | /// Create an internal network (no external route) |
| 310 | /// |
| 311 | /// Internal networks cannot reach the internet directly, making them ideal |
| 312 | /// for isolating agent containers that must route through the proxy. |
| 313 | /// |
| 314 | /// # Arguments |
| 315 | /// * `name` - The network name (e.g., "tsk-agent-abc123") |
| 316 | /// |
| 317 | /// # Returns |
| 318 | /// The network ID on success |
| 319 | async fn create_internal_network(&self, name: &str) -> Result<String, String>; |
| 320 | |
| 321 | /// Connect a running container to an additional network |
| 322 | /// |
| 323 | /// Used to connect the proxy container to each agent's isolated network. |
| 324 | /// |
| 325 | /// # Arguments |
| 326 | /// * `container` - Container ID or name |
| 327 | /// * `network` - Network name to connect to |
| 328 | async fn connect_container_to_network( |
| 329 | &self, |
| 330 | container: &str, |
| 331 | network: &str, |
nothing calls this directly
no outgoing calls
no test coverage detected