Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

Commit 4ba5ccd

Browse files
committed
Adding fedora support to GetOSVersion
1 parent e7fe0b2 commit 4ba5ccd

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

pkg/util/helpers_linux.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ package util
1717

1818
import (
1919
"fmt"
20-
"github.com/cobaugh/osrelease"
2120
"syscall"
2221
"time"
22+
23+
"github.com/cobaugh/osrelease"
2324
)
2425

2526
const (
@@ -55,6 +56,8 @@ func getOSVersion(osReleasePath string) (string, error) {
5556
return getDebianVersion(osReleaseMap), nil
5657
case "centos":
5758
return getDebianVersion(osReleaseMap), nil
59+
case "fedora":
60+
return getDebianVersion(osReleaseMap), nil
5861
case "rhel":
5962
return getDebianVersion(osReleaseMap), nil
6063
default:

pkg/util/helpers_linux_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ func TestGetOSVersionLinux(t *testing.T) {
5757
expectedOSVersion: "rhel 7.7 (Maipo)",
5858
expectErr: false,
5959
},
60+
{
61+
name: "fedora",
62+
fakeOSReleasePath: "testdata/os-release-fedora",
63+
expectedOSVersion: "35 (Thirty Five)",
64+
expectErr: false,
65+
},
6066
{
6167
name: "Unknown",
6268
fakeOSReleasePath: "testdata/os-release-unknown",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
NAME="Fedora Linux"
2+
VERSION="35 (Thirty Five)"
3+
ID=fedora
4+
VERSION_ID=35
5+
VERSION_CODENAME=""
6+
PLATFORM_ID="platform:f35"
7+
PRETTY_NAME="Fedora Linux 35 (Thirty Five)"
8+
ANSI_COLOR="0;38;2;60;110;180"
9+
LOGO=fedora-logo-icon
10+
CPE_NAME="cpe:/o:fedoraproject:fedora:35"
11+
HOME_URL="https://fedoraproject.org/"
12+
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f35/system-administrators-guide/"
13+
SUPPORT_URL="https://ask.fedoraproject.org/"
14+
BUG_REPORT_URL="https://bugzilla.redhat.com/"
15+
REDHAT_BUGZILLA_PRODUCT="Fedora"
16+
REDHAT_BUGZILLA_PRODUCT_VERSION=35
17+
REDHAT_SUPPORT_PRODUCT="Fedora"
18+
REDHAT_SUPPORT_PRODUCT_VERSION=35
19+
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"

0 commit comments

Comments
 (0)