Commit 9de5dc24 authored by Milos Gajdos's avatar Milos Gajdos Committed by Bryan McLellan
Browse files

CHEF-3484: Modified configure_session method to skip nil items in loop

If we don't skip nil items then the if condition fails with No Method error.
ie if !config[:override_attribute] && nil[:cloud] &&
nil[:cloud][:public_hostname] is obviously nonsense
parent 92de5f30
......@@ -124,6 +124,8 @@ class Chef
q = Chef::Search::Query.new
@action_nodes = q.search(:node, @name_args[0])[0]
@action_nodes.each do |item|
# we should skip the loop to next iteration if the item returned by the search is nil
next if item.nil?
# if a command line attribute was not passed, and we have a cloud public_hostname, use that.
# see #configure_attribute for the source of config[:attribute] and config[:override_attribute]
if !config[:override_attribute] && item[:cloud] and item[:cloud][:public_hostname]
......@@ -133,7 +135,8 @@ class Chef
else
i = format_for_display(item)[config[:attribute]]
end
r.push(i) unless i.nil?
# we no longer need a check for nil as we are skipping nil items
r.push(i)
end
r
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment