From 423f5f8a9758c39955e2d6869a66bea71c7728bd Mon Sep 17 00:00:00 2001 From: Edgar Lee Date: Wed, 8 Apr 2020 12:11:24 -0700 Subject: [PATCH 1/2] Allow sessions to hijack the connection outside of a solve Signed-off-by: Edgar Lee --- client/client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/client.go b/client/client.go index 6b824094..d256ec37 100644 --- a/client/client.go +++ b/client/client.go @@ -11,6 +11,8 @@ import ( "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" controlapi "github.com/moby/buildkit/api/services/control" "github.com/moby/buildkit/client/connhelper" + "github.com/moby/buildkit/session" + "github.com/moby/buildkit/session/grpchijack" "github.com/moby/buildkit/util/appdefaults" opentracing "github.com/opentracing/opentracing-go" "github.com/pkg/errors" @@ -80,6 +82,10 @@ func (c *Client) controlClient() controlapi.ControlClient { return controlapi.NewControlClient(c.conn) } +func (c *Client) Dialer() session.Dialer { + return grpchijack.Dialer(c.controlClient()) +} + func (c *Client) Close() error { return c.conn.Close() } From d42b8bfc108de700b6ba4f058d9f6c6b53ba1836 Mon Sep 17 00:00:00 2001 From: Edgar Lee Date: Wed, 8 Apr 2020 14:07:35 -0700 Subject: [PATCH 2/2] Set single export entry outside of session initialization Signed-off-by: Edgar Lee --- client/solve.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client/solve.go b/client/solve.go index 2c867822..1d77bc45 100644 --- a/client/solve.go +++ b/client/solve.go @@ -115,6 +115,12 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG } var ex ExportEntry + if len(opt.Exports) > 1 { + return nil, errors.New("currently only single Exports can be specified") + } + if len(opt.Exports) == 1 { + ex = opt.Exports[0] + } if !opt.SessionPreInitialized { if len(syncedDirs) > 0 { @@ -125,13 +131,6 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG s.Allow(a) } - if len(opt.Exports) > 1 { - return nil, errors.New("currently only single Exports can be specified") - } - if len(opt.Exports) == 1 { - ex = opt.Exports[0] - } - switch ex.Type { case ExporterLocal: if ex.Output != nil {