Skip to content

Commit

Permalink
Add rhel support for osversion
Browse files Browse the repository at this point in the history
  • Loading branch information
stpabhi committed Apr 15, 2020
1 parent 20e0147 commit 11cf049
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/util/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/util/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions pkg/util/testdata/os-release-rhel
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 11cf049

Please sign in to comment.