Fixed CentOS minor version issue by looking for /etc/centos-release file first
@@ -31,6 +31,7 @@ import (
const (
osReleaseFile = "/etc/os-release"
systemReleaseFile = "/etc/system-release"
+ centosReleaseFile = "/etc/centos-release"
redhatReleaseFile = "/etc/redhat-release"
unameCommand = "/usr/bin/uname"
lsbReleaseCommand = "lsb_release"
@@ -69,7 +70,25 @@ func getPlatformDetails(log log.T) (name string, version string, err error) {
name = notAvailableMessage
version = notAvailableMessage
- if fileutil.Exists(osReleaseFile) {
+ if fileutil.Exists(centosReleaseFile) {
+ // CentOS has incomplete information in the osReleaseFile
+ // and there fore needs to be before osReleaseFile exist check
+ log.Debugf(fetchingDetailsMessage, centosReleaseFile)
+ contents, err = fileutil.ReadAllText(centosReleaseFile)
+ log.Debugf(commandOutputMessage, contents)
+
+ if err != nil {
+ log.Debugf(errorOccurredMessage, centosReleaseFile, err)
+ return
+ }
+
+ if strings.Contains(contents, "CentOS") {
+ data := strings.Split(contents, "release")
+ name = strings.TrimSpace(data[0])
+ versionData := strings.Split(data[1], "(")
+ version = strings.TrimSpace(versionData[0])
+ }
+ } else if fileutil.Exists(osReleaseFile) {
log.Debugf(fetchingDetailsMessage, osReleaseFile)
contents := new(osRelease)
