mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
feat: add timeout override for pre-update lifecycle hook
This commit is contained in:
parent
7e7d4bf9ce
commit
1d1c630f7a
7 changed files with 89 additions and 24 deletions
|
@ -2,10 +2,11 @@ package container
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/containrrr/watchtower/internal/util"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/containrrr/watchtower/internal/util"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
dockercontainer "github.com/docker/docker/api/types/container"
|
||||
)
|
||||
|
@ -118,6 +119,25 @@ 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 "off" which will allow the command/script
|
||||
// to run indefinitely. Users should be cautious with the off 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
|
||||
}
|
||||
|
||||
// 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