From 2061550bc178afd85b02fc74304d93ef9ad1b2bc Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 29 May 2024 14:20:53 -0400 Subject: [PATCH] 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 --- util/imagetools/create.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/util/imagetools/create.go b/util/imagetools/create.go index fa168b1a..71853e07 100644 --- a/util/imagetools/create.go +++ b/util/imagetools/create.go @@ -80,12 +80,15 @@ func (r *Resolver) Combine(ctx context.Context, srcs []*Source, ann []string, pr // on single source, return original bytes if len(srcs) == 1 && len(ann) == 0 { 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 { return dts[0], srcs[0].Desc, nil } - case images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex: - return dts[0], srcs[0].Desc, nil } }