proper set implementation

pull/393/head
Lukas Elsner 5 years ago
parent a2a62fb46e
commit fa1b8d5d0c

@ -3,7 +3,6 @@ package actions
import ( import (
"github.com/containrrr/watchtower/internal/util" "github.com/containrrr/watchtower/internal/util"
"github.com/containrrr/watchtower/pkg/container" "github.com/containrrr/watchtower/pkg/container"
"github.com/deckarep/golang-set"
log "github.com/sirupsen/logrus" 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) { func restartContainersInSortedOrder(containers []container.Container, client container.Client, params UpdateParams) {
toDelete := mapset.NewSet() toDelete := make(map[container.Container]bool)
for _, container := range containers { for _, container := range containers {
if !container.Stale { if !container.Stale {
continue continue
} }
restartStaleContainer(container, client, params) restartStaleContainer(container, client, params)
toDelete.Add(container) toDelete[container] = true
} }
if params.Cleanup { if params.Cleanup {
iterator := toDelete.Iterator() for cont := range toDelete {
for c := range iterator.C {
cont := c.(container.Container)
if err := client.RemoveImage(cont); err != nil { if err := client.RemoveImage(cont); err != nil {
log.Error(err) log.Error(err)
} }

Loading…
Cancel
Save