MCPcopy Create free account
hub / github.com/codename-co/stack / list_stacks

Function list_stacks

packages/app/src-tauri/src/docker.rs:45–68  ·  view source on GitHub ↗
(include_inactive: bool)

Source from the content-addressed store, hash-verified

43
44#[command]
45pub 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]
71pub async fn list_containers() -> Result<Vec<ContainerSummary>, String> {

Callers 1

create_menuFunction · 0.85

Calls 3

get_dockerFunction · 0.85
get_containersFunction · 0.85
extract_projectsFunction · 0.85

Tested by

no test coverage detected