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
Fixes #28121 - Fix convert_string_to_bool to deal with Array #77
Conversation
see issue: #62 |
@orrabin , @ShimShtein please review :) |
523b88b
to
34b3c8d
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.
LGTM, I tested and no longer get the error with this PR.
lib/fog/ovirt/compute/v4.rb
Outdated
convert_string_to_bool(value) | ||
elsif value.is_a? Array | ||
value.map { |item| convert_string_to_bool(item) } | ||
if opts.is_a? Hash |
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.
def convert_string_to_bool(value)
case value
when "true"
return true
when "false"
return false
when Array
return value.map { |elem| convert_string_to_bool(elem) }
when Hash
value.each do |key, elem|
value[key] = convert_string_to_bool(elem)
end
return value
else
return value
end
end
thanks @ShimShtein, can you please review again :) ? |
merged, Thanks @shiramax! |
The PR fixes a bug in the convert_string_to_bool function. ATM the function It doesn't validate the data type of the item in value.map (when it's an array). It caused the same error. It happens when deploying a host to oVirt (from Foreman 1.23):
NoMethodError: undefined method
each' for #<Fog::Ovirt::Compute::Interface:0x007f0b76120628> /usr/share/foreman/vendor/ruby/2.3.0/gems/fog-ovirt-1.2.1/lib/fog/ovirt/compute/v4.rb:116:in
convert_string_to_bool'/usr/share/foreman/vendor/ruby/2.3.0/gems/fog-ovirt-1.2.1/lib/fog/ovirt/compute/v4.rb:124:in
block (2 levels) in convert_string_to_bool' /usr/share/foreman/vendor/ruby/2.3.0/gems/fog-core-2.1.0/lib/fog/core/collection.rb:18:in
map'/usr/share/foreman/vendor/ruby/2.3.0/gems/fog-core-2.1.0/lib/fog/core/collection.rb:18:in
map' /usr/share/foreman/vendor/ruby/2.3.0/gems/fog-ovirt-1.2.1/lib/fog/ovirt/compute/v4.rb:124:in
block in convert_string_to_bool'/usr/share/foreman/vendor/ruby/2.3.0/gems/fog-ovirt-1.2.1/lib/fog/ovirt/compute/v4.rb:116:in
each' /usr/share/foreman/vendor/ruby/2.3.0/gems/fog-ovirt-1.2.1/lib/fog/ovirt/compute/v4.rb:116:in
convert_string_to_bool'/usr/share/foreman/vendor/ruby/2.3.0/gems/fog-ovirt-1.2.1/lib/fog/ovirt/requests/compute/v4/update_vm.rb:9:in
update_vm' /usr/share/foreman/vendor/ruby/2.3.0/gems/fog-ovirt-1.2.1/lib/fog/ovirt/models/compute/server.rb:177:in
save'/usr/share/foreman/app/models/compute_resources/foreman/model/ovirt.rb:242:in `start_vm'