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