AddPlatformInfo adds OS and platform information.
(ctx context.Context)
| 11 | |
| 12 | // AddPlatformInfo adds OS and platform information. |
| 13 | func (di *Info) AddPlatformInfo(ctx context.Context) { |
| 14 | // Get information from the system. |
| 15 | info, err := host.InfoWithContext(ctx) |
| 16 | if err != nil { |
| 17 | di.AddSection( |
| 18 | "Platform Information", |
| 19 | NoFlags, |
| 20 | fmt.Sprintf("Failed to get: %s", err), |
| 21 | ) |
| 22 | return |
| 23 | } |
| 24 | |
| 25 | // Check if we want to add virtulization information. |
| 26 | var virtInfo string |
| 27 | if info.VirtualizationRole == "guest" { |
| 28 | if info.VirtualizationSystem != "" { |
| 29 | virtInfo = fmt.Sprintf("VM: %s", info.VirtualizationSystem) |
| 30 | } else { |
| 31 | virtInfo = "VM: unidentified" |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | // Add section. |
| 36 | di.AddSection( |
| 37 | fmt.Sprintf("Platform: %s %s", info.Platform, info.PlatformVersion), |
| 38 | UseCodeSection|AddContentLineBreaks, |
| 39 | fmt.Sprintf("System: %s %s (%s) %s", info.Platform, info.OS, info.PlatformFamily, info.PlatformVersion), |
| 40 | fmt.Sprintf("Kernel: %s %s", info.KernelVersion, info.KernelArch), |
| 41 | virtInfo, |
| 42 | ) |
| 43 | } |
no test coverage detected