From 8f576e579024eae301eef1fc04402352648df1f2 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 8 Mar 2024 12:20:00 -0800 Subject: [PATCH] remote: fix connhelpers with custom dialer With the new dial-stdio command the dialer is split from `Client` function in order to access it directly. This breaks the custom connhelpers functionality as support for connhelpers is a feature of the default dialer. If client defines a custom dialer then only it is used without extra modifications. This means that remote driver dialer needs to detect the connhelpers on its own. Signed-off-by: Tonis Tiigi --- driver/remote/driver.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/driver/remote/driver.go b/driver/remote/driver.go index 5f51e8f071b..0dc676cf36b 100644 --- a/driver/remote/driver.go +++ b/driver/remote/driver.go @@ -13,6 +13,7 @@ import ( util "github.com/docker/buildx/driver/remote/util" "github.com/docker/buildx/util/progress" "github.com/moby/buildkit/client" + "github.com/moby/buildkit/client/connhelper" "github.com/moby/buildkit/util/tracing/detect" "github.com/pkg/errors" ) @@ -95,7 +96,16 @@ func (d *Driver) Client(ctx context.Context) (*client.Client, error) { } func (d *Driver) Dial(ctx context.Context) (net.Conn, error) { - network, addr, ok := strings.Cut(d.InitConfig.EndpointAddr, "://") + addr := d.InitConfig.EndpointAddr + ch, err := connhelper.GetConnectionHelper(addr) + if err != nil { + return nil, err + } + if ch != nil { + return ch.ContextDialer(ctx, addr) + } + + network, addr, ok := strings.Cut(addr, "://") if !ok { return nil, errors.Errorf("invalid endpoint address: %s", d.InitConfig.EndpointAddr) }