in providers/linux/os.go [156:200]
func makeOSInfo(osRelease map[string]string) (*types.OSInfo, error) {
os := &types.OSInfo{
Type: "linux",
Platform: firstOf(osRelease, "ID", "DISTRIB_ID"),
Name: firstOf(osRelease, "NAME", "PRETTY_NAME"),
Version: firstOf(osRelease, "VERSION", "VERSION_ID", "DISTRIB_RELEASE"),
Build: osRelease["BUILD_ID"],
Codename: firstOf(osRelease, "VERSION_CODENAME", "DISTRIB_CODENAME"),
}
if os.Codename == "" {
// Some OSes use their own CODENAME keys (e.g UBUNTU_CODENAME).
for k, v := range osRelease {
if strings.Contains(k, "CODENAME") {
os.Codename = v
break
}
}
}
if os.Platform == "" {
// Fallback to the first word of the Name field.
os.Platform, _, _ = strings.Cut(os.Name, " ")
}
os.Family = linuxFamily(os.Platform)
if os.Family == "" {
// ID_LIKE is a space-separated list of OS identifiers that this
// OS is similar to. Use this to figure out the Linux family.
for _, id := range strings.Fields(osRelease["ID_LIKE"]) {
os.Family = linuxFamily(id)
if os.Family != "" {
break
}
}
}
if osRelease["ID_LIKE"] == "suse" {
extractVersionDetails(os, os.Version, versionRegexpSuse)
} else if os.Version != "" {
extractVersionDetails(os, os.Version, versionRegexp)
}
return os, nil
}