Skip to content

Commit 1d03b66

Browse files
authored
Merge pull request #424 from stpabhi/rhel-support
Add rhel support for osversion
2 parents 20e0147 + 5342a50 commit 1d03b66

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

pkg/util/helpers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ func GetOSVersion() (string, error) {
9191
return getDebianVersion(osReleaseMap), nil
9292
case "centos":
9393
return getDebianVersion(osReleaseMap), nil
94+
case "rhel":
95+
return getDebianVersion(osReleaseMap), nil
9496
default:
9597
return "", fmt.Errorf("Unsupported ID in /etc/os-release: %q", osReleaseMap["ID"])
9698
}

pkg/util/helpers_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ func TestGetOSVersion(t *testing.T) {
167167
expectedOSVersion: "centos 7 (Core)",
168168
expectErr: false,
169169
},
170+
{
171+
name: "rhel",
172+
fakeOSReleasePath: "testdata/os-release-rhel",
173+
expectedOSVersion: "rhel 7.7 (Maipo)",
174+
expectErr: false,
175+
},
170176
{
171177
name: "Unknown",
172178
fakeOSReleasePath: "testdata/os-release-unknown",

pkg/util/testdata/os-release-rhel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
NAME="Red Hat Enterprise Linux Server"
2+
VERSION="7.7 (Maipo)"
3+
ID="rhel"
4+
ID_LIKE="fedora"
5+
VERSION_ID="7.7"
6+
PRETTY_NAME="Red Hat Enterprise Linux Server 7.7 (Maipo)"
7+
ANSI_COLOR="0;31"
8+
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.7:GA:server"
9+
HOME_URL="https://www.redhat.com/"
10+
BUG_REPORT_URL="https://bugzilla.redhat.com/"
11+
12+
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
13+
REDHAT_BUGZILLA_PRODUCT_VERSION=7.7
14+
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
15+
REDHAT_SUPPORT_PRODUCT_VERSION="7.7"

0 commit comments

Comments
 (0)