mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-15 14:40:13 +01:00
feat: add open container version to log messages
This commit is contained in:
parent
d6bb80a3a0
commit
d60d5bb7b4
1 changed files with 15 additions and 2 deletions
|
|
@ -20,7 +20,10 @@ import (
|
|||
t "github.com/beatkind/watchtower/pkg/types"
|
||||
)
|
||||
|
||||
const defaultStopSignal = "SIGTERM"
|
||||
const (
|
||||
defaultStopSignal = "SIGTERM"
|
||||
openContainerVersion = "org.opencontainers.image.version"
|
||||
)
|
||||
|
||||
// A Client is the interface through which watchtower interacts with the
|
||||
// Docker API.
|
||||
|
|
@ -193,6 +196,10 @@ func (client dockerClient) StopContainer(c t.Container, timeout time.Duration) e
|
|||
shortID := c.ID().ShortID()
|
||||
|
||||
if c.IsRunning() {
|
||||
openVer, ok := c.ContainerInfo().Config.Labels[openContainerVersion]
|
||||
if ok {
|
||||
shortID = fmt.Sprintf("%s - %s", shortID, openVer)
|
||||
}
|
||||
log.Infof("Stopping %s (%s) with %s", c.Name(), shortID, signal)
|
||||
if err := client.api.ContainerKill(bg, idStr, signal); err != nil {
|
||||
return err
|
||||
|
|
@ -349,7 +356,13 @@ func (client dockerClient) HasNewImage(ctx context.Context, container t.Containe
|
|||
return false, currentImageID, nil
|
||||
}
|
||||
|
||||
log.Infof("Found new %s image (%s)", imageName, newImageID.ShortID())
|
||||
imageID := newImageID.ShortID()
|
||||
openImageVer, ok := newImageInfo.Config.Labels[openContainerVersion]
|
||||
if ok {
|
||||
imageID = fmt.Sprintf("%s - %s", imageID, openImageVer)
|
||||
}
|
||||
|
||||
log.Infof("Found new %s image (%s)", imageName, imageID)
|
||||
return true, newImageID, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue