fix(centos): identify CentOS and CentOS Stream (#1360)

This commit is contained in:
MaineK00n
2022-02-03 05:32:03 +09:00
committed by GitHub
parent 7c209cc9dc
commit 2923cbc645
7 changed files with 86 additions and 47 deletions

View File

@@ -300,11 +300,17 @@ func (l Distro) String() string {
// MajorVersion returns Major version
func (l Distro) MajorVersion() (int, error) {
if l.Family == constant.Amazon {
switch l.Family {
case constant.Amazon:
return strconv.Atoi(getAmazonLinuxVersion(l.Release))
}
if 0 < len(l.Release) {
return strconv.Atoi(strings.Split(l.Release, ".")[0])
case constant.CentOS:
if 0 < len(l.Release) {
return strconv.Atoi(strings.Split(strings.TrimPrefix(l.Release, "stream"), ".")[0])
}
default:
if 0 < len(l.Release) {
return strconv.Atoi(strings.Split(l.Release, ".")[0])
}
}
return 0, xerrors.New("Release is empty")
}