-
Notifications
You must be signed in to change notification settings - Fork 28
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 regression where URIs as input for the entrypoint no longer worked. #107
Fix regression where URIs as input for the entrypoint no longer worked. #107
Conversation
d8fcb84
to
09955b3
Compare
@@ -139,10 +139,11 @@ def normalize_entrypoint_url(entrypoint, suffix_path) | |||
strip_path.nil? || suffix_path = strip_path | |||
strip_path = suffix_path.gsub(%r{^/}, '') | |||
strip_path.nil? || suffix_path = strip_path | |||
strip_entrypoint = entrypoint.gsub(%r{/$}, '') | |||
the_entry_point = (entrypoint.is_a? URI::HTTP) ? entrypoint.to_s : entrypoint |
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 not the simpler entrypoint = entrypoint.to_s
?
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.
On 8 Jul 2016, at 14:02, Oleg Barenboim wrote:
Why not the simpler
entrypoint = entrypoint.to_s
?
Isn't a to_s on something that is already a string a bit odd? But sure I
can change that.
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.
Idiomatic Ruby /cc @Fryguy
09955b3
to
0cf88f2
Compare
strip_entrypoint = entrypoint.gsub(%r{/$}, '') | ||
strip_path.nil? && strip_entrypoint = entrypoint | ||
strip_entrypoint = entrypoint.to_s.gsub(%r{/$}, '') | ||
strip_path.nil? && strip_entrypoint = entrypoint.to_s |
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.
what about empty strings? (I mean '')
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.
The internal clients use that method to get to the correct base-endpoint, so I don't think this is an issue that could arise. I can add a guard on suffix_path
being empty to warn the developer of a new sub-client - the nil
case is easily caught by nil.gsub
bailing out :-)
is this applying to all subclients or only main client and metrics? |
0cf88f2
to
6336cf3
Compare
6336cf3
to
cd40a17
Compare
@abonas when you do |
strip_path = suffix_path.gsub(%r{/$}, '') | ||
strip_path.nil? || suffix_path = strip_path | ||
strip_path = suffix_path.gsub(%r{^/}, '') | ||
strip_path.nil? || suffix_path = strip_path | ||
strip_entrypoint = entrypoint.gsub(%r{/$}, '') | ||
strip_path.nil? && strip_entrypoint = entrypoint | ||
strip_entrypoint = entrypoint.to_s.gsub(%r{/$}, '') |
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 think doing entrypoint = entrypoint.to_s
above here should eliminate need to do the to_s
conversions below.
@pilhuhn is is better to do |
strip_entrypoint = entrypoint.gsub(%r{/$}, '') | ||
strip_path.nil? && strip_entrypoint = entrypoint | ||
strip_path.nil? && strip_entrypoint = entrypoint.to_s |
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.
in line 143 entrypoint = entrypoint.to_s
is converted to string, do we need the .to_s
here ?
I checked in CM and this works fine :-) with and without this .to_s
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 need the to_s
as the entrypoint could be a URI::HTTP
(what you had originally) and without it the gsub()
in line 144 will error out as you have reported :)
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.
entrypoint could be a URI::HTTP
after line 143 entrypoint is string
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.
Now I get what you mean - sorry
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.
There is a to_s
in line 143 and other in line 145. I guess the later isn't needed, right?
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.
np. I checked it without the to_s
in line 145 and CM metrics wroks :-)
cc8a98d
to
709fe46
Compare
Ok, when Travis is happy, I will merge it and then release the 2.2.1 version of the gem and PR it on MiQ side |
Some normalization logic in 2.2.0 introduced a regression where URI:HTTP object were no longer accepted as input for entrypoints.
This pr checks for uri objects and converts them to string if needed.
@simon3z @yaacov