mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
proper set implementation
This commit is contained in:
parent
a2a62fb46e
commit
fa1b8d5d0c
1 changed files with 3 additions and 6 deletions
|
@ -3,7 +3,6 @@ package actions
|
|||
import (
|
||||
"github.com/containrrr/watchtower/internal/util"
|
||||
"github.com/containrrr/watchtower/pkg/container"
|
||||
"github.com/deckarep/golang-set"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -74,18 +73,16 @@ func stopStaleContainer(container container.Container, client container.Client,
|
|||
}
|
||||
|
||||
func restartContainersInSortedOrder(containers []container.Container, client container.Client, params UpdateParams) {
|
||||
toDelete := mapset.NewSet()
|
||||
toDelete := make(map[container.Container]bool)
|
||||
for _, container := range containers {
|
||||
if !container.Stale {
|
||||
continue
|
||||
}
|
||||
restartStaleContainer(container, client, params)
|
||||
toDelete.Add(container)
|
||||
toDelete[container] = true
|
||||
}
|
||||
if params.Cleanup {
|
||||
iterator := toDelete.Iterator()
|
||||
for c := range iterator.C {
|
||||
cont := c.(container.Container)
|
||||
for cont := range toDelete {
|
||||
if err := client.RemoveImage(cont); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue