2018-04-19 13:07:27 -04:00
|
|
|
package llb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
digest "github.com/opencontainers/go-digest"
|
2020-04-16 11:06:33 -04:00
|
|
|
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
2018-04-19 13:07:27 -04:00
|
|
|
)
|
|
|
|
|
2018-09-26 08:26:12 -04:00
|
|
|
// WithMetaResolver adds a metadata resolver to an image
|
2018-04-19 13:07:27 -04:00
|
|
|
func WithMetaResolver(mr ImageMetaResolver) ImageOption {
|
2018-08-11 15:04:13 -04:00
|
|
|
return imageOptionFunc(func(ii *ImageInfo) {
|
2018-04-19 13:07:27 -04:00
|
|
|
ii.metaResolver = mr
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-04-16 11:06:33 -04:00
|
|
|
// 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
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-09-26 08:26:12 -04:00
|
|
|
// ImageMetaResolver can resolve image config metadata from a reference
|
2018-04-19 13:07:27 -04:00
|
|
|
type ImageMetaResolver interface {
|
2020-04-16 11:06:33 -04:00
|
|
|
ResolveImageConfig(ctx context.Context, ref string, opt ResolveImageConfigOpt) (digest.Digest, []byte, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResolveImageConfigOpt struct {
|
|
|
|
Platform *specs.Platform
|
|
|
|
ResolveMode string
|
|
|
|
LogName string
|
2018-04-19 13:07:27 -04:00
|
|
|
}
|