summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordidier Belot <electrolinux@gmail.com>2015-12-17 22:39:11 +0100
committerdidier Belot <electrolinux@gmail.com>2015-12-17 22:39:11 +0100
commit278ca2c09ceb1bf9814c741970e44faa28b9b796 (patch)
tree294ea52f0c9df43a95bc9746804337a50150edf4
parentb8d2b39cfd46307090f527e98d1cf641a452888b (diff)
downloadohai-278ca2c09ceb1bf9814c741970e44faa28b9b796.tar.gz
Adding a new "alpine" platform and platform_family
-rw-r--r--lib/ohai/plugins/linux/platform.rb5
-rw-r--r--spec/unit/plugins/linux/platform_spec.rb19
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb
index 659d69fd..0a8406d8 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")
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 025ea223..9306ebcd 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 }