diff --git a/client/container_stats.go b/client/container_stats.go index 2244e0f4b9..076954f4c3 100644 --- a/client/container_stats.go +++ b/client/container_stats.go @@ -28,7 +28,7 @@ func (cli *Client) ContainerStats(ctx context.Context, containerID string, strea return container.StatsResponseReader{ Body: resp.Body, - OSType: getDockerOS(resp.Header.Get("Server")), + OSType: resp.Header.Get("Ostype"), }, nil } @@ -51,6 +51,6 @@ func (cli *Client) ContainerStatsOneShot(ctx context.Context, containerID string return container.StatsResponseReader{ Body: resp.Body, - OSType: getDockerOS(resp.Header.Get("Server")), + OSType: resp.Header.Get("Ostype"), }, nil } diff --git a/client/image_build.go b/client/image_build.go index 66ca75e4af..1ed0878bfd 100644 --- a/client/image_build.go +++ b/client/image_build.go @@ -40,7 +40,7 @@ func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, optio return build.ImageBuildResponse{ Body: resp.Body, - OSType: getDockerOS(resp.Header.Get("Server")), + OSType: resp.Header.Get("Ostype"), }, nil } diff --git a/client/image_build_test.go b/client/image_build_test.go index 5610391fdf..76c514962d 100644 --- a/client/image_build_test.go +++ b/client/image_build_test.go @@ -191,7 +191,7 @@ func TestImageBuild(t *testing.T) { } headers := http.Header{} - headers.Add("Server", "Docker/v1.23 (MyOS)") + headers.Add("Ostype", "MyOS") return &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte("body"))), @@ -208,15 +208,3 @@ func TestImageBuild(t *testing.T) { assert.Check(t, is.Equal(string(response), "body")) } } - -func TestGetDockerOS(t *testing.T) { - cases := map[string]string{ - "Docker/v1.22 (linux)": "linux", - "Docker/v1.22 (windows)": "windows", - "Foo/v1.22 (bar)": "", - } - for header, os := range cases { - g := getDockerOS(header) - assert.Check(t, is.Equal(g, os)) - } -} diff --git a/client/utils.go b/client/utils.go index 67e1e6934b..7b82f185ac 100644 --- a/client/utils.go +++ b/client/utils.go @@ -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) {