mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
Add a --prefer-index flag that allows you to specify the preferred behavior when deciding on how to create an image/manifest from a single source.
Signed-off-by: Tim Smith <tismith@rvohealth.com>
This commit is contained in:
@ -29,7 +29,7 @@ type Source struct {
|
||||
Ref reference.Named
|
||||
}
|
||||
|
||||
func (r *Resolver) Combine(ctx context.Context, srcs []*Source, ann []string) ([]byte, ocispec.Descriptor, error) {
|
||||
func (r *Resolver) Combine(ctx context.Context, srcs []*Source, ann []string, preferIndex bool) ([]byte, ocispec.Descriptor, error) {
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
||||
|
||||
dts := make([][]byte, len(srcs))
|
||||
@ -79,7 +79,12 @@ func (r *Resolver) Combine(ctx context.Context, srcs []*Source, ann []string) ([
|
||||
|
||||
// on single source, return original bytes
|
||||
if len(srcs) == 1 && len(ann) == 0 {
|
||||
if mt := srcs[0].Desc.MediaType; mt == images.MediaTypeDockerSchema2ManifestList || mt == images.MediaTypeDockerSchema2Manifest || mt == ocispec.MediaTypeImageIndex {
|
||||
switch srcs[0].Desc.MediaType {
|
||||
case images.MediaTypeDockerSchema2Manifest:
|
||||
if !preferIndex {
|
||||
return dts[0], srcs[0].Desc, nil
|
||||
}
|
||||
case images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
|
||||
return dts[0], srcs[0].Desc, nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user