Merge pull request #21272 from Microsoft/jstarks/manifest_updates
Add os_version and os_features to Image
This commit is contained in:
commit
3f3ba02798
3 changed files with 27 additions and 8 deletions
|
@ -1,11 +1,14 @@
|
||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ntuserApiset = syscall.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0")
|
||||||
|
)
|
||||||
|
|
||||||
// OSVersion is a wrapper for Windows version information
|
// OSVersion is a wrapper for Windows version information
|
||||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
|
||||||
type OSVersion struct {
|
type OSVersion struct {
|
||||||
|
@ -17,17 +20,18 @@ type OSVersion struct {
|
||||||
|
|
||||||
// GetOSVersion gets the operating system version on Windows. Note that
|
// GetOSVersion gets the operating system version on Windows. Note that
|
||||||
// docker.exe must be manifested to get the correct version information.
|
// docker.exe must be manifested to get the correct version information.
|
||||||
func GetOSVersion() (OSVersion, error) {
|
func GetOSVersion() OSVersion {
|
||||||
var err error
|
var err error
|
||||||
osv := OSVersion{}
|
osv := OSVersion{}
|
||||||
osv.Version, err = syscall.GetVersion()
|
osv.Version, err = syscall.GetVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return osv, fmt.Errorf("Failed to call GetVersion()")
|
// GetVersion never fails.
|
||||||
|
panic(err)
|
||||||
}
|
}
|
||||||
osv.MajorVersion = uint8(osv.Version & 0xFF)
|
osv.MajorVersion = uint8(osv.Version & 0xFF)
|
||||||
osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
|
osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
|
||||||
osv.Build = uint16(osv.Version >> 16)
|
osv.Build = uint16(osv.Version >> 16)
|
||||||
return osv, nil
|
return osv
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmount is a platform-specific helper function to call
|
// Unmount is a platform-specific helper function to call
|
||||||
|
@ -58,3 +62,12 @@ func CommandLineToArgv(commandLine string) ([]string, error) {
|
||||||
|
|
||||||
return newArgs, nil
|
return newArgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasWin32KSupport determines whether containers that depend on win32k can
|
||||||
|
// run on this machine. Win32k is the driver used to implement windowing.
|
||||||
|
func HasWin32KSupport() bool {
|
||||||
|
// For now, check for ntuser API support on the host. In the future, a host
|
||||||
|
// may support win32k in containers even if the host does not support ntuser
|
||||||
|
// APIs.
|
||||||
|
return ntuserApiset.Load() == nil
|
||||||
|
}
|
||||||
|
|
9
system/syscall_windows_test.go
Normal file
9
system/syscall_windows_test.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package system
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestHasWin32KSupport(t *testing.T) {
|
||||||
|
s := HasWin32KSupport() // make sure this doesn't panic
|
||||||
|
|
||||||
|
t.Logf("win32k: %v", s) // will be different on different platforms -- informative only
|
||||||
|
}
|
|
@ -57,10 +57,7 @@ func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
||||||
// console which supports ANSI emulation, or fall-back to the golang emulator
|
// console which supports ANSI emulation, or fall-back to the golang emulator
|
||||||
// (github.com/azure/go-ansiterm).
|
// (github.com/azure/go-ansiterm).
|
||||||
func useNativeConsole() bool {
|
func useNativeConsole() bool {
|
||||||
osv, err := system.GetOSVersion()
|
osv := system.GetOSVersion()
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Native console is not available before major version 10
|
// Native console is not available before major version 10
|
||||||
if osv.MajorVersion < 10 {
|
if osv.MajorVersion < 10 {
|
||||||
|
|
Loading…
Reference in a new issue