99.9% of use case for request call are using daemonHost. This makes it
default and adds a `request.DoOnHost` function to be able to specify
the host for specific, more complex use cases.
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
| ... | ... |
@@ -718,7 +718,7 @@ func (d *Daemon) ReloadConfig() error {
|
| 718 | 718 |
errCh := make(chan error) |
| 719 | 719 |
started := make(chan struct{})
|
| 720 | 720 |
go func() {
|
| 721 |
- _, body, err := request.Get(d.Sock(), "/events") |
|
| 721 |
+ _, body, err := request.DoOnHost(d.Sock(), "/events", request.Method(http.MethodGet)) |
|
| 722 | 722 |
close(started) |
| 723 | 723 |
if err != nil {
|
| 724 | 724 |
errCh <- err |
| ... | ... |
@@ -32,7 +32,7 @@ RUN find /tmp/` |
| 32 | 32 |
server := fakeStorage(c, map[string]string{"testD": testD})
|
| 33 | 33 |
defer server.Close() |
| 34 | 34 |
|
| 35 |
- res, body, err := request.Post(daemonHost(), "/build?dockerfile=baz&remote="+server.URL()+"/testD", request.JSON) |
|
| 35 |
+ res, body, err := request.Post("/build?dockerfile=baz&remote="+server.URL()+"/testD", request.JSON)
|
|
| 36 | 36 |
c.Assert(err, checker.IsNil) |
| 37 | 37 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 38 | 38 |
|
| ... | ... |
@@ -71,7 +71,7 @@ func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *check.C) {
|
| 71 | 71 |
}) |
| 72 | 72 |
defer server.Close() |
| 73 | 73 |
|
| 74 |
- res, b, err := request.Post(daemonHost(), "/build?remote="+server.URL()+"/testT.tar", request.ContentType("application/tar"))
|
|
| 74 |
+ res, b, err := request.Post("/build?remote="+server.URL()+"/testT.tar", request.ContentType("application/tar"))
|
|
| 75 | 75 |
c.Assert(err, checker.IsNil) |
| 76 | 76 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 77 | 77 |
b.Close() |
| ... | ... |
@@ -119,7 +119,7 @@ RUN echo 'right' |
| 119 | 119 |
defer server.Close() |
| 120 | 120 |
|
| 121 | 121 |
url := "/build?dockerfile=custom&remote=" + server.URL() + "/testT.tar" |
| 122 |
- res, body, err := request.Post(daemonHost(), url, request.ContentType("application/tar"))
|
|
| 122 |
+ res, body, err := request.Post(url, request.ContentType("application/tar"))
|
|
| 123 | 123 |
c.Assert(err, checker.IsNil) |
| 124 | 124 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 125 | 125 |
|
| ... | ... |
@@ -138,7 +138,7 @@ RUN echo from dockerfile`, |
| 138 | 138 |
}, false) |
| 139 | 139 |
defer git.Close() |
| 140 | 140 |
|
| 141 |
- res, body, err := request.Post(daemonHost(), "/build?remote="+git.RepoURL, request.JSON) |
|
| 141 |
+ res, body, err := request.Post("/build?remote="+git.RepoURL, request.JSON)
|
|
| 142 | 142 |
c.Assert(err, checker.IsNil) |
| 143 | 143 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 144 | 144 |
|
| ... | ... |
@@ -159,7 +159,7 @@ RUN echo from Dockerfile`, |
| 159 | 159 |
defer git.Close() |
| 160 | 160 |
|
| 161 | 161 |
// Make sure it tries to 'dockerfile' query param value |
| 162 |
- res, body, err := request.Post(daemonHost(), "/build?dockerfile=baz&remote="+git.RepoURL, request.JSON) |
|
| 162 |
+ res, body, err := request.Post("/build?dockerfile=baz&remote="+git.RepoURL, request.JSON)
|
|
| 163 | 163 |
c.Assert(err, checker.IsNil) |
| 164 | 164 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 165 | 165 |
|
| ... | ... |
@@ -181,7 +181,7 @@ RUN echo from dockerfile`, |
| 181 | 181 |
defer git.Close() |
| 182 | 182 |
|
| 183 | 183 |
// Make sure it tries to 'dockerfile' query param value |
| 184 |
- res, body, err := request.Post(daemonHost(), "/build?remote="+git.RepoURL, request.JSON) |
|
| 184 |
+ res, body, err := request.Post("/build?remote="+git.RepoURL, request.JSON)
|
|
| 185 | 185 |
c.Assert(err, checker.IsNil) |
| 186 | 186 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 187 | 187 |
|
| ... | ... |
@@ -228,7 +228,7 @@ func (s *DockerSuite) TestBuildAPIUnnormalizedTarPaths(c *check.C) {
|
| 228 | 228 |
// failed to close tar archive |
| 229 | 229 |
c.Assert(tw.Close(), checker.IsNil) |
| 230 | 230 |
|
| 231 |
- res, body, err := request.Post(daemonHost(), "/build", request.RawContent(ioutil.NopCloser(buffer)), request.ContentType("application/x-tar"))
|
|
| 231 |
+ res, body, err := request.Post("/build", request.RawContent(ioutil.NopCloser(buffer)), request.ContentType("application/x-tar"))
|
|
| 232 | 232 |
c.Assert(err, checker.IsNil) |
| 233 | 233 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 234 | 234 |
|
| ... | ... |
@@ -216,7 +216,7 @@ func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) {
|
| 216 | 216 |
buf := &testutil.ChannelBuffer{C: make(chan []byte, 1)}
|
| 217 | 217 |
defer buf.Close() |
| 218 | 218 |
|
| 219 |
- _, body, err := request.Get(daemonHost(), "/containers/"+id+"/stats?stream=1", request.JSON) |
|
| 219 |
+ _, body, err := request.Get("/containers/"+id+"/stats?stream=1", request.JSON)
|
|
| 220 | 220 |
c.Assert(err, checker.IsNil) |
| 221 | 221 |
defer body.Close() |
| 222 | 222 |
|
| ... | ... |
@@ -255,7 +255,7 @@ func (s *DockerSuite) TestGetContainerStatsStream(c *check.C) {
|
| 255 | 255 |
} |
| 256 | 256 |
bc := make(chan b, 1) |
| 257 | 257 |
go func() {
|
| 258 |
- status, body, err := request.Get(daemonHost(), "/containers/"+name+"/stats") |
|
| 258 |
+ status, body, err := request.Get("/containers/" + name + "/stats")
|
|
| 259 | 259 |
bc <- b{status.StatusCode, body, err}
|
| 260 | 260 |
}() |
| 261 | 261 |
|
| ... | ... |
@@ -329,7 +329,7 @@ func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) {
|
| 329 | 329 |
// We expect an immediate response, but if it's not immediate, the test would hang, so put it in a goroutine |
| 330 | 330 |
// below we'll check this on a timeout. |
| 331 | 331 |
go func() {
|
| 332 |
- resp, body, err := request.Get(daemonHost(), "/containers/"+name+"/stats") |
|
| 332 |
+ resp, body, err := request.Get("/containers/" + name + "/stats")
|
|
| 333 | 333 |
body.Close() |
| 334 | 334 |
chResp <- stats{resp.StatusCode, err}
|
| 335 | 335 |
}() |
| ... | ... |
@@ -661,7 +661,7 @@ func (s *DockerSuite) TestContainerAPIVerifyHeader(c *check.C) {
|
| 661 | 661 |
create := func(ct string) (*http.Response, io.ReadCloser, error) {
|
| 662 | 662 |
jsonData := bytes.NewBuffer(nil) |
| 663 | 663 |
c.Assert(json.NewEncoder(jsonData).Encode(config), checker.IsNil) |
| 664 |
- return request.Post(daemonHost(), "/containers/create", request.RawContent(ioutil.NopCloser(jsonData)), request.ContentType(ct)) |
|
| 664 |
+ return request.Post("/containers/create", request.RawContent(ioutil.NopCloser(jsonData)), request.ContentType(ct))
|
|
| 665 | 665 |
} |
| 666 | 666 |
|
| 667 | 667 |
// Try with no content-type |
| ... | ... |
@@ -697,7 +697,7 @@ func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *check.C) {
|
| 697 | 697 |
} |
| 698 | 698 |
}` |
| 699 | 699 |
|
| 700 |
- res, body, err := request.Post(daemonHost(), "/containers/create", request.RawString(config), request.JSON) |
|
| 700 |
+ res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON)
|
|
| 701 | 701 |
c.Assert(err, checker.IsNil) |
| 702 | 702 |
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) |
| 703 | 703 |
|
| ... | ... |
@@ -717,7 +717,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *check.C) |
| 717 | 717 |
} |
| 718 | 718 |
}` |
| 719 | 719 |
|
| 720 |
- res, body, err := request.Post(daemonHost(), "/containers/create", request.RawString(config), request.JSON) |
|
| 720 |
+ res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON)
|
|
| 721 | 721 |
c.Assert(err, checker.IsNil) |
| 722 | 722 |
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) |
| 723 | 723 |
|
| ... | ... |
@@ -737,7 +737,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *check.C) {
|
| 737 | 737 |
} |
| 738 | 738 |
}` |
| 739 | 739 |
|
| 740 |
- res, body, err := request.Post(daemonHost(), "/containers/create", request.RawString(config), request.JSON) |
|
| 740 |
+ res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON)
|
|
| 741 | 741 |
c.Assert(err, checker.IsNil) |
| 742 | 742 |
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) |
| 743 | 743 |
|
| ... | ... |
@@ -757,7 +757,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *check.C |
| 757 | 757 |
} |
| 758 | 758 |
}` |
| 759 | 759 |
|
| 760 |
- res, body, err := request.Post(daemonHost(), "/containers/create", request.RawString(config), request.JSON) |
|
| 760 |
+ res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON)
|
|
| 761 | 761 |
c.Assert(err, checker.IsNil) |
| 762 | 762 |
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) |
| 763 | 763 |
|
| ... | ... |
@@ -777,7 +777,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *check.C) |
| 777 | 777 |
} |
| 778 | 778 |
}` |
| 779 | 779 |
|
| 780 |
- res, _, err := request.Post(daemonHost(), "/containers/create", request.RawString(config), request.JSON) |
|
| 780 |
+ res, _, err := request.Post("/containers/create", request.RawString(config), request.JSON)
|
|
| 781 | 781 |
c.Assert(err, checker.IsNil) |
| 782 | 782 |
c.Assert(res.StatusCode, checker.Equals, http.StatusCreated) |
| 783 | 783 |
} |
| ... | ... |
@@ -808,7 +808,7 @@ func (s *DockerSuite) TestContainerAPIPostCreateNull(c *check.C) {
|
| 808 | 808 |
"NetworkDisabled":false, |
| 809 | 809 |
"OnBuild":null}` |
| 810 | 810 |
|
| 811 |
- res, body, err := request.Post(daemonHost(), "/containers/create", request.RawString(config), request.JSON) |
|
| 811 |
+ res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON)
|
|
| 812 | 812 |
c.Assert(err, checker.IsNil) |
| 813 | 813 |
c.Assert(res.StatusCode, checker.Equals, http.StatusCreated) |
| 814 | 814 |
|
| ... | ... |
@@ -839,7 +839,7 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *check.C) {
|
| 839 | 839 |
"Memory": 524287 |
| 840 | 840 |
}` |
| 841 | 841 |
|
| 842 |
- res, body, err := request.Post(daemonHost(), "/containers/create", request.RawString(config), request.JSON) |
|
| 842 |
+ res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON)
|
|
| 843 | 843 |
c.Assert(err, checker.IsNil) |
| 844 | 844 |
b, err2 := testutil.ReadBody(body) |
| 845 | 845 |
c.Assert(err2, checker.IsNil) |
| ... | ... |
@@ -1139,7 +1139,7 @@ func (s *DockerSuite) TestContainerAPIChunkedEncoding(c *check.C) {
|
| 1139 | 1139 |
"OpenStdin": true, |
| 1140 | 1140 |
} |
| 1141 | 1141 |
|
| 1142 |
- resp, _, err := request.Post(daemonHost(), "/containers/create", request.JSONBody(config), func(req *http.Request) error {
|
|
| 1142 |
+ resp, _, err := request.Post("/containers/create", request.JSONBody(config), func(req *http.Request) error {
|
|
| 1143 | 1143 |
// This is a cheat to make the http request do chunked encoding |
| 1144 | 1144 |
// Otherwise (just setting the Content-Encoding to chunked) net/http will overwrite |
| 1145 | 1145 |
// https://golang.org/src/pkg/net/http/request.go?s=11980:12172 |
| ... | ... |
@@ -22,7 +22,7 @@ func (s *DockerSuite) TestEventsAPIEmptyOutput(c *check.C) {
|
| 22 | 22 |
} |
| 23 | 23 |
chResp := make(chan *apiResp) |
| 24 | 24 |
go func() {
|
| 25 |
- resp, body, err := request.Get(daemonHost(), "/events") |
|
| 25 |
+ resp, body, err := request.Get("/events")
|
|
| 26 | 26 |
body.Close() |
| 27 | 27 |
chResp <- &apiResp{resp, err}
|
| 28 | 28 |
}() |
| ... | ... |
@@ -47,7 +47,7 @@ func (s *DockerSuite) TestEventsAPIBackwardsCompatible(c *check.C) {
|
| 47 | 47 |
q := url.Values{}
|
| 48 | 48 |
q.Set("since", ts)
|
| 49 | 49 |
|
| 50 |
- _, body, err := request.Get(daemonHost(), "/events?"+q.Encode()) |
|
| 50 |
+ _, body, err := request.Get("/events?" + q.Encode())
|
|
| 51 | 51 |
c.Assert(err, checker.IsNil) |
| 52 | 52 |
defer body.Close() |
| 53 | 53 |
|
| ... | ... |
@@ -62,7 +62,7 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *check.C) {
|
| 62 | 62 |
} |
| 63 | 63 |
defer conn.Close() |
| 64 | 64 |
|
| 65 |
- _, rc, err := request.Post(daemonHost(), fmt.Sprintf("/exec/%s/resize?h=24&w=80", execID), request.ContentType("text/plain"))
|
|
| 65 |
+ _, rc, err := request.Post(fmt.Sprintf("/exec/%s/resize?h=24&w=80", execID), request.ContentType("text/plain"))
|
|
| 66 | 66 |
// It's probably a panic of the daemon if io.ErrUnexpectedEOF is returned. |
| 67 | 67 |
if err == io.ErrUnexpectedEOF {
|
| 68 | 68 |
return fmt.Errorf("The daemon might have crashed.")
|
| ... | ... |
@@ -38,7 +38,7 @@ func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *check.C) {
|
| 38 | 38 |
c.Fatalf("Can not encode data to json %s", err)
|
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
- res, body, err := request.Post(daemonHost(), fmt.Sprintf("/containers/%s/exec", name), request.RawContent(ioutil.NopCloser(jsonData)), request.ContentType("test/plain"))
|
|
| 41 |
+ res, body, err := request.Post(fmt.Sprintf("/containers/%s/exec", name), request.RawContent(ioutil.NopCloser(jsonData)), request.ContentType("test/plain"))
|
|
| 42 | 42 |
c.Assert(err, checker.IsNil) |
| 43 | 43 |
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) |
| 44 | 44 |
|
| ... | ... |
@@ -96,7 +96,7 @@ func (s *DockerSuite) TestExecAPIStartEnsureHeaders(c *check.C) {
|
| 96 | 96 |
dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top") |
| 97 | 97 |
|
| 98 | 98 |
id := createExec(c, "test") |
| 99 |
- resp, _, err := request.Post(daemonHost(), fmt.Sprintf("/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.JSON)
|
|
| 99 |
+ resp, _, err := request.Post(fmt.Sprintf("/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.JSON)
|
|
| 100 | 100 |
c.Assert(err, checker.IsNil) |
| 101 | 101 |
c.Assert(resp.Header.Get("Server"), checker.Not(checker.Equals), "")
|
| 102 | 102 |
} |
| ... | ... |
@@ -106,7 +106,7 @@ func (s *DockerSuite) TestExecAPIStartBackwardsCompatible(c *check.C) {
|
| 106 | 106 |
runSleepingContainer(c, "-d", "--name", "test") |
| 107 | 107 |
id := createExec(c, "test") |
| 108 | 108 |
|
| 109 |
- resp, body, err := request.Post(daemonHost(), fmt.Sprintf("/v1.20/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.ContentType("text/plain"))
|
|
| 109 |
+ resp, body, err := request.Post(fmt.Sprintf("/v1.20/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.ContentType("text/plain"))
|
|
| 110 | 110 |
c.Assert(err, checker.IsNil) |
| 111 | 111 |
|
| 112 | 112 |
b, err := testutil.ReadBody(body) |
| ... | ... |
@@ -141,14 +141,14 @@ func (s *DockerSuite) TestExecAPIStartWithDetach(c *check.C) {
|
| 141 | 141 |
}{}
|
| 142 | 142 |
c.Assert(json.Unmarshal(b, &createResp), checker.IsNil, check.Commentf(string(b))) |
| 143 | 143 |
|
| 144 |
- _, body, err := request.Post(daemonHost(), fmt.Sprintf("/exec/%s/start", createResp.ID), request.RawString(`{"Detach": true}`), request.JSON)
|
|
| 144 |
+ _, body, err := request.Post(fmt.Sprintf("/exec/%s/start", createResp.ID), request.RawString(`{"Detach": true}`), request.JSON)
|
|
| 145 | 145 |
c.Assert(err, checker.IsNil) |
| 146 | 146 |
|
| 147 | 147 |
b, err = testutil.ReadBody(body) |
| 148 | 148 |
comment := check.Commentf("response body: %s", b)
|
| 149 | 149 |
c.Assert(err, checker.IsNil, comment) |
| 150 | 150 |
|
| 151 |
- resp, _, err := request.Get(daemonHost(), "/_ping") |
|
| 151 |
+ resp, _, err := request.Get("/_ping")
|
|
| 152 | 152 |
c.Assert(err, checker.IsNil) |
| 153 | 153 |
if resp.StatusCode != http.StatusOK {
|
| 154 | 154 |
c.Fatal("daemon is down, it should alive")
|
| ... | ... |
@@ -191,7 +191,7 @@ func createExec(c *check.C, name string) string {
|
| 191 | 191 |
} |
| 192 | 192 |
|
| 193 | 193 |
func createExecCmd(c *check.C, name string, cmd string) string {
|
| 194 |
- _, reader, err := request.Post(daemonHost(), fmt.Sprintf("/containers/%s/exec", name), request.JSONBody(map[string]interface{}{"Cmd": []string{cmd}}))
|
|
| 194 |
+ _, reader, err := request.Post(fmt.Sprintf("/containers/%s/exec", name), request.JSONBody(map[string]interface{}{"Cmd": []string{cmd}}))
|
|
| 195 | 195 |
c.Assert(err, checker.IsNil) |
| 196 | 196 |
b, err := ioutil.ReadAll(reader) |
| 197 | 197 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -204,7 +204,7 @@ func createExecCmd(c *check.C, name string, cmd string) string {
|
| 204 | 204 |
} |
| 205 | 205 |
|
| 206 | 206 |
func startExec(c *check.C, id string, code int) {
|
| 207 |
- resp, body, err := request.Post(daemonHost(), fmt.Sprintf("/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.JSON)
|
|
| 207 |
+ resp, body, err := request.Post(fmt.Sprintf("/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.JSON)
|
|
| 208 | 208 |
c.Assert(err, checker.IsNil) |
| 209 | 209 |
|
| 210 | 210 |
b, err := testutil.ReadBody(body) |
| ... | ... |
@@ -214,7 +214,7 @@ func startExec(c *check.C, id string, code int) {
|
| 214 | 214 |
} |
| 215 | 215 |
|
| 216 | 216 |
func inspectExec(c *check.C, id string, out interface{}) {
|
| 217 |
- resp, body, err := request.Get(daemonHost(), fmt.Sprintf("/exec/%s/json", id))
|
|
| 217 |
+ resp, body, err := request.Get(fmt.Sprintf("/exec/%s/json", id))
|
|
| 218 | 218 |
c.Assert(err, checker.IsNil) |
| 219 | 219 |
defer body.Close() |
| 220 | 220 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK) |
| ... | ... |
@@ -240,7 +240,7 @@ func waitForExec(c *check.C, id string) {
|
| 240 | 240 |
} |
| 241 | 241 |
|
| 242 | 242 |
func inspectContainer(c *check.C, id string, out interface{}) {
|
| 243 |
- resp, body, err := request.Get(daemonHost(), fmt.Sprintf("/containers/%s/json", id))
|
|
| 243 |
+ resp, body, err := request.Get(fmt.Sprintf("/containers/%s/json", id))
|
|
| 244 | 244 |
c.Assert(err, checker.IsNil) |
| 245 | 245 |
defer body.Close() |
| 246 | 246 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK) |
| ... | ... |
@@ -56,14 +56,14 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *check.C) {
|
| 56 | 56 |
buildImageSuccessfully(c, "saveandload", withDockerfile("FROM busybox\nENV FOO bar"))
|
| 57 | 57 |
id := getIDByName(c, "saveandload") |
| 58 | 58 |
|
| 59 |
- res, body, err := request.Get(daemonHost(), "/images/"+id+"/get") |
|
| 59 |
+ res, body, err := request.Get("/images/" + id + "/get")
|
|
| 60 | 60 |
c.Assert(err, checker.IsNil) |
| 61 | 61 |
defer body.Close() |
| 62 | 62 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 63 | 63 |
|
| 64 | 64 |
dockerCmd(c, "rmi", id) |
| 65 | 65 |
|
| 66 |
- res, loadBody, err := request.Post(daemonHost(), "/images/load", request.RawContent(body), request.ContentType("application/x-tar"))
|
|
| 66 |
+ res, loadBody, err := request.Post("/images/load", request.RawContent(body), request.ContentType("application/x-tar"))
|
|
| 67 | 67 |
c.Assert(err, checker.IsNil) |
| 68 | 68 |
defer loadBody.Close() |
| 69 | 69 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| ... | ... |
@@ -119,7 +119,7 @@ func (s *DockerSuite) TestAPIImagesHistory(c *check.C) {
|
| 119 | 119 |
func (s *DockerSuite) TestAPIImagesSearchJSONContentType(c *check.C) {
|
| 120 | 120 |
testRequires(c, Network) |
| 121 | 121 |
|
| 122 |
- res, b, err := request.Get(daemonHost(), "/images/search?term=test", request.JSON) |
|
| 122 |
+ res, b, err := request.Get("/images/search?term=test", request.JSON)
|
|
| 123 | 123 |
c.Assert(err, check.IsNil) |
| 124 | 124 |
b.Close() |
| 125 | 125 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| ... | ... |
@@ -25,7 +25,7 @@ func (s *DockerSuite) TestLogsAPIWithStdout(c *check.C) {
|
| 25 | 25 |
chLog := make(chan logOut) |
| 26 | 26 |
|
| 27 | 27 |
go func() {
|
| 28 |
- res, body, err := request.Get(daemonHost(), fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1×tamps=1", id))
|
|
| 28 |
+ res, body, err := request.Get(fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1×tamps=1", id))
|
|
| 29 | 29 |
if err != nil {
|
| 30 | 30 |
chLog <- logOut{"", nil, err}
|
| 31 | 31 |
return |
| ... | ... |
@@ -69,7 +69,7 @@ func (s *DockerSuite) TestLogsAPIFollowEmptyOutput(c *check.C) {
|
| 69 | 69 |
t0 := time.Now() |
| 70 | 70 |
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "sleep", "10") |
| 71 | 71 |
|
| 72 |
- _, body, err := request.Get(daemonHost(), fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1&stderr=1&tail=all", name))
|
|
| 72 |
+ _, body, err := request.Get(fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1&stderr=1&tail=all", name))
|
|
| 73 | 73 |
t1 := time.Now() |
| 74 | 74 |
c.Assert(err, checker.IsNil) |
| 75 | 75 |
body.Close() |
| ... | ... |
@@ -81,7 +81,7 @@ func (s *DockerSuite) TestLogsAPIFollowEmptyOutput(c *check.C) {
|
| 81 | 81 |
|
| 82 | 82 |
func (s *DockerSuite) TestLogsAPIContainerNotFound(c *check.C) {
|
| 83 | 83 |
name := "nonExistentContainer" |
| 84 |
- resp, _, err := request.Get(daemonHost(), fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1&stderr=1&tail=all", name))
|
|
| 84 |
+ resp, _, err := request.Get(fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1&stderr=1&tail=all", name))
|
|
| 85 | 85 |
c.Assert(err, checker.IsNil) |
| 86 | 86 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusNotFound) |
| 87 | 87 |
} |
| ... | ... |
@@ -257,7 +257,7 @@ func createDeletePredefinedNetwork(c *check.C, name string) {
|
| 257 | 257 |
} |
| 258 | 258 |
|
| 259 | 259 |
func isNetworkAvailable(c *check.C, name string) bool {
|
| 260 |
- resp, body, err := request.Get(daemonHost(), "/networks") |
|
| 260 |
+ resp, body, err := request.Get("/networks")
|
|
| 261 | 261 |
c.Assert(err, checker.IsNil) |
| 262 | 262 |
defer resp.Body.Close() |
| 263 | 263 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK) |
| ... | ... |
@@ -284,7 +284,7 @@ func getNetworkIDByName(c *check.C, name string) string {
|
| 284 | 284 |
c.Assert(err, checker.IsNil) |
| 285 | 285 |
v.Set("filters", filterJSON)
|
| 286 | 286 |
|
| 287 |
- resp, body, err := request.Get(daemonHost(), "/networks?"+v.Encode()) |
|
| 287 |
+ resp, body, err := request.Get("/networks?" + v.Encode())
|
|
| 288 | 288 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK) |
| 289 | 289 |
c.Assert(err, checker.IsNil) |
| 290 | 290 |
|
| ... | ... |
@@ -297,7 +297,7 @@ func getNetworkIDByName(c *check.C, name string) string {
|
| 297 | 297 |
} |
| 298 | 298 |
|
| 299 | 299 |
func getNetworkResource(c *check.C, id string) *types.NetworkResource {
|
| 300 |
- _, obj, err := request.Get(daemonHost(), "/networks/"+id) |
|
| 300 |
+ _, obj, err := request.Get("/networks/" + id)
|
|
| 301 | 301 |
c.Assert(err, checker.IsNil) |
| 302 | 302 |
|
| 303 | 303 |
nr := types.NetworkResource{}
|
| ... | ... |
@@ -308,7 +308,7 @@ func getNetworkResource(c *check.C, id string) *types.NetworkResource {
|
| 308 | 308 |
} |
| 309 | 309 |
|
| 310 | 310 |
func createNetwork(c *check.C, config types.NetworkCreateRequest, shouldSucceed bool) string {
|
| 311 |
- resp, body, err := request.Post(daemonHost(), "/networks/create", request.JSONBody(config)) |
|
| 311 |
+ resp, body, err := request.Post("/networks/create", request.JSONBody(config))
|
|
| 312 | 312 |
c.Assert(err, checker.IsNil) |
| 313 | 313 |
defer resp.Body.Close() |
| 314 | 314 |
if !shouldSucceed {
|
| ... | ... |
@@ -330,7 +330,7 @@ func connectNetwork(c *check.C, nid, cid string) {
|
| 330 | 330 |
Container: cid, |
| 331 | 331 |
} |
| 332 | 332 |
|
| 333 |
- resp, _, err := request.Post(daemonHost(), "/networks/"+nid+"/connect", request.JSONBody(config)) |
|
| 333 |
+ resp, _, err := request.Post("/networks/"+nid+"/connect", request.JSONBody(config))
|
|
| 334 | 334 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK) |
| 335 | 335 |
c.Assert(err, checker.IsNil) |
| 336 | 336 |
} |
| ... | ... |
@@ -340,13 +340,13 @@ func disconnectNetwork(c *check.C, nid, cid string) {
|
| 340 | 340 |
Container: cid, |
| 341 | 341 |
} |
| 342 | 342 |
|
| 343 |
- resp, _, err := request.Post(daemonHost(), "/networks/"+nid+"/disconnect", request.JSONBody(config)) |
|
| 343 |
+ resp, _, err := request.Post("/networks/"+nid+"/disconnect", request.JSONBody(config))
|
|
| 344 | 344 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK) |
| 345 | 345 |
c.Assert(err, checker.IsNil) |
| 346 | 346 |
} |
| 347 | 347 |
|
| 348 | 348 |
func deleteNetwork(c *check.C, id string, shouldSucceed bool) {
|
| 349 |
- resp, _, err := request.Delete(daemonHost(), "/networks/"+id) |
|
| 349 |
+ resp, _, err := request.Delete("/networks/" + id)
|
|
| 350 | 350 |
c.Assert(err, checker.IsNil) |
| 351 | 351 |
defer resp.Body.Close() |
| 352 | 352 |
if !shouldSucceed {
|
| ... | ... |
@@ -26,7 +26,7 @@ func (s *DockerSuite) TestAPIStatsNoStreamGetCpu(c *check.C) {
|
| 26 | 26 |
id := strings.TrimSpace(out) |
| 27 | 27 |
c.Assert(waitRun(id), checker.IsNil) |
| 28 | 28 |
|
| 29 |
- resp, body, err := request.Get(daemonHost(), fmt.Sprintf("/containers/%s/stats?stream=false", id))
|
|
| 29 |
+ resp, body, err := request.Get(fmt.Sprintf("/containers/%s/stats?stream=false", id))
|
|
| 30 | 30 |
c.Assert(err, checker.IsNil) |
| 31 | 31 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK) |
| 32 | 32 |
c.Assert(resp.Header.Get("Content-Type"), checker.Equals, "application/json")
|
| ... | ... |
@@ -65,7 +65,7 @@ func (s *DockerSuite) TestAPIStatsStoppedContainerInGoroutines(c *check.C) {
|
| 65 | 65 |
id := strings.TrimSpace(out) |
| 66 | 66 |
|
| 67 | 67 |
getGoRoutines := func() int {
|
| 68 |
- _, body, err := request.Get(daemonHost(), fmt.Sprintf("/info"))
|
|
| 68 |
+ _, body, err := request.Get(fmt.Sprintf("/info"))
|
|
| 69 | 69 |
c.Assert(err, checker.IsNil) |
| 70 | 70 |
info := types.Info{}
|
| 71 | 71 |
err = json.NewDecoder(body).Decode(&info) |
| ... | ... |
@@ -76,7 +76,7 @@ func (s *DockerSuite) TestAPIStatsStoppedContainerInGoroutines(c *check.C) {
|
| 76 | 76 |
|
| 77 | 77 |
// When the HTTP connection is closed, the number of goroutines should not increase. |
| 78 | 78 |
routines := getGoRoutines() |
| 79 |
- _, body, err := request.Get(daemonHost(), fmt.Sprintf("/containers/%s/stats", id))
|
|
| 79 |
+ _, body, err := request.Get(fmt.Sprintf("/containers/%s/stats", id))
|
|
| 80 | 80 |
c.Assert(err, checker.IsNil) |
| 81 | 81 |
body.Close() |
| 82 | 82 |
|
| ... | ... |
@@ -192,7 +192,7 @@ func (s *DockerSuite) TestAPIStatsNetworkStatsVersioning(c *check.C) {
|
| 192 | 192 |
func getNetworkStats(c *check.C, id string) map[string]types.NetworkStats {
|
| 193 | 193 |
var st *types.StatsJSON |
| 194 | 194 |
|
| 195 |
- _, body, err := request.Get(daemonHost(), fmt.Sprintf("/containers/%s/stats?stream=false", id))
|
|
| 195 |
+ _, body, err := request.Get(fmt.Sprintf("/containers/%s/stats?stream=false", id))
|
|
| 196 | 196 |
c.Assert(err, checker.IsNil) |
| 197 | 197 |
|
| 198 | 198 |
err = json.NewDecoder(body).Decode(&st) |
| ... | ... |
@@ -209,7 +209,7 @@ func getNetworkStats(c *check.C, id string) map[string]types.NetworkStats {
|
| 209 | 209 |
func getVersionedStats(c *check.C, id string, apiVersion string) map[string]interface{} {
|
| 210 | 210 |
stats := make(map[string]interface{})
|
| 211 | 211 |
|
| 212 |
- _, body, err := request.Get(daemonHost(), fmt.Sprintf("/%s/containers/%s/stats?stream=false", apiVersion, id))
|
|
| 212 |
+ _, body, err := request.Get(fmt.Sprintf("/%s/containers/%s/stats?stream=false", apiVersion, id))
|
|
| 213 | 213 |
c.Assert(err, checker.IsNil) |
| 214 | 214 |
defer body.Close() |
| 215 | 215 |
|
| ... | ... |
@@ -284,7 +284,7 @@ func (s *DockerSuite) TestAPIStatsNoStreamConnectedContainers(c *check.C) {
|
| 284 | 284 |
|
| 285 | 285 |
ch := make(chan error) |
| 286 | 286 |
go func() {
|
| 287 |
- resp, body, err := request.Get(daemonHost(), fmt.Sprintf("/containers/%s/stats?stream=false", id2))
|
|
| 287 |
+ resp, body, err := request.Get(fmt.Sprintf("/containers/%s/stats?stream=false", id2))
|
|
| 288 | 288 |
defer body.Close() |
| 289 | 289 |
if err != nil {
|
| 290 | 290 |
ch <- err |
| ... | ... |
@@ -16,7 +16,7 @@ import ( |
| 16 | 16 |
func (s *DockerSuite) TestAPIStatsContainerGetMemoryLimit(c *check.C) {
|
| 17 | 17 |
testRequires(c, DaemonIsLinux, memoryLimitSupport) |
| 18 | 18 |
|
| 19 |
- resp, body, err := request.Get(daemonHost(), "/info", request.JSON) |
|
| 19 |
+ resp, body, err := request.Get("/info", request.JSON)
|
|
| 20 | 20 |
c.Assert(err, checker.IsNil) |
| 21 | 21 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK) |
| 22 | 22 |
var info types.Info |
| ... | ... |
@@ -29,7 +29,7 @@ func (s *DockerSuite) TestAPIStatsContainerGetMemoryLimit(c *check.C) {
|
| 29 | 29 |
dockerCmd(c, "run", "-d", "--name", conName, "busybox", "top") |
| 30 | 30 |
c.Assert(waitRun(conName), checker.IsNil) |
| 31 | 31 |
|
| 32 |
- resp, body, err = request.Get(daemonHost(), fmt.Sprintf("/containers/%s/stats?stream=false", conName))
|
|
| 32 |
+ resp, body, err = request.Get(fmt.Sprintf("/containers/%s/stats?stream=false", conName))
|
|
| 33 | 33 |
c.Assert(err, checker.IsNil) |
| 34 | 34 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK) |
| 35 | 35 |
c.Assert(resp.Header.Get("Content-Type"), checker.Equals, "application/json")
|
| ... | ... |
@@ -18,13 +18,13 @@ import ( |
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 | 20 |
func (s *DockerSuite) TestAPIOptionsRoute(c *check.C) {
|
| 21 |
- resp, _, err := request.Do(daemonHost(), "/", request.Method(http.MethodOptions)) |
|
| 21 |
+ resp, _, err := request.Do("/", request.Method(http.MethodOptions))
|
|
| 22 | 22 |
c.Assert(err, checker.IsNil) |
| 23 | 23 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusOK) |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
func (s *DockerSuite) TestAPIGetEnabledCORS(c *check.C) {
|
| 27 |
- res, body, err := request.Get(daemonHost(), "/version") |
|
| 27 |
+ res, body, err := request.Get("/version")
|
|
| 28 | 28 |
c.Assert(err, checker.IsNil) |
| 29 | 29 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 30 | 30 |
body.Close() |
| ... | ... |
@@ -49,7 +49,7 @@ func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) {
|
| 49 | 49 |
v[1] = strconv.Itoa(vMinInt) |
| 50 | 50 |
version := strings.Join(v, ".") |
| 51 | 51 |
|
| 52 |
- resp, body, err := request.Get(daemonHost(), "/v"+version+"/version") |
|
| 52 |
+ resp, body, err := request.Get("/v" + version + "/version")
|
|
| 53 | 53 |
c.Assert(err, checker.IsNil) |
| 54 | 54 |
defer body.Close() |
| 55 | 55 |
c.Assert(resp.StatusCode, checker.Equals, http.StatusBadRequest) |
| ... | ... |
@@ -80,7 +80,7 @@ func (s *DockerSuite) TestAPIDockerAPIVersion(c *check.C) {
|
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 | 82 |
func (s *DockerSuite) TestAPIErrorJSON(c *check.C) {
|
| 83 |
- httpResp, body, err := request.Post(daemonHost(), "/containers/create", request.JSONBody(struct{}{}))
|
|
| 83 |
+ httpResp, body, err := request.Post("/containers/create", request.JSONBody(struct{}{}))
|
|
| 84 | 84 |
c.Assert(err, checker.IsNil) |
| 85 | 85 |
c.Assert(httpResp.StatusCode, checker.Equals, http.StatusInternalServerError) |
| 86 | 86 |
c.Assert(httpResp.Header.Get("Content-Type"), checker.Equals, "application/json")
|
| ... | ... |
@@ -93,7 +93,7 @@ func (s *DockerSuite) TestAPIErrorPlainText(c *check.C) {
|
| 93 | 93 |
// Windows requires API 1.25 or later. This test is validating a behaviour which was present |
| 94 | 94 |
// in v1.23, but changed in 1.24, hence not applicable on Windows. See apiVersionSupportsJSONErrors |
| 95 | 95 |
testRequires(c, DaemonIsLinux) |
| 96 |
- httpResp, body, err := request.Post(daemonHost(), "/v1.23/containers/create", request.JSONBody(struct{}{}))
|
|
| 96 |
+ httpResp, body, err := request.Post("/v1.23/containers/create", request.JSONBody(struct{}{}))
|
|
| 97 | 97 |
c.Assert(err, checker.IsNil) |
| 98 | 98 |
c.Assert(httpResp.StatusCode, checker.Equals, http.StatusInternalServerError) |
| 99 | 99 |
c.Assert(httpResp.Header.Get("Content-Type"), checker.Contains, "text/plain")
|
| ... | ... |
@@ -104,7 +104,7 @@ func (s *DockerSuite) TestAPIErrorPlainText(c *check.C) {
|
| 104 | 104 |
|
| 105 | 105 |
func (s *DockerSuite) TestAPIErrorNotFoundJSON(c *check.C) {
|
| 106 | 106 |
// 404 is a different code path to normal errors, so test separately |
| 107 |
- httpResp, body, err := request.Get(daemonHost(), "/notfound", request.JSON) |
|
| 107 |
+ httpResp, body, err := request.Get("/notfound", request.JSON)
|
|
| 108 | 108 |
c.Assert(err, checker.IsNil) |
| 109 | 109 |
c.Assert(httpResp.StatusCode, checker.Equals, http.StatusNotFound) |
| 110 | 110 |
c.Assert(httpResp.Header.Get("Content-Type"), checker.Equals, "application/json")
|
| ... | ... |
@@ -114,7 +114,7 @@ func (s *DockerSuite) TestAPIErrorNotFoundJSON(c *check.C) {
|
| 114 | 114 |
} |
| 115 | 115 |
|
| 116 | 116 |
func (s *DockerSuite) TestAPIErrorNotFoundPlainText(c *check.C) {
|
| 117 |
- httpResp, body, err := request.Get(daemonHost(), "/v1.23/notfound", request.JSON) |
|
| 117 |
+ httpResp, body, err := request.Get("/v1.23/notfound", request.JSON)
|
|
| 118 | 118 |
c.Assert(err, checker.IsNil) |
| 119 | 119 |
c.Assert(httpResp.StatusCode, checker.Equals, http.StatusNotFound) |
| 120 | 120 |
c.Assert(httpResp.Header.Get("Content-Type"), checker.Contains, "text/plain")
|
| ... | ... |
@@ -220,7 +220,7 @@ func (s *DockerSuite) TestUpdateStats(c *check.C) {
|
| 220 | 220 |
c.Assert(waitRun(name), checker.IsNil) |
| 221 | 221 |
|
| 222 | 222 |
getMemLimit := func(id string) uint64 {
|
| 223 |
- resp, body, err := request.Get(daemonHost(), fmt.Sprintf("/containers/%s/stats?stream=false", id))
|
|
| 223 |
+ resp, body, err := request.Get(fmt.Sprintf("/containers/%s/stats?stream=false", id))
|
|
| 224 | 224 |
c.Assert(err, checker.IsNil) |
| 225 | 225 |
c.Assert(resp.Header.Get("Content-Type"), checker.Equals, "application/json")
|
| 226 | 226 |
|
| ... | ... |
@@ -150,7 +150,7 @@ func (s *DockerSuite) TestDeprecatedStartWithTooLowMemoryLimit(c *check.C) {
|
| 150 | 150 |
"Memory": 524287 |
| 151 | 151 |
}` |
| 152 | 152 |
|
| 153 |
- res, body, err := request.Post(daemonHost(), formatV123StartAPIURL("/containers/"+containerID+"/start"), request.RawString(config), request.JSON)
|
|
| 153 |
+ res, body, err := request.Post(formatV123StartAPIURL("/containers/"+containerID+"/start"), request.RawString(config), request.JSON)
|
|
| 154 | 154 |
c.Assert(err, checker.IsNil) |
| 155 | 155 |
b, err2 := testutil.ReadBody(body) |
| 156 | 156 |
c.Assert(err2, checker.IsNil) |
| ... | ... |
@@ -169,7 +169,7 @@ func (s *DockerSuite) TestDeprecatedPostContainersStartWithoutLinksInHostConfig( |
| 169 | 169 |
hc := inspectFieldJSON(c, name, "HostConfig") |
| 170 | 170 |
config := `{"HostConfig":` + hc + `}`
|
| 171 | 171 |
|
| 172 |
- res, b, err := request.Post(daemonHost(), formatV123StartAPIURL("/containers/"+name+"/start"), request.RawString(config), request.JSON)
|
|
| 172 |
+ res, b, err := request.Post(formatV123StartAPIURL("/containers/"+name+"/start"), request.RawString(config), request.JSON)
|
|
| 173 | 173 |
c.Assert(err, checker.IsNil) |
| 174 | 174 |
c.Assert(res.StatusCode, checker.Equals, http.StatusNoContent) |
| 175 | 175 |
b.Close() |
| ... | ... |
@@ -187,7 +187,7 @@ func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfig(c * |
| 187 | 187 |
hc := inspectFieldJSON(c, name, "HostConfig") |
| 188 | 188 |
config := `{"HostConfig":` + hc + `}`
|
| 189 | 189 |
|
| 190 |
- res, b, err := request.Post(daemonHost(), formatV123StartAPIURL("/containers/"+name+"/start"), request.RawString(config), request.JSON)
|
|
| 190 |
+ res, b, err := request.Post(formatV123StartAPIURL("/containers/"+name+"/start"), request.RawString(config), request.JSON)
|
|
| 191 | 191 |
c.Assert(err, checker.IsNil) |
| 192 | 192 |
c.Assert(res.StatusCode, checker.Equals, http.StatusNoContent) |
| 193 | 193 |
b.Close() |
| ... | ... |
@@ -205,7 +205,7 @@ func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfigIdLi |
| 205 | 205 |
hc := inspectFieldJSON(c, name, "HostConfig") |
| 206 | 206 |
config := `{"HostConfig":` + hc + `}`
|
| 207 | 207 |
|
| 208 |
- res, b, err := request.Post(daemonHost(), formatV123StartAPIURL("/containers/"+name+"/start"), request.RawString(config), request.JSON)
|
|
| 208 |
+ res, b, err := request.Post(formatV123StartAPIURL("/containers/"+name+"/start"), request.RawString(config), request.JSON)
|
|
| 209 | 209 |
c.Assert(err, checker.IsNil) |
| 210 | 210 |
c.Assert(res.StatusCode, checker.Equals, http.StatusNoContent) |
| 211 | 211 |
b.Close() |
| ... | ... |
@@ -219,7 +219,7 @@ func (s *DockerSuite) TestDeprecatedStartWithNilDNS(c *check.C) {
|
| 219 | 219 |
|
| 220 | 220 |
config := `{"HostConfig": {"Dns": null}}`
|
| 221 | 221 |
|
| 222 |
- res, b, err := request.Post(daemonHost(), formatV123StartAPIURL("/containers/"+containerID+"/start"), request.RawString(config), request.JSON)
|
|
| 222 |
+ res, b, err := request.Post(formatV123StartAPIURL("/containers/"+containerID+"/start"), request.RawString(config), request.JSON)
|
|
| 223 | 223 |
c.Assert(err, checker.IsNil) |
| 224 | 224 |
c.Assert(res.StatusCode, checker.Equals, http.StatusNoContent) |
| 225 | 225 |
b.Close() |
| ... | ... |
@@ -22,7 +22,6 @@ import ( |
| 22 | 22 |
"github.com/docker/docker/api/types" |
| 23 | 23 |
"github.com/docker/docker/integration-cli/checker" |
| 24 | 24 |
"github.com/docker/docker/integration-cli/daemon" |
| 25 |
- "github.com/docker/docker/integration-cli/environment" |
|
| 26 | 25 |
"github.com/docker/docker/integration-cli/registry" |
| 27 | 26 |
"github.com/docker/docker/integration-cli/request" |
| 28 | 27 |
"github.com/docker/docker/pkg/stringutils" |
| ... | ... |
@@ -32,7 +31,7 @@ import ( |
| 32 | 32 |
|
| 33 | 33 |
// Deprecated |
| 34 | 34 |
func daemonHost() string {
|
| 35 |
- return environment.DaemonHost() |
|
| 35 |
+ return request.DaemonHost() |
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 | 38 |
// FIXME(vdemeester) move this away are remove ignoreNoSuchContainer bool |
| ... | ... |
@@ -4,13 +4,11 @@ import ( |
| 4 | 4 |
"encoding/json" |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"net/http" |
| 7 |
- "os" |
|
| 8 | 7 |
"strings" |
| 9 | 8 |
|
| 10 | 9 |
"github.com/docker/docker/api/types" |
| 11 | 10 |
volumetypes "github.com/docker/docker/api/types/volume" |
| 12 | 11 |
"github.com/docker/docker/integration-cli/request" |
| 13 |
- "github.com/docker/docker/opts" |
|
| 14 | 12 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 15 | 13 |
) |
| 16 | 14 |
|
| ... | ... |
@@ -111,7 +109,7 @@ func deleteAllVolumes(t testingT, dockerBinary string) {
|
| 111 | 111 |
} |
| 112 | 112 |
var errs []string |
| 113 | 113 |
for _, v := range volumes {
|
| 114 |
- status, b, err := request.SockRequest("DELETE", "/volumes/"+v.Name, nil, DaemonHost())
|
|
| 114 |
+ status, b, err := request.SockRequest("DELETE", "/volumes/"+v.Name, nil, request.DaemonHost())
|
|
| 115 | 115 |
if err != nil {
|
| 116 | 116 |
errs = append(errs, err.Error()) |
| 117 | 117 |
continue |
| ... | ... |
@@ -127,7 +125,7 @@ func deleteAllVolumes(t testingT, dockerBinary string) {
|
| 127 | 127 |
|
| 128 | 128 |
func getAllVolumes() ([]*types.Volume, error) {
|
| 129 | 129 |
var volumes volumetypes.VolumesListOKBody |
| 130 |
- _, b, err := request.SockRequest("GET", "/volumes", nil, DaemonHost())
|
|
| 130 |
+ _, b, err := request.SockRequest("GET", "/volumes", nil, request.DaemonHost())
|
|
| 131 | 131 |
if err != nil {
|
| 132 | 132 |
return nil, err |
| 133 | 133 |
} |
| ... | ... |
@@ -151,7 +149,7 @@ func deleteAllNetworks(t testingT, dockerBinary string, daemonPlatform string) {
|
| 151 | 151 |
// nat is a pre-defined network on Windows and cannot be removed |
| 152 | 152 |
continue |
| 153 | 153 |
} |
| 154 |
- status, b, err := request.SockRequest("DELETE", "/networks/"+n.Name, nil, DaemonHost())
|
|
| 154 |
+ status, b, err := request.SockRequest("DELETE", "/networks/"+n.Name, nil, request.DaemonHost())
|
|
| 155 | 155 |
if err != nil {
|
| 156 | 156 |
errs = append(errs, err.Error()) |
| 157 | 157 |
continue |
| ... | ... |
@@ -167,7 +165,7 @@ func deleteAllNetworks(t testingT, dockerBinary string, daemonPlatform string) {
|
| 167 | 167 |
|
| 168 | 168 |
func getAllNetworks() ([]types.NetworkResource, error) {
|
| 169 | 169 |
var networks []types.NetworkResource |
| 170 |
- _, b, err := request.SockRequest("GET", "/networks", nil, DaemonHost())
|
|
| 170 |
+ _, b, err := request.SockRequest("GET", "/networks", nil, request.DaemonHost())
|
|
| 171 | 171 |
if err != nil {
|
| 172 | 172 |
return nil, err |
| 173 | 173 |
} |
| ... | ... |
@@ -185,7 +183,7 @@ func deleteAllPlugins(t testingT, dockerBinary string) {
|
| 185 | 185 |
var errs []string |
| 186 | 186 |
for _, p := range plugins {
|
| 187 | 187 |
pluginName := p.Name |
| 188 |
- status, b, err := request.SockRequest("DELETE", "/plugins/"+pluginName+"?force=1", nil, DaemonHost())
|
|
| 188 |
+ status, b, err := request.SockRequest("DELETE", "/plugins/"+pluginName+"?force=1", nil, request.DaemonHost())
|
|
| 189 | 189 |
if err != nil {
|
| 190 | 190 |
errs = append(errs, err.Error()) |
| 191 | 191 |
continue |
| ... | ... |
@@ -201,7 +199,7 @@ func deleteAllPlugins(t testingT, dockerBinary string) {
|
| 201 | 201 |
|
| 202 | 202 |
func getAllPlugins() (types.PluginsListResponse, error) {
|
| 203 | 203 |
var plugins types.PluginsListResponse |
| 204 |
- _, b, err := request.SockRequest("GET", "/plugins", nil, DaemonHost())
|
|
| 204 |
+ _, b, err := request.SockRequest("GET", "/plugins", nil, request.DaemonHost())
|
|
| 205 | 205 |
if err != nil {
|
| 206 | 206 |
return nil, err |
| 207 | 207 |
} |
| ... | ... |
@@ -210,12 +208,3 @@ func getAllPlugins() (types.PluginsListResponse, error) {
|
| 210 | 210 |
} |
| 211 | 211 |
return plugins, nil |
| 212 | 212 |
} |
| 213 |
- |
|
| 214 |
-// DaemonHost return the daemon host string for this test execution |
|
| 215 |
-func DaemonHost() string {
|
|
| 216 |
- daemonURLStr := "unix://" + opts.DefaultUnixSocket |
|
| 217 |
- if daemonHostVar := os.Getenv("DOCKER_HOST"); daemonHostVar != "" {
|
|
| 218 |
- daemonURLStr = daemonHostVar |
|
| 219 |
- } |
|
| 220 |
- return daemonURLStr |
|
| 221 |
-} |
| ... | ... |
@@ -18,6 +18,7 @@ import ( |
| 18 | 18 |
"time" |
| 19 | 19 |
|
| 20 | 20 |
dclient "github.com/docker/docker/client" |
| 21 |
+ "github.com/docker/docker/opts" |
|
| 21 | 22 |
"github.com/docker/docker/pkg/ioutils" |
| 22 | 23 |
"github.com/docker/docker/pkg/testutil" |
| 23 | 24 |
"github.com/docker/go-connections/sockets" |
| ... | ... |
@@ -74,22 +75,27 @@ func JSONBody(data interface{}) func(*http.Request) error {
|
| 74 | 74 |
} |
| 75 | 75 |
|
| 76 | 76 |
// Post creates and execute a POST request on the specified host and endpoint, with the specified request modifiers |
| 77 |
-func Post(host, endpoint string, modifiers ...func(*http.Request) error) (*http.Response, io.ReadCloser, error) {
|
|
| 78 |
- return Do(host, endpoint, append(modifiers, Method(http.MethodPost))...) |
|
| 77 |
+func Post(endpoint string, modifiers ...func(*http.Request) error) (*http.Response, io.ReadCloser, error) {
|
|
| 78 |
+ return Do(endpoint, append(modifiers, Method(http.MethodPost))...) |
|
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 | 81 |
// Delete creates and execute a DELETE request on the specified host and endpoint, with the specified request modifiers |
| 82 |
-func Delete(host, endpoint string, modifiers ...func(*http.Request) error) (*http.Response, io.ReadCloser, error) {
|
|
| 83 |
- return Do(host, endpoint, append(modifiers, Method(http.MethodDelete))...) |
|
| 82 |
+func Delete(endpoint string, modifiers ...func(*http.Request) error) (*http.Response, io.ReadCloser, error) {
|
|
| 83 |
+ return Do(endpoint, append(modifiers, Method(http.MethodDelete))...) |
|
| 84 | 84 |
} |
| 85 | 85 |
|
| 86 | 86 |
// Get creates and execute a GET request on the specified host and endpoint, with the specified request modifiers |
| 87 |
-func Get(host, endpoint string, modifiers ...func(*http.Request) error) (*http.Response, io.ReadCloser, error) {
|
|
| 88 |
- return Do(host, endpoint, modifiers...) |
|
| 87 |
+func Get(endpoint string, modifiers ...func(*http.Request) error) (*http.Response, io.ReadCloser, error) {
|
|
| 88 |
+ return Do(endpoint, modifiers...) |
|
| 89 | 89 |
} |
| 90 | 90 |
|
| 91 |
-// Do creates and execute a request on the specified host and endpoint, with the specified request modifiers |
|
| 92 |
-func Do(host, endpoint string, modifiers ...func(*http.Request) error) (*http.Response, io.ReadCloser, error) {
|
|
| 91 |
+// Do creates and execute a request on the specified endpoint, with the specified request modifiers |
|
| 92 |
+func Do(endpoint string, modifiers ...func(*http.Request) error) (*http.Response, io.ReadCloser, error) {
|
|
| 93 |
+ return DoOnHost(DaemonHost(), endpoint, modifiers...) |
|
| 94 |
+} |
|
| 95 |
+ |
|
| 96 |
+// DoOnHost creates and execute a request on the specified host and endpoint, with the specified request modifiers |
|
| 97 |
+func DoOnHost(host, endpoint string, modifiers ...func(*http.Request) error) (*http.Response, io.ReadCloser, error) {
|
|
| 93 | 98 |
req, err := New(host, endpoint, modifiers...) |
| 94 | 99 |
if err != nil {
|
| 95 | 100 |
return nil, nil, err |
| ... | ... |
@@ -283,3 +289,12 @@ func getTLSConfig() (*tls.Config, error) {
|
| 283 | 283 |
|
| 284 | 284 |
return tlsConfig, nil |
| 285 | 285 |
} |
| 286 |
+ |
|
| 287 |
+// DaemonHost return the daemon host string for this test execution |
|
| 288 |
+func DaemonHost() string {
|
|
| 289 |
+ daemonURLStr := "unix://" + opts.DefaultUnixSocket |
|
| 290 |
+ if daemonHostVar := os.Getenv("DOCKER_HOST"); daemonHostVar != "" {
|
|
| 291 |
+ daemonURLStr = daemonHostVar |
|
| 292 |
+ } |
|
| 293 |
+ return daemonURLStr |
|
| 294 |
+} |