From 4ac3aeef297e942d07709f27f075706ff7170607 Mon Sep 17 00:00:00 2001 From: Sohan Kunkerkar Date: Tue, 12 Sep 2023 12:12:48 -0400 Subject: [PATCH] internal/storage: address unpredictable behavior of image names The current implementation of image names exhibits unpredictable behavior for users, as it relies on the order in which names were pulled, which is not guaranteed by the API. To address this issue, this commit proposes processing all names in image.Names through the filter. Signed-off-by: Sohan Kunkerkar --- internal/storage/image.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/storage/image.go b/internal/storage/image.go index fea1d0c9c25..7754b0c01c5 100644 --- a/internal/storage/image.go +++ b/internal/storage/image.go @@ -255,14 +255,21 @@ func (svc *imageService) buildImageCacheItem(systemContext *types.SystemContext, return imageCacheItem{}, err } } - name, _, _ := sortNamesByType(image.Names) + + imagePinned := false + for _, image := range image.Names { + if FilterPinnedImage(image, svc.regexForPinnedImages) { + imagePinned = true + break + } + } return imageCacheItem{ config: imageConfig, size: size, configDigest: configDigest, info: info, annotations: ociManifest.Annotations, - isImagePinned: FilterPinnedImage(name, svc.regexForPinnedImages), + isImagePinned: imagePinned, }, nil }