github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/client/utils.go (about) 1 package client 2 3 import ( 4 "net/url" 5 "regexp" 6 7 "github.com/docker/docker/api/types/filters" 8 ) 9 10 var headerRegexp = regexp.MustCompile(`\ADocker/.+\s\((.+)\)\z`) 11 12 // getDockerOS returns the operating system based on the server header from the daemon. 13 func getDockerOS(serverHeader string) string { 14 var osType string 15 matches := headerRegexp.FindStringSubmatch(serverHeader) 16 if len(matches) > 0 { 17 osType = matches[1] 18 } 19 return osType 20 } 21 22 // getFiltersQuery returns a url query with "filters" query term, based on the 23 // filters provided. 24 func getFiltersQuery(f filters.Args) (url.Values, error) { 25 query := url.Values{} 26 if f.Len() > 0 { 27 filterJSON, err := filters.ToJSON(f) 28 if err != nil { 29 return query, err 30 } 31 query.Set("filters", filterJSON) 32 } 33 return query, nil 34 }