solver: return digest when resolving images

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2021-12-09 14:16:39 -05:00
parent 1d71f77151
commit 2164875737
2 changed files with 6 additions and 6 deletions

View File

@ -762,7 +762,7 @@ func (p *Pipeline) FetchContainer(ctx context.Context, op *compiler.Value, st ll
// Load image metadata and convert to to LLB.
platform := p.pctx.Platform.Get()
p.image, err = p.s.ResolveImageConfig(ctx, ref.String(), llb.ResolveImageConfigOpt{
p.image, _, err = p.s.ResolveImageConfig(ctx, ref.String(), llb.ResolveImageConfigOpt{
LogName: p.vertexNamef("load metadata for %s", ref.String()),
Platform: &platform,
})

View File

@ -101,21 +101,21 @@ func (s Solver) SessionID() string {
return s.opts.Gateway.BuildOpts().SessionID
}
func (s Solver) ResolveImageConfig(ctx context.Context, ref string, opts llb.ResolveImageConfigOpt) (dockerfile2llb.Image, error) {
func (s Solver) ResolveImageConfig(ctx context.Context, ref string, opts llb.ResolveImageConfigOpt) (dockerfile2llb.Image, digest.Digest, error) {
var image dockerfile2llb.Image
// Load image metadata and convert to to LLB.
// Inspired by https://github.com/moby/buildkit/blob/master/frontend/dockerfile/dockerfile2llb/convert.go
// FIXME: this needs to handle platform
_, meta, err := s.opts.Gateway.ResolveImageConfig(ctx, ref, opts)
dg, meta, err := s.opts.Gateway.ResolveImageConfig(ctx, ref, opts)
if err != nil {
return image, err
return image, "", err
}
if err := json.Unmarshal(meta, &image); err != nil {
return image, err
return image, "", err
}
return image, nil
return image, dg, nil
}
// Solve will block until the state is solved and returns a Reference.