mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 18:13:42 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package llb
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
 | 
						|
	digest "github.com/opencontainers/go-digest"
 | 
						|
	ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
 | 
						|
)
 | 
						|
 | 
						|
// WithMetaResolver adds a metadata resolver to an image
 | 
						|
func WithMetaResolver(mr ImageMetaResolver) ImageOption {
 | 
						|
	return imageOptionFunc(func(ii *ImageInfo) {
 | 
						|
		ii.metaResolver = mr
 | 
						|
	})
 | 
						|
}
 | 
						|
 | 
						|
// ResolveDigest uses the meta resolver to update the ref of image with full digest before marshaling.
 | 
						|
// This makes image ref immutable and is recommended if you want to make sure meta resolver data
 | 
						|
// matches the image used during the build.
 | 
						|
func ResolveDigest(v bool) ImageOption {
 | 
						|
	return imageOptionFunc(func(ii *ImageInfo) {
 | 
						|
		ii.resolveDigest = v
 | 
						|
	})
 | 
						|
}
 | 
						|
 | 
						|
func WithLayerLimit(l int) ImageOption {
 | 
						|
	return imageOptionFunc(func(ii *ImageInfo) {
 | 
						|
		ii.layerLimit = &l
 | 
						|
	})
 | 
						|
}
 | 
						|
 | 
						|
// ImageMetaResolver can resolve image config metadata from a reference
 | 
						|
type ImageMetaResolver interface {
 | 
						|
	ResolveImageConfig(ctx context.Context, ref string, opt ResolveImageConfigOpt) (digest.Digest, []byte, error)
 | 
						|
}
 | 
						|
 | 
						|
type ResolverType int
 | 
						|
 | 
						|
const (
 | 
						|
	ResolverTypeRegistry ResolverType = iota
 | 
						|
	ResolverTypeOCILayout
 | 
						|
)
 | 
						|
 | 
						|
type ResolveImageConfigOpt struct {
 | 
						|
	Platform     *ocispecs.Platform
 | 
						|
	ResolveMode  string
 | 
						|
	LogName      string
 | 
						|
	ResolverType // default is ResolverTypeRegistry
 | 
						|
	SessionID    string
 | 
						|
}
 |