summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-03-06 16:06:04 -0800
committerTim Smith <tsmith84@gmail.com>2020-03-06 16:06:04 -0800
commite23fb9955df4657af4e6aace0c9b7316d5660da6 (patch)
treec690e834a9836ce1f3eb47189ef9bcf872ea11c8
parent5c64875047c594baa235f24dd19ad70ff3506a84 (diff)
downloadchef-e23fb9955df4657af4e6aace0c9b7316d5660da6.tar.gz
Make sure the ipv4 field is actually there
It's should be there, but we might as well Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/knife/core/node_presenter.rb2
-rw-r--r--lib/chef/knife/core/status_presenter.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb
index 23f8fd9815..be01b39728 100644
--- a/lib/chef/knife/core/node_presenter.rb
+++ b/lib/chef/knife/core/node_presenter.rb
@@ -95,7 +95,7 @@ class Chef
if data.is_a?(Chef::Node)
node = data
# special case clouds with their split horizon whatsis.
- ip = (node[:cloud] && node[:cloud][:public_ipv4_addrs].first) || node[:ipaddress]
+ ip = (node[:cloud] && node[:cloud][:public_ipv4_addrs] && node[:cloud][:public_ipv4_addrs].first) || node[:ipaddress]
summarized = <<~SUMMARY
#{ui.color("Node Name:", :bold)} #{ui.color(node.name, :bold)}
diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb
index 1b47eccc5d..32ea605e70 100644
--- a/lib/chef/knife/core/status_presenter.rb
+++ b/lib/chef/knife/core/status_presenter.rb
@@ -96,7 +96,7 @@ class Chef
list.each do |data|
node = data
# special case clouds with their split horizon whatsis.
- ip = (node[:cloud] && node[:cloud][:public_ipv4_addrs].first) || node[:ipaddress]
+ ip = (node[:cloud] && node[:cloud][:public_ipv4_addrs] && node[:cloud][:public_ipv4_addrs].first) || node[:ipaddress]
fqdn = (node[:cloud] && node[:cloud][:public_hostname]) || node[:fqdn]
name = node["name"] || node.name