mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 14:10:12 +01:00
Pre-update lifecycle hook (#793)
* Make watchtower skip update if pre-update lifecycle hook exits with a non-zero exit code #649 * Make watchtower skip update if pre-update lifecycle hook exits with a non-zero exit code #649 * Make watchtower skip update if pre-update lifecycle hook exits with a non-zero exit code #649 * Make watchtower skip update if pre-update lifecycle hook exits with a non-zero exit code #649 * Make watchtower skip update if pre-update lifecycle hook exits with a non-zero exit code #649 * Make watchtower skip update if pre-update lifecycle hook exits with a non-zero exit code #649 * Make watchtower skip update if pre-update lifecycle hook exits with a non-zero exit code #649 * Prevent starting new container if old one is not stopped because of lifecycle hook. * Add null check for c.containerInfo.State in IsRunning * Fixed that the container would not start * Added test for preupdate * EX_TEMPFAIL -> ExTempFail * Added missing fuction ouput names * Skip preupdate when container is restarting.
This commit is contained in:
parent
dc12a1ac7f
commit
145fe6dbcb
8 changed files with 281 additions and 39 deletions
|
|
@ -2,6 +2,7 @@ package mocks
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/containrrr/watchtower/pkg/container"
|
||||
"time"
|
||||
|
||||
|
|
@ -70,12 +71,21 @@ func (client MockClient) RemoveImageByID(id string) error {
|
|||
|
||||
// GetContainer is a mock method
|
||||
func (client MockClient) GetContainer(containerID string) (container.Container, error) {
|
||||
return container.Container{}, nil
|
||||
return client.TestData.Containers[0], nil
|
||||
}
|
||||
|
||||
// ExecuteCommand is a mock method
|
||||
func (client MockClient) ExecuteCommand(containerID string, command string, timeout int) error {
|
||||
return nil
|
||||
func (client MockClient) ExecuteCommand(containerID string, command string, timeout int) (SkipUpdate bool, err error) {
|
||||
switch command {
|
||||
case "/PreUpdateReturn0.sh":
|
||||
return false, nil
|
||||
case "/PreUpdateReturn1.sh":
|
||||
return false, fmt.Errorf("command exited with code 1")
|
||||
case "/PreUpdateReturn75.sh":
|
||||
return true, nil
|
||||
default:
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
// IsContainerStale is always true for the mock client
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue