Signed-off-by: David Calavera <david.calavera@gmail.com>
| ... | ... |
@@ -35,7 +35,7 @@ func (cli *Client) ContainerCommit(options types.ContainerCommitOptions) (types. |
| 35 | 35 |
} |
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 |
- resp, err := cli.POST("/commit", query, config, nil)
|
|
| 38 |
+ resp, err := cli.post("/commit", query, config, nil)
|
|
| 39 | 39 |
if err != nil {
|
| 40 | 40 |
return response, err |
| 41 | 41 |
} |
| ... | ... |
@@ -18,7 +18,7 @@ func (cli *Client) ContainerCreate(config *runconfig.ContainerConfigWrapper, con |
| 18 | 18 |
query.Set("name", containerName)
|
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
- serverResp, err := cli.POST("/containers/create", query, config, nil)
|
|
| 21 |
+ serverResp, err := cli.post("/containers/create", query, config, nil)
|
|
| 22 | 22 |
if err != nil {
|
| 23 | 23 |
if serverResp != nil && serverResp.statusCode == 404 && strings.Contains(err.Error(), config.Image) {
|
| 24 | 24 |
return response, imageNotFoundError{config.Image}
|
| ... | ... |
@@ -8,7 +8,7 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
// ContainerInspect returns the all the container information. |
| 10 | 10 |
func (cli *Client) ContainerInspect(containerID string) (types.ContainerJSON, error) {
|
| 11 |
- serverResp, err := cli.GET("/containers/"+containerID+"/json", nil, nil)
|
|
| 11 |
+ serverResp, err := cli.get("/containers/"+containerID+"/json", nil, nil)
|
|
| 12 | 12 |
if err != nil {
|
| 13 | 13 |
return types.ContainerJSON{}, err
|
| 14 | 14 |
} |
| ... | ... |
@@ -42,7 +42,7 @@ func (cli *Client) ContainerList(options types.ContainerListOptions) ([]types.Co |
| 42 | 42 |
query.Set("filters", filterJSON)
|
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 |
- resp, err := cli.GET("/containers/json", query, nil)
|
|
| 45 |
+ resp, err := cli.get("/containers/json", query, nil)
|
|
| 46 | 46 |
if err != nil {
|
| 47 | 47 |
return nil, err |
| 48 | 48 |
} |
| ... | ... |
@@ -20,7 +20,7 @@ func (cli *Client) ContainerRemove(options types.ContainerRemoveOptions) error {
|
| 20 | 20 |
query.Set("force", "1")
|
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
- resp, err := cli.DELETE("/containers/"+options.ContainerID, query, nil)
|
|
| 23 |
+ resp, err := cli.delete("/containers/"+options.ContainerID, query, nil)
|
|
| 24 | 24 |
ensureReaderClosed(resp) |
| 25 | 25 |
return err |
| 26 | 26 |
} |
| ... | ... |
@@ -6,7 +6,7 @@ import "net/url" |
| 6 | 6 |
func (cli *Client) ContainerRename(containerID, newContainerName string) error {
|
| 7 | 7 |
query := url.Values{}
|
| 8 | 8 |
query.Set("name", newContainerName)
|
| 9 |
- resp, err := cli.POST("/containers/"+containerID+"/rename", query, nil, nil)
|
|
| 9 |
+ resp, err := cli.post("/containers/"+containerID+"/rename", query, nil, nil)
|
|
| 10 | 10 |
ensureReaderClosed(resp) |
| 11 | 11 |
return err |
| 12 | 12 |
} |
| ... | ... |
@@ -11,7 +11,7 @@ import ( |
| 11 | 11 |
func (cli *Client) ContainerRestart(containerID string, timeout int) error {
|
| 12 | 12 |
query := url.Values{}
|
| 13 | 13 |
query.Set("t", strconv.Itoa(timeout))
|
| 14 |
- resp, err := cli.POST("/containers"+containerID+"/restart", query, nil, nil)
|
|
| 14 |
+ resp, err := cli.post("/containers/"+containerID+"/restart", query, nil, nil)
|
|
| 15 | 15 |
ensureReaderClosed(resp) |
| 16 | 16 |
return err |
| 17 | 17 |
} |
| ... | ... |
@@ -10,7 +10,7 @@ import ( |
| 10 | 10 |
func (cli *Client) ContainerStop(containerID string, timeout int) error {
|
| 11 | 11 |
query := url.Values{}
|
| 12 | 12 |
query.Set("t", strconv.Itoa(timeout))
|
| 13 |
- resp, err := cli.POST("/containers/"+containerID+"/stop", query, nil, nil)
|
|
| 13 |
+ resp, err := cli.post("/containers/"+containerID+"/stop", query, nil, nil)
|
|
| 14 | 14 |
ensureReaderClosed(resp) |
| 15 | 15 |
return err |
| 16 | 16 |
} |
| ... | ... |
@@ -2,7 +2,7 @@ package lib |
| 2 | 2 |
|
| 3 | 3 |
// ContainerUnpause resumes the process execution within a container |
| 4 | 4 |
func (cli *Client) ContainerUnpause(containerID string) error {
|
| 5 |
- resp, err := cli.POST("/containers/"+containerID+"/unpause", nil, nil, nil)
|
|
| 5 |
+ resp, err := cli.post("/containers/"+containerID+"/unpause", nil, nil, nil)
|
|
| 6 | 6 |
ensureReaderClosed(resp) |
| 7 | 7 |
return err |
| 8 | 8 |
} |
| ... | ... |
@@ -19,7 +19,7 @@ func (cli *Client) ContainerStatPath(containerID, path string) (types.ContainerP |
| 19 | 19 |
query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API.
|
| 20 | 20 |
|
| 21 | 21 |
urlStr := fmt.Sprintf("/containers/%s/archive", containerID)
|
| 22 |
- response, err := cli.HEAD(urlStr, query, nil) |
|
| 22 |
+ response, err := cli.head(urlStr, query, nil) |
|
| 23 | 23 |
if err != nil {
|
| 24 | 24 |
return types.ContainerPathStat{}, err
|
| 25 | 25 |
} |
| ... | ... |
@@ -38,7 +38,7 @@ func (cli *Client) CopyToContainer(options types.CopyToContainerOptions) error {
|
| 38 | 38 |
|
| 39 | 39 |
path := fmt.Sprintf("/containers/%s/archive", options.ContainerID)
|
| 40 | 40 |
|
| 41 |
- response, err := cli.PUT(path, query, options.Content, nil) |
|
| 41 |
+ response, err := cli.putRaw(path, query, options.Content, nil) |
|
| 42 | 42 |
if err != nil {
|
| 43 | 43 |
return err |
| 44 | 44 |
} |
| ... | ... |
@@ -58,7 +58,7 @@ func (cli *Client) CopyFromContainer(containerID, srcPath string) (io.ReadCloser |
| 58 | 58 |
query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API.
|
| 59 | 59 |
|
| 60 | 60 |
apiPath := fmt.Sprintf("/containers/%s/archive", containerID)
|
| 61 |
- response, err := cli.GET(apiPath, query, nil) |
|
| 61 |
+ response, err := cli.get(apiPath, query, nil) |
|
| 62 | 62 |
if err != nil {
|
| 63 | 63 |
return nil, types.ContainerPathStat{}, err
|
| 64 | 64 |
} |
| ... | ... |
@@ -11,7 +11,7 @@ import ( |
| 11 | 11 |
func (cli *Client) ContainerDiff(containerID string) ([]types.ContainerChange, error) {
|
| 12 | 12 |
var changes []types.ContainerChange |
| 13 | 13 |
|
| 14 |
- serverResp, err := cli.GET("/containers/"+containerID+"/changes", url.Values{}, nil)
|
|
| 14 |
+ serverResp, err := cli.get("/containers/"+containerID+"/changes", url.Values{}, nil)
|
|
| 15 | 15 |
if err != nil {
|
| 16 | 16 |
return changes, err |
| 17 | 17 |
} |
| ... | ... |
@@ -38,7 +38,7 @@ func (cli *Client) Events(options types.EventsOptions) (io.ReadCloser, error) {
|
| 38 | 38 |
query.Set("filters", filterJSON)
|
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
- serverResponse, err := cli.GET("/events", query, nil)
|
|
| 41 |
+ serverResponse, err := cli.get("/events", query, nil)
|
|
| 42 | 42 |
if err != nil {
|
| 43 | 43 |
return nil, err |
| 44 | 44 |
} |
| ... | ... |
@@ -9,7 +9,7 @@ import ( |
| 9 | 9 |
// and returns them as a io.ReadCloser. It's up to the caller |
| 10 | 10 |
// to close the stream. |
| 11 | 11 |
func (cli *Client) ContainerExport(containerID string) (io.ReadCloser, error) {
|
| 12 |
- serverResp, err := cli.GET("/containers/"+containerID+"/export", url.Values{}, nil)
|
|
| 12 |
+ serverResp, err := cli.get("/containers/"+containerID+"/export", url.Values{}, nil)
|
|
| 13 | 13 |
if err != nil {
|
| 14 | 14 |
return nil, err |
| 15 | 15 |
} |
| ... | ... |
@@ -10,7 +10,7 @@ import ( |
| 10 | 10 |
// ImageHistory returns the changes in an image in history format. |
| 11 | 11 |
func (cli *Client) ImageHistory(imageID string) ([]types.ImageHistory, error) {
|
| 12 | 12 |
var history []types.ImageHistory |
| 13 |
- serverResp, err := cli.GET("/images/"+imageID+"/history", url.Values{}, nil)
|
|
| 13 |
+ serverResp, err := cli.get("/images/"+imageID+"/history", url.Values{}, nil)
|
|
| 14 | 14 |
if err != nil {
|
| 15 | 15 |
return history, err |
| 16 | 16 |
} |
| ... | ... |
@@ -30,7 +30,7 @@ func (cli *Client) ImageBuild(options types.ImageBuildOptions) (types.ImageBuild |
| 30 | 30 |
headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf))
|
| 31 | 31 |
headers.Set("Content-Type", "application/tar")
|
| 32 | 32 |
|
| 33 |
- serverResp, err := cli.POSTRaw("/build", query, options.Context, headers)
|
|
| 33 |
+ serverResp, err := cli.postRaw("/build", query, options.Context, headers)
|
|
| 34 | 34 |
if err != nil {
|
| 35 | 35 |
return types.ImageBuildResponse{}, err
|
| 36 | 36 |
} |
| ... | ... |
@@ -15,7 +15,7 @@ func (cli *Client) ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, |
| 15 | 15 |
query.Set("tag", options.Tag)
|
| 16 | 16 |
|
| 17 | 17 |
headers := map[string][]string{"X-Registry-Auth": {options.RegistryAuth}}
|
| 18 |
- resp, err := cli.POST("/images/create", query, nil, headers)
|
|
| 18 |
+ resp, err := cli.post("/images/create", query, nil, headers)
|
|
| 19 | 19 |
if err != nil {
|
| 20 | 20 |
return nil, err |
| 21 | 21 |
} |
| ... | ... |
@@ -19,7 +19,7 @@ func (cli *Client) ImageImport(options types.ImageImportOptions) (io.ReadCloser, |
| 19 | 19 |
query.Add("changes", change)
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
- resp, err := cli.POSTRaw("/images/create", query, options.Source, nil)
|
|
| 22 |
+ resp, err := cli.postRaw("/images/create", query, options.Source, nil)
|
|
| 23 | 23 |
if err != nil {
|
| 24 | 24 |
return nil, err |
| 25 | 25 |
} |
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
func (cli *Client) ImageList(options types.ImageListOptions) ([]types.Image, error) {
|
| 13 | 13 |
var images []types.Image |
| 14 | 14 |
query := url.Values{}
|
| 15 |
+ |
|
| 15 | 16 |
if options.Filters.Len() > 0 {
|
| 16 | 17 |
filterJSON, err := filters.ToParam(options.Filters) |
| 17 | 18 |
if err != nil {
|
| ... | ... |
@@ -27,7 +28,7 @@ func (cli *Client) ImageList(options types.ImageListOptions) ([]types.Image, err |
| 27 | 27 |
query.Set("all", "1")
|
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
- serverResp, err := cli.GET("/images/json?", query, nil)
|
|
| 30 |
+ serverResp, err := cli.get("/images/json", query, nil)
|
|
| 31 | 31 |
if err != nil {
|
| 32 | 32 |
return images, err |
| 33 | 33 |
} |
| ... | ... |
@@ -9,7 +9,7 @@ import ( |
| 9 | 9 |
// It's up to the caller to close the io.ReadCloser returned by |
| 10 | 10 |
// this function. |
| 11 | 11 |
func (cli *Client) ImageLoad(input io.Reader) (io.ReadCloser, error) {
|
| 12 |
- resp, err := cli.POSTRaw("/images/load", url.Values{}, input, nil)
|
|
| 12 |
+ resp, err := cli.postRaw("/images/load", url.Values{}, input, nil)
|
|
| 13 | 13 |
if err != nil {
|
| 14 | 14 |
return nil, err |
| 15 | 15 |
} |
| ... | ... |
@@ -18,7 +18,7 @@ func (cli *Client) ImageRemove(options types.ImageRemoveOptions) ([]types.ImageD |
| 18 | 18 |
query.Set("noprune", "1")
|
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
- resp, err := cli.DELETE("/images/"+options.ImageID, query, nil)
|
|
| 21 |
+ resp, err := cli.delete("/images/"+options.ImageID, query, nil)
|
|
| 22 | 22 |
if err != nil {
|
| 23 | 23 |
return nil, err |
| 24 | 24 |
} |
| ... | ... |
@@ -15,7 +15,7 @@ func (cli *Client) ImageTag(options types.ImageTagOptions) error {
|
| 15 | 15 |
query.Set("force", "1")
|
| 16 | 16 |
} |
| 17 | 17 |
|
| 18 |
- resp, err := cli.POST("/images/"+options.ImageID+"/tag", query, nil, nil)
|
|
| 18 |
+ resp, err := cli.post("/images/"+options.ImageID+"/tag", query, nil, nil)
|
|
| 19 | 19 |
ensureReaderClosed(resp) |
| 20 | 20 |
return err |
| 21 | 21 |
} |
| ... | ... |
@@ -11,7 +11,7 @@ import ( |
| 11 | 11 |
// Info returns information about the docker server. |
| 12 | 12 |
func (cli *Client) Info() (types.Info, error) {
|
| 13 | 13 |
var info types.Info |
| 14 |
- serverResp, err := cli.GET("/info", url.Values{}, nil)
|
|
| 14 |
+ serverResp, err := cli.get("/info", url.Values{}, nil)
|
|
| 15 | 15 |
if err != nil {
|
| 16 | 16 |
return info, err |
| 17 | 17 |
} |
| ... | ... |
@@ -7,7 +7,7 @@ func (cli *Client) ContainerKill(containerID, signal string) error {
|
| 7 | 7 |
query := url.Values{}
|
| 8 | 8 |
query.Set("signal", signal)
|
| 9 | 9 |
|
| 10 |
- resp, err := cli.POST("/containers/"+containerID+"/kill", query, nil, nil)
|
|
| 10 |
+ resp, err := cli.post("/containers/"+containerID+"/kill", query, nil, nil)
|
|
| 11 | 11 |
ensureReaderClosed(resp) |
| 12 | 12 |
return err |
| 13 | 13 |
} |
| ... | ... |
@@ -12,7 +12,7 @@ import ( |
| 12 | 12 |
// RegistryLogin authenticates the docker server with a given docker registry. |
| 13 | 13 |
// It returns UnauthorizerError when the authentication fails. |
| 14 | 14 |
func (cli *Client) RegistryLogin(auth cliconfig.AuthConfig) (types.AuthResponse, error) {
|
| 15 |
- resp, err := cli.POST("/auth", url.Values{}, auth, nil)
|
|
| 15 |
+ resp, err := cli.post("/auth", url.Values{}, auth, nil)
|
|
| 16 | 16 |
|
| 17 | 17 |
if resp != nil && resp.statusCode == http.StatusUnauthorized {
|
| 18 | 18 |
return types.AuthResponse{}, unauthorizedError{err}
|
| ... | ... |
@@ -38,7 +38,7 @@ func (cli *Client) ContainerLogs(options types.ContainerLogsOptions) (io.ReadClo |
| 38 | 38 |
} |
| 39 | 39 |
query.Set("tail", options.Tail)
|
| 40 | 40 |
|
| 41 |
- resp, err := cli.GET("/containers/"+options.ContainerID+"/logs", query, nil)
|
|
| 41 |
+ resp, err := cli.get("/containers/"+options.ContainerID+"/logs", query, nil)
|
|
| 42 | 42 |
if err != nil {
|
| 43 | 43 |
return nil, err |
| 44 | 44 |
} |
| ... | ... |
@@ -9,7 +9,7 @@ import ( |
| 9 | 9 |
// NetworkCreate creates a new network in the docker host. |
| 10 | 10 |
func (cli *Client) NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
| 11 | 11 |
var response types.NetworkCreateResponse |
| 12 |
- serverResp, err := cli.POST("/networks/create", nil, options, nil)
|
|
| 12 |
+ serverResp, err := cli.post("/networks/create", nil, options, nil)
|
|
| 13 | 13 |
if err != nil {
|
| 14 | 14 |
return response, err |
| 15 | 15 |
} |
| ... | ... |
@@ -21,7 +21,7 @@ func (cli *Client) NetworkCreate(options types.NetworkCreate) (types.NetworkCrea |
| 21 | 21 |
|
| 22 | 22 |
// NetworkRemove removes an existent network from the docker host. |
| 23 | 23 |
func (cli *Client) NetworkRemove(networkID string) error {
|
| 24 |
- resp, err := cli.DELETE("/networks/"+networkID, nil, nil)
|
|
| 24 |
+ resp, err := cli.delete("/networks/"+networkID, nil, nil)
|
|
| 25 | 25 |
ensureReaderClosed(resp) |
| 26 | 26 |
return err |
| 27 | 27 |
} |
| ... | ... |
@@ -29,7 +29,7 @@ func (cli *Client) NetworkRemove(networkID string) error {
|
| 29 | 29 |
// NetworkConnect connects a container to an existent network in the docker host. |
| 30 | 30 |
func (cli *Client) NetworkConnect(networkID, containerID string) error {
|
| 31 | 31 |
nc := types.NetworkConnect{containerID}
|
| 32 |
- resp, err := cli.POST("/networks/"+networkID+"/connect", nil, nc, nil)
|
|
| 32 |
+ resp, err := cli.post("/networks/"+networkID+"/connect", nil, nc, nil)
|
|
| 33 | 33 |
ensureReaderClosed(resp) |
| 34 | 34 |
return err |
| 35 | 35 |
} |
| ... | ... |
@@ -37,7 +37,7 @@ func (cli *Client) NetworkConnect(networkID, containerID string) error {
|
| 37 | 37 |
// NetworkDisconnect disconnects a container from an existent network in the docker host. |
| 38 | 38 |
func (cli *Client) NetworkDisconnect(networkID, containerID string) error {
|
| 39 | 39 |
nc := types.NetworkConnect{containerID}
|
| 40 |
- resp, err := cli.POST("/networks/"+networkID+"/disconnect", nil, nc, nil)
|
|
| 40 |
+ resp, err := cli.post("/networks/"+networkID+"/disconnect", nil, nc, nil)
|
|
| 41 | 41 |
ensureReaderClosed(resp) |
| 42 | 42 |
return err |
| 43 | 43 |
} |
| ... | ... |
@@ -45,7 +45,7 @@ func (cli *Client) NetworkDisconnect(networkID, containerID string) error {
|
| 45 | 45 |
// NetworkList returns the list of networks configured in the docker host. |
| 46 | 46 |
func (cli *Client) NetworkList() ([]types.NetworkResource, error) {
|
| 47 | 47 |
var networkResources []types.NetworkResource |
| 48 |
- resp, err := cli.GET("/networks", nil, nil)
|
|
| 48 |
+ resp, err := cli.get("/networks", nil, nil)
|
|
| 49 | 49 |
if err != nil {
|
| 50 | 50 |
return networkResources, err |
| 51 | 51 |
} |
| ... | ... |
@@ -57,7 +57,7 @@ func (cli *Client) NetworkList() ([]types.NetworkResource, error) {
|
| 57 | 57 |
// NetworkInspect returns the information for a specific network configured in the docker host. |
| 58 | 58 |
func (cli *Client) NetworkInspect(networkID string) (types.NetworkResource, error) {
|
| 59 | 59 |
var networkResource types.NetworkResource |
| 60 |
- resp, err := cli.GET("/networks/"+networkID, nil, nil)
|
|
| 60 |
+ resp, err := cli.get("/networks/"+networkID, nil, nil)
|
|
| 61 | 61 |
if err != nil {
|
| 62 | 62 |
return networkResource, err |
| 63 | 63 |
} |
| ... | ... |
@@ -13,44 +13,49 @@ import ( |
| 13 | 13 |
"github.com/docker/docker/utils" |
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 |
-// ServerResponse is a wrapper for http API responses. |
|
| 17 |
-type ServerResponse struct {
|
|
| 16 |
+// serverResponse is a wrapper for http API responses. |
|
| 17 |
+type serverResponse struct {
|
|
| 18 | 18 |
body io.ReadCloser |
| 19 | 19 |
header http.Header |
| 20 | 20 |
statusCode int |
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
-// HEAD sends an http request to the docker API using the method HEAD. |
|
| 24 |
-func (cli *Client) HEAD(path string, query url.Values, headers map[string][]string) (*ServerResponse, error) {
|
|
| 23 |
+// head sends an http request to the docker API using the method HEAD. |
|
| 24 |
+func (cli *Client) head(path string, query url.Values, headers map[string][]string) (*serverResponse, error) {
|
|
| 25 | 25 |
return cli.sendRequest("HEAD", path, query, nil, headers)
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 |
-// GET sends an http request to the docker API using the method GET. |
|
| 29 |
-func (cli *Client) GET(path string, query url.Values, headers map[string][]string) (*ServerResponse, error) {
|
|
| 28 |
+// get sends an http request to the docker API using the method GET. |
|
| 29 |
+func (cli *Client) get(path string, query url.Values, headers map[string][]string) (*serverResponse, error) {
|
|
| 30 | 30 |
return cli.sendRequest("GET", path, query, nil, headers)
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 |
-// POST sends an http request to the docker API using the method POST. |
|
| 34 |
-func (cli *Client) POST(path string, query url.Values, body interface{}, headers map[string][]string) (*ServerResponse, error) {
|
|
| 33 |
+// post sends an http request to the docker API using the method POST. |
|
| 34 |
+func (cli *Client) post(path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) {
|
|
| 35 | 35 |
return cli.sendRequest("POST", path, query, body, headers)
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 |
-// POSTRaw sends the raw input to the docker API using the method POST. |
|
| 39 |
-func (cli *Client) POSTRaw(path string, query url.Values, body io.Reader, headers map[string][]string) (*ServerResponse, error) {
|
|
| 38 |
+// postRaw sends the raw input to the docker API using the method POST. |
|
| 39 |
+func (cli *Client) postRaw(path string, query url.Values, body io.Reader, headers map[string][]string) (*serverResponse, error) {
|
|
| 40 | 40 |
return cli.sendClientRequest("POST", path, query, body, headers)
|
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 |
-// PUT sends an http request to the docker API using the method PUT. |
|
| 44 |
-func (cli *Client) PUT(path string, query url.Values, body interface{}, headers map[string][]string) (*ServerResponse, error) {
|
|
| 43 |
+// put sends an http request to the docker API using the method PUT. |
|
| 44 |
+func (cli *Client) put(path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) {
|
|
| 45 | 45 |
return cli.sendRequest("PUT", path, query, body, headers)
|
| 46 | 46 |
} |
| 47 | 47 |
|
| 48 |
-// DELETE sends an http request to the docker API using the method DELETE. |
|
| 49 |
-func (cli *Client) DELETE(path string, query url.Values, headers map[string][]string) (*ServerResponse, error) {
|
|
| 48 |
+// putRaw sends the raw input to the docker API using the method PUT. |
|
| 49 |
+func (cli *Client) putRaw(path string, query url.Values, body io.Reader, headers map[string][]string) (*serverResponse, error) {
|
|
| 50 |
+ return cli.sendClientRequest("PUT", path, query, body, headers)
|
|
| 51 |
+} |
|
| 52 |
+ |
|
| 53 |
+// delete sends an http request to the docker API using the method DELETE. |
|
| 54 |
+func (cli *Client) delete(path string, query url.Values, headers map[string][]string) (*serverResponse, error) {
|
|
| 50 | 55 |
return cli.sendRequest("DELETE", path, query, nil, headers)
|
| 51 | 56 |
} |
| 52 | 57 |
|
| 53 |
-func (cli *Client) sendRequest(method, path string, query url.Values, body interface{}, headers map[string][]string) (*ServerResponse, error) {
|
|
| 58 |
+func (cli *Client) sendRequest(method, path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) {
|
|
| 54 | 59 |
params, err := encodeData(body) |
| 55 | 60 |
if err != nil {
|
| 56 | 61 |
return nil, err |
| ... | ... |
@@ -66,8 +71,8 @@ func (cli *Client) sendRequest(method, path string, query url.Values, body inter |
| 66 | 66 |
return cli.sendClientRequest(method, path, query, params, headers) |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 |
-func (cli *Client) sendClientRequest(method, path string, query url.Values, in io.Reader, headers map[string][]string) (*ServerResponse, error) {
|
|
| 70 |
- serverResp := &ServerResponse{
|
|
| 69 |
+func (cli *Client) sendClientRequest(method, path string, query url.Values, in io.Reader, headers map[string][]string) (*serverResponse, error) {
|
|
| 70 |
+ serverResp := &serverResponse{
|
|
| 71 | 71 |
body: nil, |
| 72 | 72 |
statusCode: -1, |
| 73 | 73 |
} |
| ... | ... |
@@ -148,7 +153,7 @@ func encodeData(data interface{}) (*bytes.Buffer, error) {
|
| 148 | 148 |
return params, nil |
| 149 | 149 |
} |
| 150 | 150 |
|
| 151 |
-func ensureReaderClosed(response *ServerResponse) {
|
|
| 151 |
+func ensureReaderClosed(response *serverResponse) {
|
|
| 152 | 152 |
if response != nil && response.body != nil {
|
| 153 | 153 |
response.body.Close() |
| 154 | 154 |
} |
| ... | ... |
@@ -23,7 +23,7 @@ func (cli *Client) SystemVersion() (types.VersionResponse, error) {
|
| 23 | 23 |
Experimental: utils.ExperimentalBuild(), |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
- resp, err := cli.GET("/version", nil, nil)
|
|
| 26 |
+ resp, err := cli.get("/version", nil, nil)
|
|
| 27 | 27 |
if err != nil {
|
| 28 | 28 |
return types.VersionResponse{Client: client}, err
|
| 29 | 29 |
} |
| ... | ... |
@@ -20,7 +20,7 @@ func (cli *Client) VolumeList(filter filters.Args) (types.VolumesListResponse, e |
| 20 | 20 |
} |
| 21 | 21 |
query.Set("filters", filterJSON)
|
| 22 | 22 |
} |
| 23 |
- resp, err := cli.GET("/volumes", query, nil)
|
|
| 23 |
+ resp, err := cli.get("/volumes", query, nil)
|
|
| 24 | 24 |
if err != nil {
|
| 25 | 25 |
return volumes, err |
| 26 | 26 |
} |
| ... | ... |
@@ -33,7 +33,7 @@ func (cli *Client) VolumeList(filter filters.Args) (types.VolumesListResponse, e |
| 33 | 33 |
// VolumeInspect returns the information about a specific volume in the docker host. |
| 34 | 34 |
func (cli *Client) VolumeInspect(volumeID string) (types.Volume, error) {
|
| 35 | 35 |
var volume types.Volume |
| 36 |
- resp, err := cli.GET("/volumes"+volumeID, nil, nil)
|
|
| 36 |
+ resp, err := cli.get("/volumes/"+volumeID, nil, nil)
|
|
| 37 | 37 |
if err != nil {
|
| 38 | 38 |
return volume, err |
| 39 | 39 |
} |
| ... | ... |
@@ -45,7 +45,7 @@ func (cli *Client) VolumeInspect(volumeID string) (types.Volume, error) {
|
| 45 | 45 |
// VolumeCreate creates a volume in the docker host. |
| 46 | 46 |
func (cli *Client) VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error) {
|
| 47 | 47 |
var volume types.Volume |
| 48 |
- resp, err := cli.POST("/volumes/create", nil, options, nil)
|
|
| 48 |
+ resp, err := cli.post("/volumes/create", nil, options, nil)
|
|
| 49 | 49 |
if err != nil {
|
| 50 | 50 |
return volume, err |
| 51 | 51 |
} |
| ... | ... |
@@ -56,7 +56,7 @@ func (cli *Client) VolumeCreate(options types.VolumeCreateRequest) (types.Volume |
| 56 | 56 |
|
| 57 | 57 |
// VolumeRemove removes a volume from the docker host. |
| 58 | 58 |
func (cli *Client) VolumeRemove(volumeID string) error {
|
| 59 |
- resp, err := cli.DELETE("/volumes"+volumeID, nil, nil)
|
|
| 59 |
+ resp, err := cli.delete("/volumes/"+volumeID, nil, nil)
|
|
| 60 | 60 |
ensureReaderClosed(resp) |
| 61 | 61 |
return err |
| 62 | 62 |
} |