mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 14:10:12 +01:00
fix: correctly handle non-stale restarts (#1220)
This commit is contained in:
parent
d12ce7ce79
commit
e9c83af533
4 changed files with 166 additions and 93 deletions
|
|
@ -3,9 +3,10 @@ package mocks
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/containrrr/watchtower/pkg/container"
|
||||
"time"
|
||||
|
||||
"github.com/containrrr/watchtower/pkg/container"
|
||||
|
||||
t "github.com/containrrr/watchtower/pkg/types"
|
||||
)
|
||||
|
||||
|
|
@ -21,6 +22,7 @@ type TestData struct {
|
|||
TriedToRemoveImageCount int
|
||||
NameOfContainerToKeep string
|
||||
Containers []container.Container
|
||||
Staleness map[string]bool
|
||||
}
|
||||
|
||||
// TriedToRemoveImage is a test helper function to check whether RemoveImageByID has been called
|
||||
|
|
@ -85,9 +87,13 @@ func (client MockClient) ExecuteCommand(_ t.ContainerID, command string, _ int)
|
|||
}
|
||||
}
|
||||
|
||||
// IsContainerStale is always true for the mock client
|
||||
func (client MockClient) IsContainerStale(_ container.Container) (bool, t.ImageID, error) {
|
||||
return true, "", nil
|
||||
// IsContainerStale is true if not explicitly stated in TestData for the mock client
|
||||
func (client MockClient) IsContainerStale(cont container.Container) (bool, t.ImageID, error) {
|
||||
stale, found := client.TestData.Staleness[cont.Name()]
|
||||
if !found {
|
||||
stale = true
|
||||
}
|
||||
return stale, "", nil
|
||||
}
|
||||
|
||||
// WarnOnHeadPullFailed is always true for the mock client
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue