gets also ubuntu version

There are differences between Ubuntu 16 and Ubuntu 18 features so the system needs to know the specific version
This commit is contained in:
yoavrotems 2019-05-21 19:19:49 +03:00 committed by GitHub
parent 8fc2a4643b
commit 43081d61f2
Failed to generate hash of commit

View file

@ -104,11 +104,16 @@ func GetLSM() (lsm string, err error) {
func getPlatformVersion(output, platform string) string {
flagRe := regexp.MustCompile("version_id" + `=([^ \n]*)`)
vals := flagRe.FindStringSubmatch(output)
if vals == nil {
flagRe := regexp.MustCompile("version" + `=([^ \n]*)`)
vals = flagRe.FindStringSubmatch(output)
}
if len(vals) > 1 {
switch platform {
case "rhel":
return vals[1][:1] // Get the major version only, examaple: 7.6 will return 7
case "ubuntu":
return vals[1][:2] // Get the major version only, examaple: 18.04 will return 18
default:
return ""
}