Slightly refactored the mediaType check on single source so that now we return original bytes without filtering on mediaType, based on the preferIndex preference.

Signed-off-by: Tim Smith <tismith@rvohealth.com>
This commit is contained in:
Tim Smith 2024-05-29 14:20:53 -04:00
parent abf6c77d91
commit 2061550bc1
1 changed files with 6 additions and 3 deletions

View File

@ -80,12 +80,15 @@ func (r *Resolver) Combine(ctx context.Context, srcs []*Source, ann []string, pr
// on single source, return original bytes // on single source, return original bytes
if len(srcs) == 1 && len(ann) == 0 { if len(srcs) == 1 && len(ann) == 0 {
switch srcs[0].Desc.MediaType { switch srcs[0].Desc.MediaType {
case images.MediaTypeDockerSchema2Manifest: // if the source is already an image index or manifest list, there is no need to consider the value
// of preferIndex since if set to true then the source is already in the preferred format, and if false
// it doesn't matter since we're not going to split it into separate manifests
case images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
return dts[0], srcs[0].Desc, nil
default:
if !preferIndex { if !preferIndex {
return dts[0], srcs[0].Desc, nil return dts[0], srcs[0].Desc, nil
} }
case images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
return dts[0], srcs[0].Desc, nil
} }
} }