1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/pkg/parsers/operatingsystem/operatingsystem_windows.go
John Howard 29f93c4bc7 Windows: Move kernel_windows to use golang registry functions
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-03-16 09:47:45 -07:00

51 lines
1.1 KiB
Go

package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem"
import (
"fmt"
"golang.org/x/sys/windows/registry"
)
// GetOperatingSystem gets the name of the current operating system.
func GetOperatingSystem() (string, error) {
// Default return value
ret := "Unknown Operating System"
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
if err != nil {
return ret, err
}
defer k.Close()
pn, _, err := k.GetStringValue("ProductName")
if err != nil {
return ret, err
}
ret = pn
ri, _, err := k.GetStringValue("ReleaseId")
if err != nil {
return ret, err
}
ret = fmt.Sprintf("%s Version %s", ret, ri)
cbn, _, err := k.GetStringValue("CurrentBuildNumber")
if err != nil {
return ret, err
}
ubr, _, err := k.GetIntegerValue("UBR")
if err != nil {
return ret, err
}
ret = fmt.Sprintf("%s (OS Build %s.%d)", ret, cbn, ubr)
return ret, nil
}
// IsContainerized returns true if we are running inside a container.
// No-op on Windows, always returns false.
func IsContainerized() (bool, error) {
return false, nil
}