summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-11-26 22:03:48 -0800
committerTim Smith <tsmith@chef.io>2018-11-26 22:03:48 -0800
commit35c73dfc176756b90c5145d121bb0437f13d22f8 (patch)
treec9972e407b3e18f5d2b2d10357f76a0a60a27b51
parente1fe9b9ef0d2823d4aedb04b1693a591540a3ea9 (diff)
downloadohai-os_release_detection.tar.gz
Move clearlinux back to the legacy methodos_release_detection
It's os-release file is not in a standard location Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/linux/platform.rb3
-rw-r--r--spec/unit/plugins/linux/platform_spec.rb60
2 files changed, 25 insertions, 38 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb
index fb620ea7..96beb4cf 100644
--- a/lib/ohai/plugins/linux/platform.rb
+++ b/lib/ohai/plugins/linux/platform.rb
@@ -32,7 +32,6 @@ Ohai.plugin(:Platform) do
"opensuse-leap" => "opensuseleap",
"xenenterprise" => "xenserver",
"cumulus-linux" => "cumulus",
- "clear-linux-os" => "clearlinux",
}.freeze
end
@@ -260,7 +259,7 @@ Ohai.plugin(:Platform) do
platform_version shell_out("/bin/uname -r").stdout.strip
elsif File.exist?("/usr/lib/os-release")
contents = File.read("/usr/lib/os-release")
- if /Clear Linux/ =~ contents
+ if /clear-linux-os/ =~ contents # Clear Linux https://clearlinux.org/
platform "clearlinux"
platform_version contents[/VERSION_ID=(\d+)/, 1]
end
diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb
index 8fbd39f9..5560fc84 100644
--- a/spec/unit/plugins/linux/platform_spec.rb
+++ b/spec/unit/plugins/linux/platform_spec.rb
@@ -109,10 +109,6 @@ describe Ohai::System, "Linux plugin platform" do
expect(plugin.platform_id_remap("cumulus-linux")).to eq("cumulus")
end
- it "returns clearlinux for clear-linux-os os-release id" do
- expect(plugin.platform_id_remap("clear-linux-os")).to eq("clearlinux")
- end
-
it "does not transformation for any other platform" do
expect(plugin.platform_id_remap("ubuntu")).to eq("ubuntu")
end
@@ -688,38 +684,6 @@ OS_DATA
end
describe "on suse" do
- context "on openSUSE 15+" do
-
- let(:have_suse_release) { false }
- let(:have_os_release) { true }
-
- let(:os_release_content) do
- <<~OS_RELEASE
- NAME="openSUSE Leap"
- VERSION="15.0"
- ID="opensuse-leap"
- ID_LIKE="suse opensuse"
- VERSION_ID="15.0"
- PRETTY_NAME="openSUSE Leap 15.0"
- ANSI_COLOR="0;32"
- CPE_NAME="cpe:/o:opensuse:leap:15.0"
- OS_RELEASE
- end
-
- before do
- expect(File).to_not receive(:read).with("/etc/SuSE-release")
- expect(File).to receive(:read).with("/etc/os-release").and_return(os_release_content)
- end
-
- it "correctly detects opensuseleap 15" do
- plugin.run
- expect(plugin[:platform]).to eq("opensuseleap")
- expect(plugin[:platform_version]).to eq("15.0")
- expect(plugin[:platform_family]).to eq("suse")
- end
-
- end
-
context "on versions that have no /etc/os-release but /etc/SuSE-release (e.g. SLES12.1)" do
let(:have_suse_release) { true }
let(:have_os_release) { false }
@@ -794,5 +758,29 @@ OS_DATA
end
end
end
+
+ describe "on clearlinux" do
+ let(:have_usr_lib_os_release) { true }
+ let(:usr_lib_os_release_content) do
+ <<~CLEARLINUX_RELEASE
+ NAME="Clear Linux OS"
+ VERSION=1
+ ID=clear-linux-os
+ ID_LIKE=clear-linux-os
+ VERSION_ID=26290
+ PRETTY_NAME="Clear Linux OS"
+ CLEARLINUX_RELEASE
+ end
+ before do
+ expect(File).to receive(:read).with("/usr/lib/os-release").and_return(usr_lib_os_release_content)
+ end
+ it "should set platform to clearlinux and platform_family to clearlinux" do
+ plugin.lsb = nil
+ plugin.run
+ expect(plugin[:platform]).to eq("clearlinux")
+ expect(plugin[:platform_family]).to eq("clearlinux")
+ expect(plugin[:platform_version]).to eq("26290")
+ end
+ end
end
end