-
Notifications
You must be signed in to change notification settings - Fork 42
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 protocol selection when adding a new nuage provider #45
Fix protocol selection when adding a new nuage provider #45
Conversation
@gasper-vrhovsek please fix rubocop issues. @miq-bot add_label gaprindashvili/yes |
4ee4082
to
6a3413b
Compare
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.
@gasper-vrhovsek nitpicking, but I'd simplify the ternary operator a little bit more.
@@ -17,7 +17,7 @@ def raw_connect(username, password, endpoint_opts) | |||
end | |||
|
|||
def auth_url(protocol, server, port, version) | |||
scheme = protocol == "ssl-with-validation" ? "https" : "http" | |||
scheme = !protocol || (protocol == "non-ssl") ? "http" : "https" |
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.
I find this !protocol
part confusing*, perhaps we would be better off with:
scheme = protocol.to_s.start_with? "ssl" ? "https" : "http"
*Too much Java-like. I mean, we're in ruby, we shouldn't check for null
all over the code 😉
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 mean nil
? :)
1ba9c1b
to
8e63b1c
Compare
@miha-plesko I have reverted to the |
@@ -17,7 +17,7 @@ def raw_connect(username, password, endpoint_opts) | |||
end | |||
|
|||
def auth_url(protocol, server, port, version) | |||
scheme = protocol == "ssl-with-validation" ? "https" : "http" | |||
scheme = (!protocol || protocol == "non-ssl") ? "http" : "https" |
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.
@gasper-vrhovsek
This is difficult to read. Can you describe the logic here so I can make sure I understand it correctly?
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.
Hi @bronaghs, sure i can describe:
If protocol is not provided or if 'non-ssl' is selected, then 'http' value is assigned. Otherwise 'https' is assigned.
My background is mostly java, so I am still getting used to Ruby. I'll search for a more readable solution.
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.
@bronaghs and @miha-plesko I have refactored the scheme selecting logic. Hope it's better and more readable now.
7ee6e07
to
ca40ad5
Compare
ca40ad5
to
ac9f881
Compare
Checked commit gasper-vrhovsek@ac9f881 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
Thanks @gasper-vrhovsek for reworking it 👍 |
…ction Fix protocol selection when adding a new nuage provider (cherry picked from commit 3887e05)
Gaprindashvili backport details:
|
This fixes endpoint url generation from form input values. Before, if SSL was selected, the url began
with 'http'. Now when either 'SSL' or 'SSL with validation' are selected, the url begins with 'https'.
@miq-bot add_label bug
/cc @gberginc
/cc @miha-plesko