utils.go 376 B

123456789101112131415
  1. package client
  2. import "regexp"
  3. var headerRegexp = regexp.MustCompile(`\ADocker/.+\s\((.+)\)\z`)
  4. // getDockerOS returns the operating system based on the server header from the daemon.
  5. func getDockerOS(serverHeader string) string {
  6. var osType string
  7. matches := headerRegexp.FindStringSubmatch(serverHeader)
  8. if len(matches) > 0 {
  9. osType = matches[1]
  10. }
  11. return osType
  12. }