You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
watchtower/actions/check.go

28 lines
559 B
Go

package actions
import (
"sort"
"github.com/CenturyLinkLabs/watchtower/container"
)
func watchtowerContainersFilter(c container.Container) bool { return c.IsWatchtower() }
func CheckPrereqs(client container.Client) error {
containers, err := client.ListContainers(watchtowerContainersFilter)
if err != nil {
return err
}
if len(containers) > 1 {
sort.Sort(container.ByCreated(containers))
// Iterate over all containers execept the last one
for _, c := range containers[0 : len(containers)-1] {
client.Stop(c, 60)
}
}
return nil
}