mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-17 23:50:13 +01:00
Added noUpdate run parameter, just pull new image without updating container
This commit is contained in:
parent
82a2df38ed
commit
338b54a00e
2 changed files with 40 additions and 31 deletions
|
|
@ -34,7 +34,7 @@ func containerFilter(names []string) container.Filter {
|
||||||
// used to start those containers have been updated. If a change is detected in
|
// used to start those containers have been updated. If a change is detected in
|
||||||
// any of the images, the associated containers are stopped and restarted with
|
// any of the images, the associated containers are stopped and restarted with
|
||||||
// the new image.
|
// the new image.
|
||||||
func Update(client container.Client, names []string, cleanup bool, noRestart bool) error {
|
func Update(client container.Client, names []string, cleanup bool, noRestart bool, noUpdate bool) error {
|
||||||
log.Debug("Checking containers for updated images")
|
log.Debug("Checking containers for updated images")
|
||||||
|
|
||||||
containers, err := client.ListContainers(containerFilter(names))
|
containers, err := client.ListContainers(containerFilter(names))
|
||||||
|
|
@ -59,6 +59,7 @@ func Update(client container.Client, names []string, cleanup bool, noRestart boo
|
||||||
|
|
||||||
checkDependencies(containers)
|
checkDependencies(containers)
|
||||||
|
|
||||||
|
if !noUpdate {
|
||||||
// Stop stale containers in reverse order
|
// Stop stale containers in reverse order
|
||||||
for i := len(containers) - 1; i >= 0; i-- {
|
for i := len(containers) - 1; i >= 0; i-- {
|
||||||
container := containers[i]
|
container := containers[i]
|
||||||
|
|
@ -99,6 +100,7 @@ func Update(client container.Client, names []string, cleanup bool, noRestart boo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
9
main.go
9
main.go
|
|
@ -29,6 +29,7 @@ var (
|
||||||
scheduleSpec string
|
scheduleSpec string
|
||||||
cleanup bool
|
cleanup bool
|
||||||
noRestart bool
|
noRestart bool
|
||||||
|
noUpdate bool
|
||||||
notifier *notifications.Notifier
|
notifier *notifications.Notifier
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -76,6 +77,11 @@ func main() {
|
||||||
Usage: "remove old images after updating",
|
Usage: "remove old images after updating",
|
||||||
EnvVar: "WATCHTOWER_CLEANUP",
|
EnvVar: "WATCHTOWER_CLEANUP",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "no-update",
|
||||||
|
Usage: "do not update container",
|
||||||
|
EnvVar: "WATCHTOWER_NO_UPDATE",
|
||||||
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "tlsverify",
|
Name: "tlsverify",
|
||||||
Usage: "use TLS and verify the remote",
|
Usage: "use TLS and verify the remote",
|
||||||
|
|
@ -146,6 +152,7 @@ func before(c *cli.Context) error {
|
||||||
|
|
||||||
cleanup = c.GlobalBool("cleanup")
|
cleanup = c.GlobalBool("cleanup")
|
||||||
noRestart = c.GlobalBool("no-restart")
|
noRestart = c.GlobalBool("no-restart")
|
||||||
|
noUpdate = c.GlobalBool("no-update")
|
||||||
|
|
||||||
// configure environment vars for client
|
// configure environment vars for client
|
||||||
err := envConfig(c)
|
err := envConfig(c)
|
||||||
|
|
@ -177,7 +184,7 @@ func start(c *cli.Context) error {
|
||||||
case v := <- tryLockSem:
|
case v := <- tryLockSem:
|
||||||
defer func() { tryLockSem <- v }()
|
defer func() { tryLockSem <- v }()
|
||||||
notifier.StartNotification()
|
notifier.StartNotification()
|
||||||
if err := actions.Update(client, names, cleanup, noRestart); err != nil {
|
if err := actions.Update(client, names, cleanup, noRestart, noUpdate); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
notifier.SendNotification()
|
notifier.SendNotification()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue