From 216487573732cd5e91ff5ccd5f26fee51e32a347 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 9 Dec 2021 14:16:39 -0500 Subject: [PATCH] solver: return digest when resolving images Signed-off-by: Andrea Luzzardi --- environment/pipeline.go | 2 +- solver/solver.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/environment/pipeline.go b/environment/pipeline.go index 31b8e8e3..98e20edb 100644 --- a/environment/pipeline.go +++ b/environment/pipeline.go @@ -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, }) diff --git a/solver/solver.go b/solver/solver.go index f5a57e61..01db431f 100644 --- a/solver/solver.go +++ b/solver/solver.go @@ -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.