in generatebundlefile/ecr_helper.go [85:101]
func getLatestImageSha(details []ecrtypes.ImageDetail) (*api.SourceVersion, error) {
var latest ecrtypes.ImageDetail
latest.ImagePushedAt = &time.Time{}
for _, detail := range details {
if len(details) < 1 || detail.ImagePushedAt == nil || detail.ImageDigest == nil || detail.ImageTags == nil || len(detail.ImageTags) == 0 || *detail.ImageManifestMediaType != "application/vnd.oci.image.manifest.v1+json" {
continue
}
if detail.ImagePushedAt != nil && latest.ImagePushedAt.Before(*detail.ImagePushedAt) {
latest = detail
}
}
// Check if latest is equal to empty struct, and return error if that's the case.
if reflect.DeepEqual(latest, ecrtypes.ImageDetail{}) {
return nil, fmt.Errorf("error no images found")
}
return &api.SourceVersion{Name: latest.ImageTags[0], Digest: *latest.ImageDigest}, nil
}