mirror of
https://github.com/containrrr/watchtower.git
synced 2026-02-25 08:24:07 +01:00
Merge branch 'main' into fix-container-downtime
This commit is contained in:
commit
24276cfbc6
85 changed files with 3816 additions and 1098 deletions
|
|
@ -86,3 +86,8 @@ func (client MockClient) ExecuteCommand(containerID string, command string, time
|
|||
func (client MockClient) IsContainerStale(c container.Container) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// WarnOnHeadPullFailed is always true for the mock client
|
||||
func (client MockClient) WarnOnHeadPullFailed(c container.Container) bool {
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/containrrr/watchtower/pkg/container"
|
||||
"github.com/docker/docker/api/types"
|
||||
container2 "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -15,9 +16,14 @@ func CreateMockContainer(id string, name string, image string, created time.Time
|
|||
Image: image,
|
||||
Name: name,
|
||||
Created: created.String(),
|
||||
HostConfig: &container2.HostConfig{
|
||||
PortBindings: map[nat.Port][]nat.PortBinding{},
|
||||
},
|
||||
},
|
||||
Config: &container2.Config{
|
||||
Labels: make(map[string]string),
|
||||
Image: image,
|
||||
Labels: make(map[string]string),
|
||||
ExposedPorts: map[nat.Port]struct{}{},
|
||||
},
|
||||
}
|
||||
dependencyString := ""
|
||||
|
|
@ -33,10 +39,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{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue