mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00
add http head based digest comparison to avoid dockerhub rate limits
This commit is contained in:
parent
c8bd484b9e
commit
cb62b16369
23 changed files with 1476 additions and 57 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/containrrr/watchtower/pkg/filters"
|
||||
"github.com/containrrr/watchtower/pkg/sorter"
|
||||
|
||||
"github.com/opencontainers/runc/Godeps/_workspace/src/github.com/Sirupsen/logrus"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ func CreateMockContainer(id string, name string, image string, created time.Time
|
|||
Created: created.String(),
|
||||
},
|
||||
Config: &container2.Config{
|
||||
Image: image,
|
||||
Labels: make(map[string]string),
|
||||
},
|
||||
}
|
||||
|
@ -24,10 +25,40 @@ func CreateMockContainer(id string, name string, image string, created time.Time
|
|||
&content,
|
||||
&types.ImageInspect{
|
||||
ID: image,
|
||||
RepoDigests: []string{
|
||||
image,
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// CreateMockContainerWithImageInfo should only be used for testing
|
||||
func CreateMockContainerWithImageInfo(id string, name string, image string, created time.Time, imageInfo types.ImageInspect) container.Container {
|
||||
content := types.ContainerJSON{
|
||||
ContainerJSONBase: &types.ContainerJSONBase{
|
||||
ID: id,
|
||||
Image: image,
|
||||
Name: name,
|
||||
Created: created.String(),
|
||||
},
|
||||
Config: &container2.Config{
|
||||
Image: image,
|
||||
Labels: make(map[string]string),
|
||||
},
|
||||
}
|
||||
return *container.NewContainer(
|
||||
&content,
|
||||
&imageInfo,
|
||||
)
|
||||
}
|
||||
|
||||
// CreateMockContainerWithDigest should only be used for testing
|
||||
func CreateMockContainerWithDigest(id string, name string, image string, created time.Time, digest string) container.Container {
|
||||
c := CreateMockContainer(id, name, image, created)
|
||||
c.ImageInfo().RepoDigests = []string{digest}
|
||||
return c
|
||||
}
|
||||
|
||||
// CreateMockContainerWithConfig creates a container substitute valid for testing
|
||||
func CreateMockContainerWithConfig(id string, name string, image string, created time.Time, config *container2.Config) container.Container {
|
||||
content := types.ContainerJSON{
|
||||
|
|
|
@ -300,10 +300,11 @@ Should only be used for testing.`)
|
|||
|
||||
// SetDefaults provides default values for environment variables
|
||||
func SetDefaults() {
|
||||
day := time.Hour * 24 / time.Second
|
||||
viper.AutomaticEnv()
|
||||
viper.SetDefault("DOCKER_HOST", "unix:///var/run/docker.sock")
|
||||
viper.SetDefault("DOCKER_API_VERSION", DockerAPIMinVersion)
|
||||
viper.SetDefault("WATCHTOWER_POLL_INTERVAL", 300)
|
||||
viper.SetDefault("WATCHTOWER_POLL_INTERVAL", day)
|
||||
viper.SetDefault("WATCHTOWER_TIMEOUT", time.Second*10)
|
||||
viper.SetDefault("WATCHTOWER_NOTIFICATIONS", []string{})
|
||||
viper.SetDefault("WATCHTOWER_NOTIFICATIONS_LEVEL", "info")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue