move container state filtering into containermap

This commit is contained in:
Bradley Cicenas 2017-02-16 04:35:25 +00:00
parent a1f860a020
commit 5419337c17
2 changed files with 8 additions and 5 deletions

View File

@ -104,9 +104,15 @@ func (cm *ContainerMap) All() []*Container {
re := regexp.MustCompile(fmt.Sprintf(".*%s", filter))
for _, c := range cm.containers {
if re.FindAllString(c.name, 1) != nil {
containers = append(containers, c)
// Apply name filter
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)

View File

@ -82,9 +82,6 @@ func (g *Grid) redrawRows() {
}
ui.Body.AddRows(fieldHeader())
for _, c := range g.containers {
if !config.GetSwitchVal("allContainers") && c.state != "running" {
continue
}
ui.Body.AddRows(c.widgets.Row())
}