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 {
|
||||
command := exec.Command(`systeminfo`)
|
||||
command := exec.Command(`ver`)
|
||||
output, err := command.Output()
|
||||
if err != nil {
|
||||
return ""
|
||||
|
|
@ -15,11 +15,5 @@ func LocalOSVersion() string {
|
|||
}
|
||||
|
||||
func parseOutput(output string) string {
|
||||
lines := strings.Split(string(output), "\n")
|
||||
for _, line := range lines {
|
||||
if strings.HasPrefix(line, "OS Version") {
|
||||
return strings.TrimSpace(line[len("OS Version:"):])
|
||||
}
|
||||
}
|
||||
return ""
|
||||
return strings.TrimSpace(output)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,10 @@ import (
|
|||
|
||||
func TestOSWindows(t *testing.T) {
|
||||
output := `
|
||||
Host Name: DESKTOP-3A5PULA
|
||||
OS Name: Microsoft Windows 10 Enterprise
|
||||
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
|
||||
|
||||
Microsoft Windows [version 6.3.9600]
|
||||
|
||||
`
|
||||
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