mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Tidy GetDockerOS() function
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
9482da362c
commit
d8dcbf3ec3
4 changed files with 18 additions and 16 deletions
15
client/utils.go
Normal file
15
client/utils.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package client
|
||||
|
||||
import "regexp"
|
||||
|
||||
var headerRegexp = regexp.MustCompile(`\ADocker/.+\s\((.+)\)\z`)
|
||||
|
||||
// getDockerOS returns the operating system based on the server header from the daemon.
|
||||
func getDockerOS(serverHeader string) string {
|
||||
var osType string
|
||||
matches := headerRegexp.FindStringSubmatch(serverHeader)
|
||||
if len(matches) > 0 {
|
||||
osType = matches[1]
|
||||
}
|
||||
return osType
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue