From 11cf049c5f354062cc0179cae819d8907805bf63 Mon Sep 17 00:00:00 2001 From: Abhilash Pallerlamudi Date: Wed, 15 Apr 2020 12:14:29 -0700 Subject: [PATCH] Add rhel support for osversion --- pkg/util/helpers.go | 2 ++ pkg/util/helpers_test.go | 6 ++++++ pkg/util/testdata/os-release-rhel | 15 +++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 pkg/util/testdata/os-release-rhel diff --git a/pkg/util/helpers.go b/pkg/util/helpers.go index 84cba0a92..25f9d6b7b 100644 --- a/pkg/util/helpers.go +++ b/pkg/util/helpers.go @@ -91,6 +91,8 @@ func GetOSVersion() (string, error) { return getDebianVersion(osReleaseMap), nil case "centos": return getDebianVersion(osReleaseMap), nil + case "rhel": + return getDebianVersion(osReleaseMap), nil default: return "", fmt.Errorf("Unsupported ID in /etc/os-release: %q", osReleaseMap["ID"]) } diff --git a/pkg/util/helpers_test.go b/pkg/util/helpers_test.go index 7e7d84d1f..82ea1804f 100644 --- a/pkg/util/helpers_test.go +++ b/pkg/util/helpers_test.go @@ -167,6 +167,12 @@ func TestGetOSVersion(t *testing.T) { expectedOSVersion: "centos 7 (Core)", expectErr: false, }, + { + name: "rhel", + fakeOSReleasePath: "testdata/os-release-rhel", + expectedOSVersion: "7.7 (Maipo)", + expectErr: false, + }, { name: "Unknown", fakeOSReleasePath: "testdata/os-release-unknown", diff --git a/pkg/util/testdata/os-release-rhel b/pkg/util/testdata/os-release-rhel new file mode 100644 index 000000000..8c934d2f6 --- /dev/null +++ b/pkg/util/testdata/os-release-rhel @@ -0,0 +1,15 @@ +NAME="Red Hat Enterprise Linux Server" +VERSION="7.7 (Maipo)" +ID="rhel" +ID_LIKE="fedora" +VERSION_ID="7.7" +PRETTY_NAME="Red Hat Enterprise Linux Server 7.7 (Maipo)" +ANSI_COLOR="0;31" +CPE_NAME="cpe:/o:redhat:enterprise_linux:7.7:GA:server" +HOME_URL="https://www.redhat.com/" +BUG_REPORT_URL="https://bugzilla.redhat.com/" + +REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7" +REDHAT_BUGZILLA_PRODUCT_VERSION=7.7 +REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux" +REDHAT_SUPPORT_PRODUCT_VERSION="7.7" \ No newline at end of file