Add comments that describe original image info overwriting

This commit is contained in:
Amin Faez 2024-05-08 21:27:55 +02:00
parent 85ea00f3ad
commit ebe3fafeef
2 changed files with 9 additions and 3 deletions

View file

@ -329,10 +329,12 @@ func (client dockerClient) IsContainerStale(container t.Container, params t.Upda
} }
func (client dockerClient) HasNewImage(ctx context.Context, container t.Container) (hasNew bool, latestImage t.ImageID, err error) { func (client dockerClient) HasNewImage(ctx context.Context, container t.Container) (hasNew bool, latestImage t.ImageID, err error) {
currentImageID := t.ImageID(container.ContainerInfo().ContainerJSONBase.Image) container_info := container.ContainerInfo()
currentImageID := t.ImageID(container_info.ContainerJSONBase.Image)
imageName := container.ImageName() imageName := container.ImageName()
imageIDSetByLabel, ok := container.ContainerInfo().Config.Labels[originalImageIDLabel] // If the original-image-id label is set, it overwrites the image id reported by docker
imageIDSetByLabel, ok := container_info.Config.Labels[originalImageIDLabel]
if ok { if ok {
currentImageID = t.ImageID(imageIDSetByLabel) currentImageID = t.ImageID(imageIDSetByLabel)
log.Infof("Original image id for %s found: (%s)", imageName, currentImageID.ShortID()) log.Infof("Original image id for %s found: (%s)", imageName, currentImageID.ShortID())

View file

@ -103,7 +103,11 @@ func (c Container) SafeImageID() wt.ImageID {
// "latest" tag is assumed. // "latest" tag is assumed.
func (c Container) ImageName() string { func (c Container) ImageName() string {
// Compatibility w/ Zodiac deployments // Compatibility w/ Zodiac deployments
imageName, ok := c.getLabelValue(originalImageNameLabel) imageName, ok := c.getLabelValue(zodiacLabel)
// If the original-image-name label is set, it overwrites the image name reported by docker
if !ok {
imageName, ok = c.getLabelValue(originalImageNameLabel)
}
if !ok { if !ok {
imageName = c.containerInfo.Config.Image imageName = c.containerInfo.Config.Image
} }