mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00
add tests for check action, resolve wt cleanup bug (#284)
add unit tests for the check action to allow for some refactoring and bug fixing without having to worry about breaking stuff. resolve watchtower cleanup bug by adding an initial 1 second sleep in the check action. without the sleep, the docker client returns an empty array, which is why we were left with two watchtowers.
This commit is contained in:
parent
90bd4a1e3e
commit
46ffa16ee2
4 changed files with 239 additions and 20 deletions
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
dockercontainer "github.com/docker/docker/api/types/container"
|
||||
)
|
||||
|
@ -102,9 +102,7 @@ func (c Container) Links() []string {
|
|||
// identified by the presence of the "com.centurylinklabs.watchtower" label in
|
||||
// the container metadata.
|
||||
func (c Container) IsWatchtower() bool {
|
||||
log.Debugf("Checking if %s is a watchtower instance.", c.Name())
|
||||
wasWatchtower := ContainsWatchtowerLabel(c.containerInfo.Config.Labels)
|
||||
return wasWatchtower
|
||||
return ContainsWatchtowerLabel(c.containerInfo.Config.Labels)
|
||||
}
|
||||
|
||||
// StopSignal returns the custom stop signal (if any) that is encoded in the
|
||||
|
@ -189,4 +187,4 @@ func (c Container) hostConfig() *dockercontainer.HostConfig {
|
|||
func ContainsWatchtowerLabel(labels map[string]string) bool {
|
||||
val, ok := labels[watchtowerLabel]
|
||||
return ok && val == "true"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue