Merge pull request #11556 from afbjorklund/distribution-info

Show variant and codename of the distribution
This commit is contained in:
OpenShift Merge Robot 2021-09-15 06:25:00 -04:00 committed by GitHub
commit 4dd7bfdfaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -42,6 +42,7 @@ host:
cpus: 8 cpus: 8
distribution: distribution:
distribution: fedora distribution: fedora
variant: workstation
version: "34" version: "34"
eventLogger: journald eventLogger: journald
hostname: localhost.localdomain hostname: localhost.localdomain

View File

@ -78,7 +78,9 @@ type IDMappings struct {
// for libpod // for libpod
type DistributionInfo struct { type DistributionInfo struct {
Distribution string `json:"distribution"` Distribution string `json:"distribution"`
Variant string `json:"variant,omitempty"`
Version string `json:"version"` Version string `json:"version"`
Codename string `json:"codename,omitempty"`
} }
// ConmonInfo describes the conmon executable being used // ConmonInfo describes the conmon executable being used

View File

@ -370,9 +370,15 @@ func (r *Runtime) GetHostDistributionInfo() define.DistributionInfo {
if strings.HasPrefix(l.Text(), "ID=") { if strings.HasPrefix(l.Text(), "ID=") {
dist.Distribution = strings.TrimPrefix(l.Text(), "ID=") dist.Distribution = strings.TrimPrefix(l.Text(), "ID=")
} }
if strings.HasPrefix(l.Text(), "VARIANT_ID=") {
dist.Variant = strings.Trim(strings.TrimPrefix(l.Text(), "VARIANT_ID="), "\"")
}
if strings.HasPrefix(l.Text(), "VERSION_ID=") { if strings.HasPrefix(l.Text(), "VERSION_ID=") {
dist.Version = strings.Trim(strings.TrimPrefix(l.Text(), "VERSION_ID="), "\"") dist.Version = strings.Trim(strings.TrimPrefix(l.Text(), "VERSION_ID="), "\"")
} }
if strings.HasPrefix(l.Text(), "VERSION_CODENAME=") {
dist.Codename = strings.Trim(strings.TrimPrefix(l.Text(), "VERSION_CODENAME="), "\"")
}
} }
return dist return dist
} }