diff options
author | Tim Smith <tsmith@chef.io> | 2020-06-22 22:24:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 22:24:06 -0700 |
commit | 5036b077fe6cb15645aa067df269f2476ed08663 (patch) | |
tree | ece6ef31c6bc3c1414e0a36710e025b96c1b9daa | |
parent | fd8167b01d6648f6751da3bc47f2d49bc621e0cc (diff) | |
parent | 57863cd6b274800cc4a1cd667d662e32a1d4464c (diff) | |
download | ohai-5036b077fe6cb15645aa067df269f2476ed08663.tar.gz |
Merge pull request #1470 from chef/big_sur
Make sure Darwin hosts are always mac_os_x
-rw-r--r-- | lib/ohai/plugins/darwin/hardware.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/darwin/platform.rb | 9 | ||||
-rw-r--r-- | spec/unit/plugins/darwin/platform_spec.rb | 26 |
3 files changed, 9 insertions, 30 deletions
diff --git a/lib/ohai/plugins/darwin/hardware.rb b/lib/ohai/plugins/darwin/hardware.rb index dab7957d..87535b27 100644 --- a/lib/ohai/plugins/darwin/hardware.rb +++ b/lib/ohai/plugins/darwin/hardware.rb @@ -41,8 +41,8 @@ Ohai.plugin(:Hardware) do hardware.merge!(hw_hash[0]["_items"][0]) # ProductName: Mac OS X - # ProductVersion: 10.12.5 - # BuildVersion: 16F73 + # ProductVersion: 10.15.6 + # BuildVersion: 19G46c shell_out("sw_vers").stdout.lines.each do |line| case line when /^ProductName:\s*(.*)$/ diff --git a/lib/ohai/plugins/darwin/platform.rb b/lib/ohai/plugins/darwin/platform.rb index 298b076b..6614822c 100644 --- a/lib/ohai/plugins/darwin/platform.rb +++ b/lib/ohai/plugins/darwin/platform.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,11 +23,6 @@ Ohai.plugin(:Platform) do so = shell_out((Ohai.abs_path( "/usr/bin/sw_vers" )).to_s) so.stdout.lines do |line| case line - when /^ProductName:\s+(.+)$/ - macname = $1 - macname.downcase! - macname.tr!(" ", "_") - platform macname when /^ProductVersion:\s+(.+)$/ platform_version $1 when /^BuildVersion:\s+(.+)$/ @@ -35,6 +30,8 @@ Ohai.plugin(:Platform) do end end + # if we're on darwin assume we're on mac_os_x + platform "mac_os_x" platform_family "mac_os_x" end end diff --git a/spec/unit/plugins/darwin/platform_spec.rb b/spec/unit/plugins/darwin/platform_spec.rb index ecd2c5f0..578b61c2 100644 --- a/spec/unit/plugins/darwin/platform_spec.rb +++ b/spec/unit/plugins/darwin/platform_spec.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,7 @@ describe Ohai::System, "Darwin plugin platform" do before do @plugin = get_plugin("darwin/platform") allow(@plugin).to receive(:collect_os).and_return(:darwin) - @stdout = "ProductName: Mac OS X\nProductVersion: 10.5.5\nBuildVersion: 9F33" + @stdout = "ProductName: Mac OS X\nProductVersion: 10.15.6\nBuildVersion: 19G46c" allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, "")) end @@ -38,34 +38,16 @@ describe Ohai::System, "Darwin plugin platform" do it "sets platform_version to ProductVersion" do @plugin.run - expect(@plugin[:platform_version]).to eq("10.5.5") + expect(@plugin[:platform_version]).to eq("10.15.6") end it "sets platform_build to BuildVersion" do @plugin.run - expect(@plugin[:platform_build]).to eq("9F33") + expect(@plugin[:platform_build]).to eq("19G46c") end it "sets platform_family to mac_os_x" do @plugin.run expect(@plugin[:platform_family]).to eq("mac_os_x") end - - describe "on os x server" do - before do - @plugin[:os] = "darwin" - @stdout = "ProductName: Mac OS X Server\nProductVersion: 10.6.8\nBuildVersion: 10K549" - allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, "")) - end - - it "sets platform to mac_os_x_server" do - @plugin.run - expect(@plugin[:platform]).to eq("mac_os_x_server") - end - - it "sets platform_family to mac_os_x" do - @plugin.run - expect(@plugin[:platform_family]).to eq("mac_os_x") - end - end end |