mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: remove getDockerOS utility in favor of "Ostype" header
This utility was added in83b5729f64to replace httputils.ParseServerHeader, which was added to print a warning on Windows in126529c6d0. At the time, the only available option to detect the daemon's OS was to parse the `Server` header, which contained the version of Docker as well as the OS. However,7199522ea2introduced an `OSType` ("Ostype") header that's included on all responses, and a later commite9dac5ef5echanged that to also be included when producing an error for unsupported API versions. Note that the casing in the midddleware was changed from `OSType` to `Ostype` (normalized form) in76a5ca1d4d, but headers are case-insensitive, and `header.Get()` should handle either case in the response. In short; every API response contains an "Ostype" header, which already contains the OS ("windows" or "linux") that doesn't require any parsing, so let's put that header to use. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -8,12 +8,9 @@ import (
|
||||
|
||||
cerrdefs "github.com/containerd/errdefs"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/internal/lazyregexp"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
var headerRegexp = lazyregexp.New(`\ADocker/.+\s\((.+)\)\z`)
|
||||
|
||||
type emptyIDError string
|
||||
|
||||
func (e emptyIDError) InvalidParameter() {}
|
||||
@@ -31,16 +28,6 @@ func trimID(objType, id string) (string, error) {
|
||||
return id, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// getFiltersQuery returns a url query with "filters" query term, based on the
|
||||
// filters provided.
|
||||
func getFiltersQuery(f filters.Args) (url.Values, error) {
|
||||
|
||||
Reference in New Issue
Block a user