Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was, erm, curious where all the extra dependencies originated from 🙈;
github.com/tklauser/go-sysconf
github.com/tklauser/go-sysconf
(number of online CPUs?)github.com/shoenig/go-m1cpu
(CPU info for m1 CPUs)github.com/power-devops/perfstat
(handling oflibperfstat
??github.com/go-ole/go-ole
(loading of Windows OLE objects)github.com/yusufpapurcu/wmi
(WQL interface to Windows Management Instrumentation (WMI))And those all look to be related to this single
host.Info()
;gopsutil/host.Info()
is doing a lot of things; https://github.com/shirou/gopsutil/blob/865b8c3f58d6ee4c47dab074fbf3c4b037abfd96/host/host.go#L65-L117/etc/os-release
and more; https://github.com/shirou/gopsutil/blob/865b8c3f58d6ee4c47dab074fbf3c4b037abfd96/host/host_linux.go#L173-L321sw_vers -productVersion
https://github.com/shirou/gopsutil/blob/865b8c3f58d6ee4c47dab074fbf3c4b037abfd96/host/host_darwin.go#L98-L124unix.Utsname
, but on Windows involves parsing processor architectures; https://github.com/shirou/gopsutil/blob/865b8c3f58d6ee4c47dab074fbf3c4b037abfd96/host/host_windows.go#L251-L280/etc/os-release
; enough for the library author to implement caching, but that won't do much for a short-lived process like the CLI; https://github.com/shirou/gopsutil/blob/865b8c3f58d6ee4c47dab074fbf3c4b037abfd96/internal/common/common_linux.go#L168-L346BootTime
, andUpTime
, which again do a lot, including shelling out to various binaries, and it even has special cases fordocker
; caching was implemented there as well, but won't help us here; https://github.com/shirou/gopsutil/blob/865b8c3f58d6ee4c47dab074fbf3c4b037abfd96/internal/common/common_linux.go#L63-L119/proc
, and for each of them trying to see if it can convert them to an Integer (in which case it's a process-id); https://github.com/shirou/gopsutil/blob/865b8c3f58d6ee4c47dab074fbf3c4b037abfd96/internal/common/common_linux.go#L41-L61HostID
(sys/kernel/random/boot_id
, on Linux, but shelling out toioreg -rd1 -c IOPlatformExpertDevice
on Darwin, and using the registry on Windows)So I went looking "What information do we really need here?"
cliVersion
-hostinfo.OS
- this is hardcoded toruntime.GOOS
ingopsutil/host.Info()
hostVersion
- this comes fromPlatformVersion
. Is it a strong requirement to know the version of the OS? On Linux it will be useless without distro. On Windows, it will be "guesswork" (no official API); if really needed, we could also usepkg/parsers/kernel.GetKernelVersion()
from the docker code.hostinfo.KernelArch
- do we need detailed architecture (including CPU sub-variants), which could even be "off" when running with QEMU emulation; could we useruntime.GOARCH
instead?Can we get rid of this dependency, and replace
host.Info()
with something more basic?- A picture of a cute animal (not mandatory but encouraged)