mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
Refactoring & renaming
This commit is contained in:
parent
3dd06cffb1
commit
00f2875abf
15 changed files with 254 additions and 233 deletions
29
actions/check.go
Normal file
29
actions/check.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package actions
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/CenturyLinkLabs/watchtower/container"
|
||||
)
|
||||
|
||||
func watchtowerContainersFilter(c container.Container) bool { return c.IsWatchtower() }
|
||||
|
||||
func CheckPrereqs() error {
|
||||
client := container.NewClient()
|
||||
|
||||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue