Skip to content

Commit

Permalink
Add default remote socket path if empty
Browse files Browse the repository at this point in the history
Signed-off-by: Anders F Björklund <[email protected]>
  • Loading branch information
afbjorklund committed Sep 27, 2024
1 parent 72452eb commit d529d42
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/bindings/connection.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bindings

import (
"bytes"
"context"
"errors"
"fmt"
Expand Down Expand Up @@ -210,6 +211,22 @@ func sshClient(_url *url.URL, uri string, identity string, machine bool) (Connec
if err != nil {
return connection, newConnectError(err)
}
if _url.Path == "" {
session, err := conn.NewSession()
if err != nil {
return connection, err
}
defer session.Close()

var b bytes.Buffer
session.Stdout = &b
if err := session.Run(
"podman info --format '{{.Host.RemoteSocket.Path}}'"); err != nil {
return connection, err
}
val := strings.TrimSuffix(b.String(), "\n")
_url.Path = val
}
dialContext := func(ctx context.Context, _, _ string) (net.Conn, error) {
return ssh.DialNet(conn, "unix", _url)
}
Expand Down

0 comments on commit d529d42

Please sign in to comment.