Przeglądaj źródła

Lowercase http method functions.

Signed-off-by: David Calavera <david.calavera@gmail.com>
David Calavera 9 lat temu
rodzic
commit
d9a62c5f2b

+ 1 - 1
api/client/lib/container_commit.go

@@ -35,7 +35,7 @@ func (cli *Client) ContainerCommit(options types.ContainerCommitOptions) (types.
 		}
 	}
 
-	resp, err := cli.POST("/commit", query, config, nil)
+	resp, err := cli.post("/commit", query, config, nil)
 	if err != nil {
 		return response, err
 	}

+ 1 - 1
api/client/lib/container_create.go

@@ -18,7 +18,7 @@ func (cli *Client) ContainerCreate(config *runconfig.ContainerConfigWrapper, con
 		query.Set("name", containerName)
 	}
 
-	serverResp, err := cli.POST("/containers/create", query, config, nil)
+	serverResp, err := cli.post("/containers/create", query, config, nil)
 	if err != nil {
 		if serverResp != nil && serverResp.statusCode == 404 && strings.Contains(err.Error(), config.Image) {
 			return response, imageNotFoundError{config.Image}

+ 1 - 1
api/client/lib/container_inspect.go

@@ -8,7 +8,7 @@ import (
 
 // ContainerInspect returns the all the container information.
 func (cli *Client) ContainerInspect(containerID string) (types.ContainerJSON, error) {
-	serverResp, err := cli.GET("/containers/"+containerID+"/json", nil, nil)
+	serverResp, err := cli.get("/containers/"+containerID+"/json", nil, nil)
 	if err != nil {
 		return types.ContainerJSON{}, err
 	}

+ 1 - 1
api/client/lib/container_list.go

@@ -42,7 +42,7 @@ func (cli *Client) ContainerList(options types.ContainerListOptions) ([]types.Co
 		query.Set("filters", filterJSON)
 	}
 
-	resp, err := cli.GET("/containers/json", query, nil)
+	resp, err := cli.get("/containers/json", query, nil)
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
api/client/lib/container_remove.go

@@ -20,7 +20,7 @@ func (cli *Client) ContainerRemove(options types.ContainerRemoveOptions) error {
 		query.Set("force", "1")
 	}
 
-	resp, err := cli.DELETE("/containers/"+options.ContainerID, query, nil)
+	resp, err := cli.delete("/containers/"+options.ContainerID, query, nil)
 	ensureReaderClosed(resp)
 	return err
 }

+ 1 - 1
api/client/lib/container_rename.go

@@ -6,7 +6,7 @@ import "net/url"
 func (cli *Client) ContainerRename(containerID, newContainerName string) error {
 	query := url.Values{}
 	query.Set("name", newContainerName)
-	resp, err := cli.POST("/containers/"+containerID+"/rename", query, nil, nil)
+	resp, err := cli.post("/containers/"+containerID+"/rename", query, nil, nil)
 	ensureReaderClosed(resp)
 	return err
 }

+ 1 - 1
api/client/lib/container_restart.go

@@ -11,7 +11,7 @@ import (
 func (cli *Client) ContainerRestart(containerID string, timeout int) error {
 	query := url.Values{}
 	query.Set("t", strconv.Itoa(timeout))
-	resp, err := cli.POST("/containers"+containerID+"/restart", query, nil, nil)
+	resp, err := cli.post("/containers/"+containerID+"/restart", query, nil, nil)
 	ensureReaderClosed(resp)
 	return err
 }

+ 1 - 1
api/client/lib/container_stop.go

@@ -10,7 +10,7 @@ import (
 func (cli *Client) ContainerStop(containerID string, timeout int) error {
 	query := url.Values{}
 	query.Set("t", strconv.Itoa(timeout))
-	resp, err := cli.POST("/containers/"+containerID+"/stop", query, nil, nil)
+	resp, err := cli.post("/containers/"+containerID+"/stop", query, nil, nil)
 	ensureReaderClosed(resp)
 	return err
 }

+ 1 - 1
api/client/lib/container_unpause.go

@@ -2,7 +2,7 @@ package lib
 
 // ContainerUnpause resumes the process execution within a container
 func (cli *Client) ContainerUnpause(containerID string) error {
-	resp, err := cli.POST("/containers/"+containerID+"/unpause", nil, nil, nil)
+	resp, err := cli.post("/containers/"+containerID+"/unpause", nil, nil, nil)
 	ensureReaderClosed(resp)
 	return err
 }

+ 3 - 3
api/client/lib/copy.go

@@ -19,7 +19,7 @@ func (cli *Client) ContainerStatPath(containerID, path string) (types.ContainerP
 	query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API.
 
 	urlStr := fmt.Sprintf("/containers/%s/archive", containerID)
-	response, err := cli.HEAD(urlStr, query, nil)
+	response, err := cli.head(urlStr, query, nil)
 	if err != nil {
 		return types.ContainerPathStat{}, err
 	}
@@ -38,7 +38,7 @@ func (cli *Client) CopyToContainer(options types.CopyToContainerOptions) error {
 
 	path := fmt.Sprintf("/containers/%s/archive", options.ContainerID)
 
-	response, err := cli.PUT(path, query, options.Content, nil)
+	response, err := cli.putRaw(path, query, options.Content, nil)
 	if err != nil {
 		return err
 	}
@@ -58,7 +58,7 @@ func (cli *Client) CopyFromContainer(containerID, srcPath string) (io.ReadCloser
 	query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API.
 
 	apiPath := fmt.Sprintf("/containers/%s/archive", containerID)
-	response, err := cli.GET(apiPath, query, nil)
+	response, err := cli.get(apiPath, query, nil)
 	if err != nil {
 		return nil, types.ContainerPathStat{}, err
 	}

+ 1 - 1
api/client/lib/diff.go

@@ -11,7 +11,7 @@ import (
 func (cli *Client) ContainerDiff(containerID string) ([]types.ContainerChange, error) {
 	var changes []types.ContainerChange
 
-	serverResp, err := cli.GET("/containers/"+containerID+"/changes", url.Values{}, nil)
+	serverResp, err := cli.get("/containers/"+containerID+"/changes", url.Values{}, nil)
 	if err != nil {
 		return changes, err
 	}

+ 1 - 1
api/client/lib/events.go

@@ -38,7 +38,7 @@ func (cli *Client) Events(options types.EventsOptions) (io.ReadCloser, error) {
 		query.Set("filters", filterJSON)
 	}
 
-	serverResponse, err := cli.GET("/events", query, nil)
+	serverResponse, err := cli.get("/events", query, nil)
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
api/client/lib/export.go

@@ -9,7 +9,7 @@ import (
 // and returns them as a io.ReadCloser. It's up to the caller
 // to close the stream.
 func (cli *Client) ContainerExport(containerID string) (io.ReadCloser, error) {
-	serverResp, err := cli.GET("/containers/"+containerID+"/export", url.Values{}, nil)
+	serverResp, err := cli.get("/containers/"+containerID+"/export", url.Values{}, nil)
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
api/client/lib/history.go

@@ -10,7 +10,7 @@ import (
 // ImageHistory returns the changes in an image in history format.
 func (cli *Client) ImageHistory(imageID string) ([]types.ImageHistory, error) {
 	var history []types.ImageHistory
-	serverResp, err := cli.GET("/images/"+imageID+"/history", url.Values{}, nil)
+	serverResp, err := cli.get("/images/"+imageID+"/history", url.Values{}, nil)
 	if err != nil {
 		return history, err
 	}

+ 1 - 1
api/client/lib/image_build.go

@@ -30,7 +30,7 @@ func (cli *Client) ImageBuild(options types.ImageBuildOptions) (types.ImageBuild
 	headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf))
 	headers.Set("Content-Type", "application/tar")
 
-	serverResp, err := cli.POSTRaw("/build", query, options.Context, headers)
+	serverResp, err := cli.postRaw("/build", query, options.Context, headers)
 	if err != nil {
 		return types.ImageBuildResponse{}, err
 	}

+ 1 - 1
api/client/lib/image_create.go

@@ -15,7 +15,7 @@ func (cli *Client) ImageCreate(options types.ImageCreateOptions) (io.ReadCloser,
 	query.Set("tag", options.Tag)
 
 	headers := map[string][]string{"X-Registry-Auth": {options.RegistryAuth}}
-	resp, err := cli.POST("/images/create", query, nil, headers)
+	resp, err := cli.post("/images/create", query, nil, headers)
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
api/client/lib/image_import.go

@@ -19,7 +19,7 @@ func (cli *Client) ImageImport(options types.ImageImportOptions) (io.ReadCloser,
 		query.Add("changes", change)
 	}
 
-	resp, err := cli.POSTRaw("/images/create", query, options.Source, nil)
+	resp, err := cli.postRaw("/images/create", query, options.Source, nil)
 	if err != nil {
 		return nil, err
 	}

+ 2 - 1
api/client/lib/image_list.go

@@ -12,6 +12,7 @@ import (
 func (cli *Client) ImageList(options types.ImageListOptions) ([]types.Image, error) {
 	var images []types.Image
 	query := url.Values{}
+
 	if options.Filters.Len() > 0 {
 		filterJSON, err := filters.ToParam(options.Filters)
 		if err != nil {
@@ -27,7 +28,7 @@ func (cli *Client) ImageList(options types.ImageListOptions) ([]types.Image, err
 		query.Set("all", "1")
 	}
 
-	serverResp, err := cli.GET("/images/json?", query, nil)
+	serverResp, err := cli.get("/images/json", query, nil)
 	if err != nil {
 		return images, err
 	}

+ 1 - 1
api/client/lib/image_load.go

@@ -9,7 +9,7 @@ import (
 // It's up to the caller to close the io.ReadCloser returned by
 // this function.
 func (cli *Client) ImageLoad(input io.Reader) (io.ReadCloser, error) {
-	resp, err := cli.POSTRaw("/images/load", url.Values{}, input, nil)
+	resp, err := cli.postRaw("/images/load", url.Values{}, input, nil)
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
api/client/lib/image_remove.go

@@ -18,7 +18,7 @@ func (cli *Client) ImageRemove(options types.ImageRemoveOptions) ([]types.ImageD
 		query.Set("noprune", "1")
 	}
 
-	resp, err := cli.DELETE("/images/"+options.ImageID, query, nil)
+	resp, err := cli.delete("/images/"+options.ImageID, query, nil)
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
api/client/lib/image_save.go

@@ -12,7 +12,7 @@ func (cli *Client) ImageSave(imageIDs []string) (io.ReadCloser, error) {
 		"names": imageIDs,
 	}
 
-	resp, err := cli.GET("/images/get", query, nil)
+	resp, err := cli.get("/images/get", query, nil)
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
api/client/lib/image_tag.go

@@ -15,7 +15,7 @@ func (cli *Client) ImageTag(options types.ImageTagOptions) error {
 		query.Set("force", "1")
 	}
 
-	resp, err := cli.POST("/images/"+options.ImageID+"/tag", query, nil, nil)
+	resp, err := cli.post("/images/"+options.ImageID+"/tag", query, nil, nil)
 	ensureReaderClosed(resp)
 	return err
 }

+ 1 - 1
api/client/lib/info.go

@@ -11,7 +11,7 @@ import (
 // Info returns information about the docker server.
 func (cli *Client) Info() (types.Info, error) {
 	var info types.Info
-	serverResp, err := cli.GET("/info", url.Values{}, nil)
+	serverResp, err := cli.get("/info", url.Values{}, nil)
 	if err != nil {
 		return info, err
 	}

+ 1 - 1
api/client/lib/kill.go

@@ -7,7 +7,7 @@ func (cli *Client) ContainerKill(containerID, signal string) error {
 	query := url.Values{}
 	query.Set("signal", signal)
 
-	resp, err := cli.POST("/containers/"+containerID+"/kill", query, nil, nil)
+	resp, err := cli.post("/containers/"+containerID+"/kill", query, nil, nil)
 	ensureReaderClosed(resp)
 	return err
 }

+ 1 - 1
api/client/lib/login.go

@@ -12,7 +12,7 @@ import (
 // RegistryLogin authenticates the docker server with a given docker registry.
 // It returns UnauthorizerError when the authentication fails.
 func (cli *Client) RegistryLogin(auth cliconfig.AuthConfig) (types.AuthResponse, error) {
-	resp, err := cli.POST("/auth", url.Values{}, auth, nil)
+	resp, err := cli.post("/auth", url.Values{}, auth, nil)
 
 	if resp != nil && resp.statusCode == http.StatusUnauthorized {
 		return types.AuthResponse{}, unauthorizedError{err}

+ 1 - 1
api/client/lib/logs.go

@@ -38,7 +38,7 @@ func (cli *Client) ContainerLogs(options types.ContainerLogsOptions) (io.ReadClo
 	}
 	query.Set("tail", options.Tail)
 
-	resp, err := cli.GET("/containers/"+options.ContainerID+"/logs", query, nil)
+	resp, err := cli.get("/containers/"+options.ContainerID+"/logs", query, nil)
 	if err != nil {
 		return nil, err
 	}

+ 6 - 6
api/client/lib/network.go

@@ -9,7 +9,7 @@ import (
 // NetworkCreate creates a new network in the docker host.
 func (cli *Client) NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error) {
 	var response types.NetworkCreateResponse
-	serverResp, err := cli.POST("/networks/create", nil, options, nil)
+	serverResp, err := cli.post("/networks/create", nil, options, nil)
 	if err != nil {
 		return response, err
 	}
@@ -21,7 +21,7 @@ func (cli *Client) NetworkCreate(options types.NetworkCreate) (types.NetworkCrea
 
 // NetworkRemove removes an existent network from the docker host.
 func (cli *Client) NetworkRemove(networkID string) error {
-	resp, err := cli.DELETE("/networks/"+networkID, nil, nil)
+	resp, err := cli.delete("/networks/"+networkID, nil, nil)
 	ensureReaderClosed(resp)
 	return err
 }
@@ -29,7 +29,7 @@ func (cli *Client) NetworkRemove(networkID string) error {
 // NetworkConnect connects a container to an existent network in the docker host.
 func (cli *Client) NetworkConnect(networkID, containerID string) error {
 	nc := types.NetworkConnect{containerID}
-	resp, err := cli.POST("/networks/"+networkID+"/connect", nil, nc, nil)
+	resp, err := cli.post("/networks/"+networkID+"/connect", nil, nc, nil)
 	ensureReaderClosed(resp)
 	return err
 }
@@ -37,7 +37,7 @@ func (cli *Client) NetworkConnect(networkID, containerID string) error {
 // NetworkDisconnect disconnects a container from an existent network in the docker host.
 func (cli *Client) NetworkDisconnect(networkID, containerID string) error {
 	nc := types.NetworkConnect{containerID}
-	resp, err := cli.POST("/networks/"+networkID+"/disconnect", nil, nc, nil)
+	resp, err := cli.post("/networks/"+networkID+"/disconnect", nil, nc, nil)
 	ensureReaderClosed(resp)
 	return err
 }
@@ -45,7 +45,7 @@ func (cli *Client) NetworkDisconnect(networkID, containerID string) error {
 // NetworkList returns the list of networks configured in the docker host.
 func (cli *Client) NetworkList() ([]types.NetworkResource, error) {
 	var networkResources []types.NetworkResource
-	resp, err := cli.GET("/networks", nil, nil)
+	resp, err := cli.get("/networks", nil, nil)
 	if err != nil {
 		return networkResources, err
 	}
@@ -57,7 +57,7 @@ func (cli *Client) NetworkList() ([]types.NetworkResource, error) {
 // NetworkInspect returns the information for a specific network configured in the docker host.
 func (cli *Client) NetworkInspect(networkID string) (types.NetworkResource, error) {
 	var networkResource types.NetworkResource
-	resp, err := cli.GET("/networks/"+networkID, nil, nil)
+	resp, err := cli.get("/networks/"+networkID, nil, nil)
 	if err != nil {
 		return networkResource, err
 	}

+ 23 - 18
api/client/lib/request.go

@@ -13,44 +13,49 @@ import (
 	"github.com/docker/docker/utils"
 )
 
-// ServerResponse is a wrapper for http API responses.
-type ServerResponse struct {
+// serverResponse is a wrapper for http API responses.
+type serverResponse struct {
 	body       io.ReadCloser
 	header     http.Header
 	statusCode int
 }
 
-// HEAD sends an http request to the docker API using the method HEAD.
-func (cli *Client) HEAD(path string, query url.Values, headers map[string][]string) (*ServerResponse, error) {
+// head sends an http request to the docker API using the method HEAD.
+func (cli *Client) head(path string, query url.Values, headers map[string][]string) (*serverResponse, error) {
 	return cli.sendRequest("HEAD", path, query, nil, headers)
 }
 
-// GET sends an http request to the docker API using the method GET.
-func (cli *Client) GET(path string, query url.Values, headers map[string][]string) (*ServerResponse, error) {
+// get sends an http request to the docker API using the method GET.
+func (cli *Client) get(path string, query url.Values, headers map[string][]string) (*serverResponse, error) {
 	return cli.sendRequest("GET", path, query, nil, headers)
 }
 
-// POST sends an http request to the docker API using the method POST.
-func (cli *Client) POST(path string, query url.Values, body interface{}, headers map[string][]string) (*ServerResponse, error) {
+// post sends an http request to the docker API using the method POST.
+func (cli *Client) post(path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) {
 	return cli.sendRequest("POST", path, query, body, headers)
 }
 
-// POSTRaw sends the raw input to the docker API using the method POST.
-func (cli *Client) POSTRaw(path string, query url.Values, body io.Reader, headers map[string][]string) (*ServerResponse, error) {
+// postRaw sends the raw input to the docker API using the method POST.
+func (cli *Client) postRaw(path string, query url.Values, body io.Reader, headers map[string][]string) (*serverResponse, error) {
 	return cli.sendClientRequest("POST", path, query, body, headers)
 }
 
-// PUT sends an http request to the docker API using the method PUT.
-func (cli *Client) PUT(path string, query url.Values, body interface{}, headers map[string][]string) (*ServerResponse, error) {
+// put sends an http request to the docker API using the method PUT.
+func (cli *Client) put(path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) {
 	return cli.sendRequest("PUT", path, query, body, headers)
 }
 
-// DELETE sends an http request to the docker API using the method DELETE.
-func (cli *Client) DELETE(path string, query url.Values, headers map[string][]string) (*ServerResponse, error) {
+// putRaw sends the raw input to the docker API using the method PUT.
+func (cli *Client) putRaw(path string, query url.Values, body io.Reader, headers map[string][]string) (*serverResponse, error) {
+	return cli.sendClientRequest("PUT", path, query, body, headers)
+}
+
+// delete sends an http request to the docker API using the method DELETE.
+func (cli *Client) delete(path string, query url.Values, headers map[string][]string) (*serverResponse, error) {
 	return cli.sendRequest("DELETE", path, query, nil, headers)
 }
 
-func (cli *Client) sendRequest(method, path string, query url.Values, body interface{}, headers map[string][]string) (*ServerResponse, error) {
+func (cli *Client) sendRequest(method, path string, query url.Values, body interface{}, headers map[string][]string) (*serverResponse, error) {
 	params, err := encodeData(body)
 	if err != nil {
 		return nil, err
@@ -66,8 +71,8 @@ func (cli *Client) sendRequest(method, path string, query url.Values, body inter
 	return cli.sendClientRequest(method, path, query, params, headers)
 }
 
-func (cli *Client) sendClientRequest(method, path string, query url.Values, in io.Reader, headers map[string][]string) (*ServerResponse, error) {
-	serverResp := &ServerResponse{
+func (cli *Client) sendClientRequest(method, path string, query url.Values, in io.Reader, headers map[string][]string) (*serverResponse, error) {
+	serverResp := &serverResponse{
 		body:       nil,
 		statusCode: -1,
 	}
@@ -148,7 +153,7 @@ func encodeData(data interface{}) (*bytes.Buffer, error) {
 	return params, nil
 }
 
-func ensureReaderClosed(response *ServerResponse) {
+func ensureReaderClosed(response *serverResponse) {
 	if response != nil && response.body != nil {
 		response.body.Close()
 	}

+ 1 - 1
api/client/lib/version.go

@@ -23,7 +23,7 @@ func (cli *Client) SystemVersion() (types.VersionResponse, error) {
 		Experimental: utils.ExperimentalBuild(),
 	}
 
-	resp, err := cli.GET("/version", nil, nil)
+	resp, err := cli.get("/version", nil, nil)
 	if err != nil {
 		return types.VersionResponse{Client: client}, err
 	}

+ 4 - 4
api/client/lib/volume.go

@@ -20,7 +20,7 @@ func (cli *Client) VolumeList(filter filters.Args) (types.VolumesListResponse, e
 		}
 		query.Set("filters", filterJSON)
 	}
-	resp, err := cli.GET("/volumes", query, nil)
+	resp, err := cli.get("/volumes", query, nil)
 	if err != nil {
 		return volumes, err
 	}
@@ -33,7 +33,7 @@ func (cli *Client) VolumeList(filter filters.Args) (types.VolumesListResponse, e
 // VolumeInspect returns the information about a specific volume in the docker host.
 func (cli *Client) VolumeInspect(volumeID string) (types.Volume, error) {
 	var volume types.Volume
-	resp, err := cli.GET("/volumes"+volumeID, nil, nil)
+	resp, err := cli.get("/volumes/"+volumeID, nil, nil)
 	if err != nil {
 		return volume, err
 	}
@@ -45,7 +45,7 @@ func (cli *Client) VolumeInspect(volumeID string) (types.Volume, error) {
 // VolumeCreate creates a volume in the docker host.
 func (cli *Client) VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error) {
 	var volume types.Volume
-	resp, err := cli.POST("/volumes/create", nil, options, nil)
+	resp, err := cli.post("/volumes/create", nil, options, nil)
 	if err != nil {
 		return volume, err
 	}
@@ -56,7 +56,7 @@ func (cli *Client) VolumeCreate(options types.VolumeCreateRequest) (types.Volume
 
 // VolumeRemove removes a volume from the docker host.
 func (cli *Client) VolumeRemove(volumeID string) error {
-	resp, err := cli.DELETE("/volumes"+volumeID, nil, nil)
+	resp, err := cli.delete("/volumes/"+volumeID, nil, nil)
 	ensureReaderClosed(resp)
 	return err
 }