mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 06:06:38 +01:00
refactor: extract code from the container package
This commit is contained in:
parent
4130b110c6
commit
d1abce889a
15 changed files with 253 additions and 185 deletions
|
|
@ -3,6 +3,8 @@ package actions
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/containrrr/watchtower/pkg/filters"
|
||||
"github.com/containrrr/watchtower/pkg/sorter"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -19,7 +21,7 @@ import (
|
|||
// will stop and remove all but the most recently started container.
|
||||
func CheckForMultipleWatchtowerInstances(client container.Client, cleanup bool) error {
|
||||
awaitDockerClient()
|
||||
containers, err := client.ListContainers(container.WatchtowerContainersFilter)
|
||||
containers, err := client.ListContainers(filters.WatchtowerContainersFilter)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
@ -39,7 +41,7 @@ func cleanupExcessWatchtowers(containers []container.Container, client container
|
|||
var cleanupErrors int
|
||||
var stopErrors int
|
||||
|
||||
sort.Sort(container.ByCreated(containers))
|
||||
sort.Sort(sorter.ByCreated(containers))
|
||||
allContainersExceptLast := containers[0 : len(containers)-1]
|
||||
|
||||
for _, c := range allContainersExceptLast {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue