From 9e95c82941ed5aac270cd3ffe8ffc76697a790f7 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Thu, 30 May 2019 18:19:27 -0700 Subject: [PATCH] Fix logic that chefstyle busted =) Signed-off-by: Miah Johnson --- lib/train/platforms/detect/helpers/os_common.rb | 5 +++-- lib/train/platforms/detect/helpers/os_windows.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/train/platforms/detect/helpers/os_common.rb b/lib/train/platforms/detect/helpers/os_common.rb index 880936c1..dc84ca98 100644 --- a/lib/train/platforms/detect/helpers/os_common.rb +++ b/lib/train/platforms/detect/helpers/os_common.rb @@ -95,13 +95,14 @@ def unix_uuid def unix_uuid_from_chef file = @backend.file("/var/chef/cache/data_collector_metadata.json") - if file.exist? && !file.size == 0 + if file.exist? && file.size != 0 json = ::JSON.parse(file.content) return json["node_uuid"] if json["node_uuid"] end end def unix_uuid_from_machine_file + # require 'pry';binding.pry %W{ /etc/chef/chef_guid #{ENV['HOME']}/.chef/chef_guid @@ -110,7 +111,7 @@ def unix_uuid_from_machine_file /var/db/dbus/machine-id }.each do |path| file = @backend.file(path) - next unless file.exist? && !file.size == 0 + next unless file.exist? && file.size != 0 return file.content.chomp if path =~ /guid/ return uuid_from_string(file.content.chomp) end diff --git a/lib/train/platforms/detect/helpers/os_windows.rb b/lib/train/platforms/detect/helpers/os_windows.rb index 7bb92268..dd7f38b5 100644 --- a/lib/train/platforms/detect/helpers/os_windows.rb +++ b/lib/train/platforms/detect/helpers/os_windows.rb @@ -91,7 +91,7 @@ def windows_uuid_from_machine_file #{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}\\.chef\\chef_guid }.each do |path| file = @backend.file(path) - return file.content.chomp if file.exist? && !file.size == 0 + return file.content.chomp if file.exist? && file.size != 0 end nil end