From 2454e010d591857302127c425ad9b2a3e86810a6 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Wed, 1 Jun 2022 09:46:33 -0400 Subject: [PATCH] Add Oracle Linux to the RedHat OS family Added the Oracle Linux ("ol") platform to "redhat" OS family. Fixes #54 --- CHANGELOG.md | 1 + providers/linux/os.go | 2 +- providers/linux/os_test.go | 16 ++++++++++++++++ .../testdata/oraclelinux7/etc/oracle-release | 1 + .../linux/testdata/oraclelinux7/etc/os-release | 17 +++++++++++++++++ .../testdata/oraclelinux7/etc/redhat-release | 1 + .../testdata/oraclelinux7/etc/system-release | 1 + 7 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 providers/linux/testdata/oraclelinux7/etc/oracle-release create mode 100644 providers/linux/testdata/oraclelinux7/etc/os-release create mode 100644 providers/linux/testdata/oraclelinux7/etc/redhat-release create mode 120000 providers/linux/testdata/oraclelinux7/etc/system-release diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f8106de..d523c943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Added the Oracle Linux ("ol") platform to "redhat" OS family. [#54](https://github.com/elastic/go-sysinfo/issues/54) [#115](https://github.com/elastic/go-sysinfo/pull/115) - Updated module to require Go 1.17. [#111](https://github.com/elastic/go-sysinfo/pull/111) ### Deprecated diff --git a/providers/linux/os.go b/providers/linux/os.go index cb172c01..19ff00c0 100644 --- a/providers/linux/os.go +++ b/providers/linux/os.go @@ -50,7 +50,7 @@ var ( // familyMap contains a mapping of family -> []platforms. var familyMap = map[string][]string{ - "redhat": {"redhat", "fedora", "centos", "scientific", "oraclelinux", "amzn", "rhel"}, + "redhat": {"redhat", "fedora", "centos", "scientific", "oraclelinux", "ol", "amzn", "rhel"}, "debian": {"debian", "ubuntu", "raspbian"}, "suse": {"suse", "sles", "opensuse"}, } diff --git a/providers/linux/os_test.go b/providers/linux/os_test.go index bff5f9c5..e6c3c937 100644 --- a/providers/linux/os_test.go +++ b/providers/linux/os_test.go @@ -148,6 +148,22 @@ func TestOperatingSystem(t *testing.T) { }, *os) t.Logf("%#v", os) }) + t.Run("oraclelinux7", func(t *testing.T) { + os, err := getOSInfo("testdata/oraclelinux7") + if err != nil { + t.Fatal(err) + } + assert.Equal(t, types.OSInfo{ + Type: "linux", + Family: "redhat", + Platform: "ol", + Name: "Oracle Linux Server", + Version: "7.9", + Major: 7, + Minor: 9, + }, *os) + t.Logf("%#v", os) + }) t.Run("ubuntu1404", func(t *testing.T) { os, err := getOSInfo("testdata/ubuntu1404") if err != nil { diff --git a/providers/linux/testdata/oraclelinux7/etc/oracle-release b/providers/linux/testdata/oraclelinux7/etc/oracle-release new file mode 100644 index 00000000..1c416874 --- /dev/null +++ b/providers/linux/testdata/oraclelinux7/etc/oracle-release @@ -0,0 +1 @@ +Oracle Linux Server release 7.9 diff --git a/providers/linux/testdata/oraclelinux7/etc/os-release b/providers/linux/testdata/oraclelinux7/etc/os-release new file mode 100644 index 00000000..f8823a8e --- /dev/null +++ b/providers/linux/testdata/oraclelinux7/etc/os-release @@ -0,0 +1,17 @@ +NAME="Oracle Linux Server" +VERSION="7.9" +ID="ol" +ID_LIKE="fedora" +VARIANT="Server" +VARIANT_ID="server" +VERSION_ID="7.9" +PRETTY_NAME="Oracle Linux Server 7.9" +ANSI_COLOR="0;31" +CPE_NAME="cpe:/o:oracle:linux:7:9:server" +HOME_URL="https://linux.oracle.com/" +BUG_REPORT_URL="https://bugzilla.oracle.com/" + +ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7" +ORACLE_BUGZILLA_PRODUCT_VERSION=7.9 +ORACLE_SUPPORT_PRODUCT="Oracle Linux" +ORACLE_SUPPORT_PRODUCT_VERSION=7.9 diff --git a/providers/linux/testdata/oraclelinux7/etc/redhat-release b/providers/linux/testdata/oraclelinux7/etc/redhat-release new file mode 100644 index 00000000..db5baab4 --- /dev/null +++ b/providers/linux/testdata/oraclelinux7/etc/redhat-release @@ -0,0 +1 @@ +Red Hat Enterprise Linux Server release 7.9 (Maipo) diff --git a/providers/linux/testdata/oraclelinux7/etc/system-release b/providers/linux/testdata/oraclelinux7/etc/system-release new file mode 120000 index 00000000..b5cb9bdc --- /dev/null +++ b/providers/linux/testdata/oraclelinux7/etc/system-release @@ -0,0 +1 @@ +oracle-release \ No newline at end of file