mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-13 21:56:38 +01:00
fix(lifecycle): cleanup lifecycle
- removes unwieldy SkipUpdate return value in favor of errors.Is - generalizes the code for all four phases - allows timeout to be defined for all phases - enables explicit unit in timeout label values (in addition to implicit minutes)
This commit is contained in:
parent
76f9cea516
commit
023c1a7d93
10 changed files with 160 additions and 179 deletions
|
|
@ -219,44 +219,6 @@ func (c Container) IsWatchtower() bool {
|
|||
return ContainsWatchtowerLabel(c.containerInfo.Config.Labels)
|
||||
}
|
||||
|
||||
// PreUpdateTimeout checks whether a container has a specific timeout set
|
||||
// for how long the pre-update command is allowed to run. This value is expressed
|
||||
// either as an integer, in minutes, or as 0 which will allow the command/script
|
||||
// to run indefinitely. Users should be cautious with the 0 option, as that
|
||||
// could result in watchtower waiting forever.
|
||||
func (c Container) PreUpdateTimeout() int {
|
||||
var minutes int
|
||||
var err error
|
||||
|
||||
val := c.getLabelValueOrEmpty(preUpdateTimeoutLabel)
|
||||
|
||||
minutes, err = strconv.Atoi(val)
|
||||
if err != nil || val == "" {
|
||||
return 1
|
||||
}
|
||||
|
||||
return minutes
|
||||
}
|
||||
|
||||
// PostUpdateTimeout checks whether a container has a specific timeout set
|
||||
// for how long the post-update command is allowed to run. This value is expressed
|
||||
// either as an integer, in minutes, or as 0 which will allow the command/script
|
||||
// to run indefinitely. Users should be cautious with the 0 option, as that
|
||||
// could result in watchtower waiting forever.
|
||||
func (c Container) PostUpdateTimeout() int {
|
||||
var minutes int
|
||||
var err error
|
||||
|
||||
val := c.getLabelValueOrEmpty(postUpdateTimeoutLabel)
|
||||
|
||||
minutes, err = strconv.Atoi(val)
|
||||
if err != nil || val == "" {
|
||||
return 1
|
||||
}
|
||||
|
||||
return minutes
|
||||
}
|
||||
|
||||
// StopSignal returns the custom stop signal (if any) that is encoded in the
|
||||
// container's metadata. If the container has not specified a custom stop
|
||||
// signal, the empty string "" is returned.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue