fix(lastUpdated): fix image lastUpdated timestamp logic (#863)

The lastUpdated field was picked from the first entry in image history
Now it is the created time of the image, or the last entry in
image history, if created time is unavailable

Signed-off-by: Andrei Aaron <andaaron@cisco.com>
This commit is contained in:
Andrei Aaron
2022-10-11 03:43:05 +03:00
committed by GitHub
parent 5494208556
commit 815366024b
4 changed files with 29 additions and 46 deletions
-11
View File
@@ -1,8 +1,6 @@
package mocks
import (
"time"
v1 "github.com/google/go-containerregistry/pkg/v1"
godigest "github.com/opencontainers/go-digest"
ispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -15,7 +13,6 @@ type OciLayoutUtilsMock struct {
GetImageBlobManifestFn func(imageDir string, digest godigest.Digest) (v1.Manifest, error)
GetImageInfoFn func(imageDir string, hash v1.Hash) (ispec.Image, error)
GetImageTagsWithTimestampFn func(repo string) ([]common.TagInfo, error)
GetImageLastUpdatedFn func(imageInfo ispec.Image) time.Time
GetImagePlatformFn func(imageInfo ispec.Image) (string, string)
GetImageVendorFn func(imageInfo ispec.Image) string
GetImageManifestSizeFn func(repo string, manifestDigest godigest.Digest) int64
@@ -75,14 +72,6 @@ func (olum OciLayoutUtilsMock) GetImageTagsWithTimestamp(repo string) ([]common.
return []common.TagInfo{}, nil
}
func (olum OciLayoutUtilsMock) GetImageLastUpdated(imageInfo ispec.Image) time.Time {
if olum.GetImageLastUpdatedFn != nil {
return olum.GetImageLastUpdatedFn(imageInfo)
}
return time.Time{}
}
func (olum OciLayoutUtilsMock) GetImagePlatform(imageInfo ispec.Image) (string, string) {
if olum.GetImagePlatformFn != nil {
return olum.GetImagePlatformFn(imageInfo)