mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 23:26:45 +08:00
move container state filtering into containermap
This commit is contained in:
@@ -104,9 +104,15 @@ func (cm *ContainerMap) All() []*Container {
|
|||||||
re := regexp.MustCompile(fmt.Sprintf(".*%s", filter))
|
re := regexp.MustCompile(fmt.Sprintf(".*%s", filter))
|
||||||
|
|
||||||
for _, c := range cm.containers {
|
for _, c := range cm.containers {
|
||||||
if re.FindAllString(c.name, 1) != nil {
|
// Apply name filter
|
||||||
containers = append(containers, c)
|
if re.FindAllString(c.name, 1) == nil {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
// Apply state filter
|
||||||
|
if !config.GetSwitchVal("allContainers") && c.state != "running" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
containers = append(containers, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(containers)
|
sort.Sort(containers)
|
||||||
|
|||||||
3
grid.go
3
grid.go
@@ -82,9 +82,6 @@ func (g *Grid) redrawRows() {
|
|||||||
}
|
}
|
||||||
ui.Body.AddRows(fieldHeader())
|
ui.Body.AddRows(fieldHeader())
|
||||||
for _, c := range g.containers {
|
for _, c := range g.containers {
|
||||||
if !config.GetSwitchVal("allContainers") && c.state != "running" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ui.Body.AddRows(c.widgets.Row())
|
ui.Body.AddRows(c.widgets.Row())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user