MCPcopy Index your code
hub / github.com/ddev/ddev / GetActiveProjects

Function GetActiveProjects

pkg/ddevapp/utils.go:30–64  ·  view source on GitHub ↗

GetActiveProjects returns an array of DDEV projects that are currently running in docker (excludes paused/stopped projects).

()

Source from the content-addressed store, hash-verified

28// GetActiveProjects returns an array of DDEV projects
29// that are currently running in docker (excludes paused/stopped projects).
30func GetActiveProjects() []*DdevApp {
31 apps := make([]*DdevApp, 0)
32 labels := map[string]string{
33 "com.ddev.platform": "ddev",
34 "com.docker.compose.service": "web",
35 "com.docker.compose.oneoff": "False",
36 }
37 containers, err := dockerutil.FindContainersByLabels(labels)
38
39 if err == nil {
40 for _, siteContainer := range containers {
41 // Skip containers that are not running (e.g., paused projects)
42 if siteContainer.State != "running" {
43 continue
44 }
45 approot, ok := siteContainer.Labels["com.ddev.approot"]
46 if !ok {
47 continue
48 }
49
50 app, err := NewApp(approot, true)
51
52 // Artificially populate sitename and apptype based on labels
53 // if NewApp() failed.
54 if err != nil {
55 app.Name = siteContainer.Labels["com.ddev.site-name"]
56 app.Type = siteContainer.Labels["com.ddev.app-type"]
57 app.AppRoot = siteContainer.Labels["com.ddev.approot"]
58 }
59 apps = append(apps, app)
60 }
61 }
62
63 return apps
64}
65
66// RenderAppRow will add an application row to an existing table for describe and list output.
67func RenderAppRow(t table.Writer, row map[string]any) {

Callers 13

TestGetAppsFunction · 0.92
TestGetAppsEmptyFunction · 0.92
TestListWithoutDirFunction · 0.92
TestTraefikStaticConfigFunction · 0.92
runPortDiagnoseFunction · 0.92
stop.goFile · 0.92
TestCmdStopFunction · 0.92
debug-test.goFile · 0.92
TestPoweroffOnNewVersionFunction · 0.92
StartDdevRouterFunction · 0.85

Calls 2

FindContainersByLabelsFunction · 0.92
NewAppFunction · 0.85

Tested by 7

TestGetAppsFunction · 0.74
TestGetAppsEmptyFunction · 0.74
TestListWithoutDirFunction · 0.74
TestTraefikStaticConfigFunction · 0.74
TestCmdStopFunction · 0.74
TestPoweroffOnNewVersionFunction · 0.74