Debian Codegraph @

buildkit/frontend/gateway/forwarder/frontend.go

raw
1 package forwarder
2
3 import (
4 "context"
5
6 "github.com/moby/buildkit/executor"
7 "github.com/moby/buildkit/frontend"
8 "github.com/moby/buildkit/frontend/gateway/client"
9 "github.com/moby/buildkit/session"
10 "github.com/moby/buildkit/solver/pb"
11 "github.com/moby/buildkit/worker"
12 )
13
14 func NewGatewayForwarder(w worker.Infos, f client.BuildFunc) frontend.Frontend {
15 return &GatewayForwarder{
16 workers: w,
17 f: f,
18 }
19 }
20
21 type GatewayForwarder struct {
22 workers worker.Infos
23 f client.BuildFunc
24 }
25
26 func (gf *GatewayForwarder) Solve(ctx context.Context, llbBridge frontend.FrontendLLBBridge, exec executor.Executor, opts map[string]string, inputs map[string]*pb.Definition, sid string, sm *session.Manager) (retRes *frontend.Result, retErr error) {
27 c, err := LLBBridgeToGatewayClient(ctx, llbBridge, exec, opts, inputs, gf.workers, sid, sm)
28 if err != nil {
29 return nil, err
30 }
31
32 defer func() {
33 c.discard(retErr)
34 }()
35
36 res, err := gf.f(ctx, c)
37 if err != nil {
38 return nil, err
39 }
40
41 return c.toFrontendResult(res)
42 }