From 7baac8c1471e6da43a468180e8bfc47756cd069e Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Fri, 22 May 2020 15:17:24 +0530 Subject: [PATCH] feat: allow ssh flag arguments Signed-off-by: Rahul Kadyan Signed-off-by: Sebastiaan van Stijn --- cli/connhelper/connhelper.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cli/connhelper/connhelper.go b/cli/connhelper/connhelper.go index c8d4e5a2ee..e349b3eaef 100644 --- a/cli/connhelper/connhelper.go +++ b/cli/connhelper/connhelper.go @@ -22,6 +22,19 @@ type ConnectionHelper struct { // // ssh://@ URL requires Docker 18.09 or later on the remote host. func GetConnectionHelper(daemonURL string) (*ConnectionHelper, error) { + return getConnectionHelper(daemonURL, nil) +} + +// GetConnectionHelperWithSSHOpts returns Docker-specific connection helper for +// the given URL, and accepts additional options for ssh connections. It returns +// nil without error when no helper is registered for the scheme. +// +// Requires Docker 18.09 or later on the remote host. +func GetConnectionHelperWithSSHOpts(daemonURL string, sshFlags []string) (*ConnectionHelper, error) { + return getConnectionHelper(daemonURL, sshFlags) +} + +func getConnectionHelper(daemonURL string, sshFlags []string) (*ConnectionHelper, error) { u, err := url.Parse(daemonURL) if err != nil { return nil, err @@ -34,7 +47,7 @@ func GetConnectionHelper(daemonURL string) (*ConnectionHelper, error) { } return &ConnectionHelper{ Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) { - return commandconn.New(ctx, "ssh", sp.Args("docker", "system", "dial-stdio")...) + return commandconn.New(ctx, "ssh", append(sshFlags, sp.Args("docker", "system", "dial-stdio")...)...) }, Host: "http://docker", }, nil