Skip to content

Commit 5cc2396

Browse files
authored
Merge pull request #2541 from znck/allow-ssh-flags
feat: allow ssh flag arguments
2 parents 51a0914 + 7baac8c commit 5cc2396

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cli/connhelper/connhelper.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ type ConnectionHelper struct {
2222
//
2323
// ssh://<user>@<host> URL requires Docker 18.09 or later on the remote host.
2424
func GetConnectionHelper(daemonURL string) (*ConnectionHelper, error) {
25+
return getConnectionHelper(daemonURL, nil)
26+
}
27+
28+
// GetConnectionHelperWithSSHOpts returns Docker-specific connection helper for
29+
// the given URL, and accepts additional options for ssh connections. It returns
30+
// nil without error when no helper is registered for the scheme.
31+
//
32+
// Requires Docker 18.09 or later on the remote host.
33+
func GetConnectionHelperWithSSHOpts(daemonURL string, sshFlags []string) (*ConnectionHelper, error) {
34+
return getConnectionHelper(daemonURL, sshFlags)
35+
}
36+
37+
func getConnectionHelper(daemonURL string, sshFlags []string) (*ConnectionHelper, error) {
2538
u, err := url.Parse(daemonURL)
2639
if err != nil {
2740
return nil, err
@@ -34,7 +47,7 @@ func GetConnectionHelper(daemonURL string) (*ConnectionHelper, error) {
3447
}
3548
return &ConnectionHelper{
3649
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
37-
return commandconn.New(ctx, "ssh", sp.Args("docker", "system", "dial-stdio")...)
50+
return commandconn.New(ctx, "ssh", append(sshFlags, sp.Args("docker", "system", "dial-stdio")...)...)
3851
},
3952
Host: "http://docker",
4053
}, nil

0 commit comments

Comments
 (0)