(include_inactive: bool)
| 43 | |
| 44 | #[command] |
| 45 | pub async fn list_stacks(include_inactive: bool) -> Result<Vec<String>, String> { |
| 46 | let docker = get_docker().await?; |
| 47 | let containers = get_containers(&docker).await?; |
| 48 | |
| 49 | let mut stacks: Vec<String> = if include_inactive { |
| 50 | extract_projects(&containers).into_iter().collect() |
| 51 | } else { |
| 52 | containers |
| 53 | .iter() |
| 54 | .filter(|container| container.state == Some(String::from("running"))) |
| 55 | .filter_map(|container| { |
| 56 | container |
| 57 | .labels |
| 58 | .as_ref() |
| 59 | .and_then(|labels| labels.get("com.docker.compose.project").cloned()) |
| 60 | }) |
| 61 | .collect::<HashSet<String>>() |
| 62 | .into_iter() |
| 63 | .collect() |
| 64 | }; |
| 65 | |
| 66 | stacks.sort(); |
| 67 | Ok(stacks) |
| 68 | } |
| 69 | |
| 70 | #[command] |
| 71 | pub async fn list_containers() -> Result<Vec<ContainerSummary>, String> { |
no test coverage detected