From 90b73ff6d2c3c9735358d8bf44fcd38f017b081c Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Sun, 14 Apr 2019 21:14:40 +0900 Subject: [PATCH] connhelper: docker -> docker-container for consistency with tonistiigi/buildx#17 Close #935 Signed-off-by: Akihiro Suda --- client/connhelper/docker/docker.go | 26 ------------------- .../dockercontainer/dockercontainer.go | 26 +++++++++++++++++++ cmd/buildctl/main.go | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) delete mode 100644 client/connhelper/docker/docker.go create mode 100644 client/connhelper/dockercontainer/dockercontainer.go diff --git a/client/connhelper/docker/docker.go b/client/connhelper/docker/docker.go deleted file mode 100644 index a69032ab..00000000 --- a/client/connhelper/docker/docker.go +++ /dev/null @@ -1,26 +0,0 @@ -// Package connhelper provides helpers for connecting to a remote daemon host with custom logic. -package connhelper - -import ( - "context" - "net" - "net/url" - - "github.com/docker/cli/cli/connhelper/commandconn" - "github.com/moby/buildkit/client/connhelper" -) - -func init() { - connhelper.Register("docker", DockerHelper) -} - -// DockerHelper returns helper for connecting to Docker container. -// docker:// URL requires BuildKit v0.5.0 or later in the container. -func DockerHelper(u *url.URL) (*connhelper.ConnectionHelper, error) { - container := u.Host - return &connhelper.ConnectionHelper{ - ContextDialer: func(ctx context.Context, addr string) (net.Conn, error) { - return commandconn.New(ctx, "docker", "exec", "-i", container, "buildctl", "dial-stdio") - }, - }, nil -} diff --git a/client/connhelper/dockercontainer/dockercontainer.go b/client/connhelper/dockercontainer/dockercontainer.go new file mode 100644 index 00000000..aeebf7d7 --- /dev/null +++ b/client/connhelper/dockercontainer/dockercontainer.go @@ -0,0 +1,26 @@ +// Package dockercontainer provides connhelper for docker-container:// +package dockercontainer + +import ( + "context" + "net" + "net/url" + + "github.com/docker/cli/cli/connhelper/commandconn" + "github.com/moby/buildkit/client/connhelper" +) + +func init() { + connhelper.Register("docker-container", DockerContainerHelper) +} + +// DockerContainerHelper returns helper for connecting to Docker container. +// docker-container:// URL requires BuildKit v0.5.0 or later in the container. +func DockerContainerHelper(u *url.URL) (*connhelper.ConnectionHelper, error) { + container := u.Host + return &connhelper.ConnectionHelper{ + ContextDialer: func(ctx context.Context, addr string) (net.Conn, error) { + return commandconn.New(ctx, "docker", "exec", "-i", container, "buildctl", "dial-stdio") + }, + }, nil +} diff --git a/cmd/buildctl/main.go b/cmd/buildctl/main.go index 5f5393e6..5d2b99df 100644 --- a/cmd/buildctl/main.go +++ b/cmd/buildctl/main.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - _ "github.com/moby/buildkit/client/connhelper/docker" + _ "github.com/moby/buildkit/client/connhelper/dockercontainer" bccommon "github.com/moby/buildkit/cmd/buildctl/common" "github.com/moby/buildkit/util/apicaps" "github.com/moby/buildkit/util/appdefaults"