Skip to content

Commit 3ace8c2

Browse files
authored
Merge pull request #379 from CuZn13/master
add a case is ID="centos"
2 parents e218562 + d5cb446 commit 3ace8c2

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
@@ -89,6 +89,8 @@ func GetOSVersion() (string, error) {
8989
return getDebianVersion(osReleaseMap), nil
9090
case "ubuntu":
9191
return getDebianVersion(osReleaseMap), nil
92+
case "centos":
93+
return getDebianVersion(osReleaseMap), nil
9294
default:
9395
return "", fmt.Errorf("Unsupported ID in /etc/os-release: %q", osReleaseMap["ID"])
9496
}

pkg/util/helpers_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ func TestGetOSVersion(t *testing.T) {
161161
expectedOSVersion: "ubuntu 16.04.6 LTS (Xenial Xerus)",
162162
expectErr: false,
163163
},
164+
{
165+
name: "centos",
166+
fakeOSReleasePath: "testdata/os-release-centos",
167+
expectedOSVersion: "centos 7 (Core)",
168+
expectErr: false,
169+
},
164170
{
165171
name: "Unknown",
166172
fakeOSReleasePath: "testdata/os-release-unknown",

pkg/util/testdata/os-release-centos

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
NAME="CentOS Linux"
2+
VERSION="7 (Core)"
3+
ID="centos"
4+
ID_LIKE="rhel fedora"
5+
VERSION_ID="7"
6+
PRETTY_NAME="CentOS Linux 7 (Core)"
7+
ANSI_COLOR="0;31"
8+
CPE_NAME="cpe:/o:centos:centos:7"
9+
HOME_URL="https://www.centos.org/"
10+
BUG_REPORT_URL="https://bugs.centos.org/"
11+
12+
CENTOS_MANTISBT_PROJECT="CentOS-7"
13+
CENTOS_MANTISBT_PROJECT_VERSION="7"
14+
REDHAT_SUPPORT_PRODUCT="centos"
15+
REDHAT_SUPPORT_PRODUCT_VERSION="7"

0 commit comments

Comments
 (0)