1
0
mirror of https://github.com/moby/moby.git synced 2025-07-30 18:23:29 +03:00

Convert request.SockRequestRaw to appropriate methods

`request.SockRequestRaw` is deprecated, let's use appropriate methods
for those. This is a first pass, `SockRequest` still needs to be removed.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester
2017-02-28 17:12:30 +01:00
parent 40532143c2
commit f85ee17810
14 changed files with 88 additions and 62 deletions

View File

@ -3,6 +3,7 @@ package main
import (
"archive/tar"
"bytes"
"io/ioutil"
"net/http"
"regexp"
"strings"
@ -31,7 +32,7 @@ RUN find /tmp/`
server := fakeStorage(c, map[string]string{"testD": testD})
defer server.Close()
res, body, err := request.SockRequestRaw("POST", "/build?dockerfile=baz&remote="+server.URL()+"/testD", nil, "application/json", daemonHost())
res, body, err := request.Post(daemonHost(), "/build?dockerfile=baz&remote="+server.URL()+"/testD", request.JSON)
c.Assert(err, checker.IsNil)
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
@ -70,7 +71,7 @@ func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *check.C) {
})
defer server.Close()
res, b, err := request.SockRequestRaw("POST", "/build?remote="+server.URL()+"/testT.tar", nil, "application/tar", daemonHost())
res, b, err := request.Post(daemonHost(), "/build?remote="+server.URL()+"/testT.tar", request.ContentType("application/tar"))
c.Assert(err, checker.IsNil)
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
b.Close()
@ -118,7 +119,7 @@ RUN echo 'right'
defer server.Close()
url := "/build?dockerfile=custom&remote=" + server.URL() + "/testT.tar"
res, body, err := request.SockRequestRaw("POST", url, nil, "application/tar", daemonHost())
res, body, err := request.Post(daemonHost(), url, request.ContentType("application/tar"))
c.Assert(err, checker.IsNil)
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
@ -137,7 +138,7 @@ RUN echo from dockerfile`,
}, false)
defer git.Close()
res, body, err := request.SockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json", daemonHost())
res, body, err := request.Post(daemonHost(), "/build?remote="+git.RepoURL, request.JSON)
c.Assert(err, checker.IsNil)
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
@ -158,7 +159,7 @@ RUN echo from Dockerfile`,
defer git.Close()
// Make sure it tries to 'dockerfile' query param value
res, body, err := request.SockRequestRaw("POST", "/build?dockerfile=baz&remote="+git.RepoURL, nil, "application/json", daemonHost())
res, body, err := request.Post(daemonHost(), "/build?dockerfile=baz&remote="+git.RepoURL, request.JSON)
c.Assert(err, checker.IsNil)
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
@ -180,7 +181,7 @@ RUN echo from dockerfile`,
defer git.Close()
// Make sure it tries to 'dockerfile' query param value
res, body, err := request.SockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json", daemonHost())
res, body, err := request.Post(daemonHost(), "/build?remote="+git.RepoURL, request.JSON)
c.Assert(err, checker.IsNil)
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
@ -227,7 +228,7 @@ func (s *DockerSuite) TestBuildAPIUnnormalizedTarPaths(c *check.C) {
// failed to close tar archive
c.Assert(tw.Close(), checker.IsNil)
res, body, err := request.SockRequestRaw("POST", "/build", buffer, "application/x-tar", daemonHost())
res, body, err := request.Post(daemonHost(), "/build", request.RawContent(ioutil.NopCloser(buffer)), request.ContentType("application/x-tar"))
c.Assert(err, checker.IsNil)
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)