mirror of
https://github.com/moby/buildkit.git
synced 2026-08-05 23:30:22 +00:00
This allows images to be pulled by tag and then checked against the digest. If digest is added directly to the image reference, then tag is ignored. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package llb
|
|
|
|
import (
|
|
"github.com/moby/buildkit/client/llb/sourceresolver"
|
|
digest "github.com/opencontainers/go-digest"
|
|
)
|
|
|
|
// 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
|
|
})
|
|
}
|
|
|
|
func WithImageChecksum(dgst digest.Digest) ImageOption {
|
|
return imageOptionFunc(func(ii *ImageInfo) {
|
|
ii.checksum = dgst
|
|
})
|
|
}
|
|
|
|
// ImageMetaResolver can resolve image config metadata from a reference
|
|
type ImageMetaResolver = sourceresolver.ImageMetaResolver
|