diff options
author | Thom May <thom@may.lt> | 2016-01-19 18:45:18 +0000 |
---|---|---|
committer | Thom May <thom@may.lt> | 2016-01-19 18:45:18 +0000 |
commit | 2faaaf6ae1c7dd735137f34833f46838d9bb6169 (patch) | |
tree | 402ae4dfdf7e160ad9340420ce7ab3a27827b53d | |
parent | 1535dd6f0fb69467556c9fc5a79adb7359abd6c8 (diff) | |
parent | a695773fcb7ccf3bb2b8a85e84b04ff3baf985df (diff) | |
download | ohai-2faaaf6ae1c7dd735137f34833f46838d9bb6169.tar.gz |
Merge pull request #688 from electrolinux/alpine_family
Adding a new "alpine" platform and platform_family
-rw-r--r-- | lib/ohai/plugins/linux/platform.rb | 5 | ||||
-rw-r--r-- | spec/unit/plugins/linux/platform_spec.rb | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb index d9835a2a..6a655b85 100644 --- a/lib/ohai/plugins/linux/platform.rb +++ b/lib/ohai/plugins/linux/platform.rb @@ -142,6 +142,9 @@ Ohai.plugin(:Platform) do # no way to determine platform_version in a rolling release distribution # kernel release will be used - ex. 3.13 platform_version `uname -r`.strip + elsif File.exist?('/etc/alpine-release') + platform "alpine" + platform_version File.read("/etc/alpine-release").strip() elsif os_release_file_is_cisco? raise 'unknown Cisco /etc/os-release or /etc/cisco-release ID_LIKE field' if os_release_info['ID_LIKE'].nil? || ! os_release_info['ID_LIKE'].include?('wrlinux') @@ -191,6 +194,8 @@ Ohai.plugin(:Platform) do platform_family "arch" when /exherbo/ platform_family "exherbo" + when /alpine/ + platform_family "alpine" end end end diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index 9ff73b94..bae9af29 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -26,6 +26,7 @@ describe Ohai::System, "Linux plugin platform" do let(:have_redhat_release) { false } let(:have_gentoo_release) { false } let(:have_exherbo_release) { false } + let(:have_alpine_release) { false } let(:have_suse_release) { false } let(:have_arch_release) { false } let(:have_system_release) { false } @@ -45,6 +46,7 @@ describe Ohai::System, "Linux plugin platform" do allow(File).to receive(:exist?).with("/etc/redhat-release").and_return(have_redhat_release) allow(File).to receive(:exist?).with("/etc/gentoo-release").and_return(have_gentoo_release) allow(File).to receive(:exist?).with("/etc/exherbo-release").and_return(have_exherbo_release) + allow(File).to receive(:exist?).with("/etc/alpine-release").and_return(have_alpine_release) allow(File).to receive(:exist?).with("/etc/SuSE-release").and_return(have_suse_release) allow(File).to receive(:exist?).with("/etc/arch-release").and_return(have_arch_release) allow(File).to receive(:exist?).with("/etc/system-release").and_return(have_system_release) @@ -223,6 +225,23 @@ describe Ohai::System, "Linux plugin platform" do end end + describe "on alpine" do + + let(:have_alpine_release) { true } + + before(:each) do + @plugin.lsb = nil + end + + it "should set platform and platform_family to alpine" do + expect(File).to receive(:read).with("/etc/alpine-release").and_return("3.2.3") + @plugin.run + expect(@plugin[:platform]).to eq("alpine") + expect(@plugin[:platform_family]).to eq("alpine") + expect(@plugin[:platform_version]).to eq('3.2.3') + end + end + describe "on exherbo" do let(:have_exherbo_release) { true } |