()
| 117 | } |
| 118 | |
| 119 | pub(crate) async fn list_containers() -> Result<ListContainersResponse> { |
| 120 | let docker = Docker::connect_with_defaults().context("Failed to connect to Docker")?; |
| 121 | let containers = docker |
| 122 | .list_containers::<&str>(Some(ListContainersOptions { |
| 123 | all: true, |
| 124 | ..Default::default() |
| 125 | })) |
| 126 | .await |
| 127 | .context("Failed to list containers")?; |
| 128 | Ok(ListContainersResponse { |
| 129 | containers: containers |
| 130 | .into_iter() |
| 131 | .map(|c| Container { |
| 132 | id: c.id.unwrap_or_default(), |
| 133 | names: c.names.unwrap_or_default(), |
| 134 | image: c.image.unwrap_or_default(), |
| 135 | image_id: c.image_id.unwrap_or_default(), |
| 136 | created: c.created.unwrap_or_default(), |
| 137 | state: c.state.unwrap_or_default(), |
| 138 | status: c.status.unwrap_or_default(), |
| 139 | }) |
| 140 | .collect(), |
| 141 | }) |
| 142 | } |
| 143 | |
| 144 | fn get_interfaces() -> Vec<Interface> { |
| 145 | sysinfo::Networks::new_with_refreshed_list() |
no test coverage detected