Skip to content

Commit

Permalink
Merge pull request #16526 from cdoern/containerHost
Browse files Browse the repository at this point in the history
fix port issues for CONTAINER_HOST
  • Loading branch information
openshift-merge-robot authored Nov 17, 2022
2 parents c67a518 + 14ef6a9 commit 44a9014
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/bindings/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ func NewConnectionWithIdentity(ctx context.Context, uri string, identity string,
var connection Connection
switch _url.Scheme {
case "ssh":
port, err := strconv.Atoi(_url.Port())
if err != nil {
return nil, err
port := 22
if _url.Port() != "" {
port, err = strconv.Atoi(_url.Port())
if err != nil {
return nil, err
}
}
conn, err := ssh.Dial(&ssh.ConnectionDialOptions{
Host: uri,
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/system_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ var _ = Describe("podman system connection", func() {
_, err = Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).ToNot(HaveOccurred())

// export the container_host env var and try again
err = os.Setenv("CONTAINER_HOST", fmt.Sprintf("ssh://%s@localhost", u.Username))
Expect(err).ToNot(HaveOccurred())
defer os.Unsetenv("CONTAINER_HOST")

cmd = exec.Command(podmanTest.RemotePodmanBinary, "ps")
_, err = Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).ToNot(HaveOccurred())

uri := url.URL{
Scheme: "ssh",
User: url.User(u.Username),
Expand Down

0 comments on commit 44a9014

Please sign in to comment.