-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix port issues for CONTAINER_HOST #16526
Conversation
port, err := strconv.Atoi(_url.Port()) | ||
if err != nil { | ||
return nil, err | ||
port := 22 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could read /etc/services for this, but I think this is fine.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hesitant since there are a bunch of different ssh related lines in there it seems but I can do this if we want
return nil, err | ||
port := 22 | ||
if _url.Port() != "" { | ||
port, err = strconv.Atoi(_url.Port()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could just do port, _ =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, but I will leave the if
since atoi returns 0 on failure
one NIT ... else LGTM |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cdoern, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
5c3a8c0
to
94018d1
Compare
pkg/bindings/connection.go
Outdated
return nil, err | ||
port := 22 | ||
if _url.Port() != "" { | ||
port, _ = strconv.Atoi(_url.Port()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the error ignored? This will set the port to 0 on errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I will add the error check back in
test/e2e/system_connection_test.go
Outdated
cmd = exec.Command("export", "CONTAINER_HOST", fmt.Sprintf("ssh://%s@localhost", u.Username)) | ||
_, err = Start(cmd, GinkgoWriter, GinkgoWriter) | ||
Expect(err).ToNot(HaveOccurred()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export and unset are not commands, they are shell built-ins.
you need os.Setenv(0 and os .Unsetenv().
But I don't see how this tests anything "--connection", "QA"
should overwrite the env var, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, I knew I was doing that part wrong! As for the --connection, not sure if this makes a difference as I think the env var has priority but just in case I will try without it
94018d1
to
66174f9
Compare
test/e2e/system_connection_test.go
Outdated
_, err = Start(cmd, GinkgoWriter, GinkgoWriter) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
err = os.Unsetenv("CONTAINER_HOST") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be defer os.Unsetenv("CONTAINER_HOST") right after the setenv call, otherwise you will leak the env on test errors.
if no port is specified for an ssh style url, default to 22 resolves containers#16509 Signed-off-by: Charlie Doern <[email protected]>
66174f9
to
14ef6a9
Compare
/lgtm |
/hold cancel |
if no port is specified for an ssh style url, default to 22
resolves #16509
Signed-off-by: Charlie Doern [email protected]
Does this PR introduce a user-facing change?