diff options
author | Milos Gajdos <milosgajdos83@gmail.com> | 2012-09-27 23:24:47 +0100 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2012-10-11 11:39:02 -0700 |
commit | 9de5dc24bb340752f12471e04c5f1404418030da (patch) | |
tree | 0e3c2a7f8bd6fdb303d60a95a8100a58c13d3c80 | |
parent | 92de5f30626fafc539082f49b6e829cbb71d30e3 (diff) | |
download | chef-9de5dc24bb340752f12471e04c5f1404418030da.tar.gz |
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
-rw-r--r-- | chef/lib/chef/knife/ssh.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/chef/lib/chef/knife/ssh.rb b/chef/lib/chef/knife/ssh.rb index 4ef408ddf9..c210d158f5 100644 --- a/chef/lib/chef/knife/ssh.rb +++ b/chef/lib/chef/knife/ssh.rb @@ -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 |