mirror of https://github.com/docker/docs.git
FIX #2626 Retrieve windows version on non-english OS
Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
parent
fbf97b7c73
commit
39694f1ab4
|
|
@ -6,7 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func LocalOSVersion() string {
|
func LocalOSVersion() string {
|
||||||
command := exec.Command(`systeminfo`)
|
command := exec.Command(`ver`)
|
||||||
output, err := command.Output()
|
output, err := command.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
|
|
@ -15,11 +15,5 @@ func LocalOSVersion() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseOutput(output string) string {
|
func parseOutput(output string) string {
|
||||||
lines := strings.Split(string(output), "\n")
|
return strings.TrimSpace(output)
|
||||||
for _, line := range lines {
|
|
||||||
if strings.HasPrefix(line, "OS Version") {
|
|
||||||
return strings.TrimSpace(line[len("OS Version:"):])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,10 @@ import (
|
||||||
|
|
||||||
func TestOSWindows(t *testing.T) {
|
func TestOSWindows(t *testing.T) {
|
||||||
output := `
|
output := `
|
||||||
Host Name: DESKTOP-3A5PULA
|
|
||||||
OS Name: Microsoft Windows 10 Enterprise
|
Microsoft Windows [version 6.3.9600]
|
||||||
OS Version: 10.0.10240 N/A Build 10240
|
|
||||||
OS Manufacturer: Microsoft Corporation
|
|
||||||
OS Configuration: Standalone Workstation
|
|
||||||
OS Build Type: Multiprocessor Free
|
|
||||||
Registered Owner: Windows User
|
|
||||||
`
|
`
|
||||||
assert.Equal(t, "10.0.10240 N/A Build 10240", parseOutput(output))
|
|
||||||
|
assert.Equal(t, "Microsoft Windows [version 6.3.9600]", parseOutput(output))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue