mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
client: Use string concatenation instead of Sprintf
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
parent
096eeb3e75
commit
44c9ccc069
4 changed files with 7 additions and 10 deletions
|
@ -216,9 +216,9 @@ func (cli *Client) getAPIPath(p string, query url.Values) string {
|
||||||
var apiPath string
|
var apiPath string
|
||||||
if cli.version != "" {
|
if cli.version != "" {
|
||||||
v := strings.TrimPrefix(cli.version, "v")
|
v := strings.TrimPrefix(cli.version, "v")
|
||||||
apiPath = fmt.Sprintf("%s/v%s%s", cli.basePath, v, p)
|
apiPath = cli.basePath + "/v" + v + p
|
||||||
} else {
|
} else {
|
||||||
apiPath = fmt.Sprintf("%s%s", cli.basePath, p)
|
apiPath = cli.basePath + p
|
||||||
}
|
}
|
||||||
|
|
||||||
u := &url.URL{
|
u := &url.URL{
|
||||||
|
|
|
@ -20,7 +20,7 @@ func (cli *Client) ContainerStatPath(ctx context.Context, containerID, path stri
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API.
|
query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API.
|
||||||
|
|
||||||
urlStr := fmt.Sprintf("/containers/%s/archive", containerID)
|
urlStr := "/containers/" + containerID + "/archive"
|
||||||
response, err := cli.head(ctx, urlStr, query, nil)
|
response, err := cli.head(ctx, urlStr, query, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.ContainerPathStat{}, err
|
return types.ContainerPathStat{}, err
|
||||||
|
@ -42,7 +42,7 @@ func (cli *Client) CopyToContainer(ctx context.Context, container, path string,
|
||||||
query.Set("copyUIDGID", "true")
|
query.Set("copyUIDGID", "true")
|
||||||
}
|
}
|
||||||
|
|
||||||
apiPath := fmt.Sprintf("/containers/%s/archive", container)
|
apiPath := "/containers/" + container + "/archive"
|
||||||
|
|
||||||
response, err := cli.putRaw(ctx, apiPath, query, content, nil)
|
response, err := cli.putRaw(ctx, apiPath, query, content, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -63,7 +63,7 @@ func (cli *Client) CopyFromContainer(ctx context.Context, container, srcPath str
|
||||||
query := make(url.Values, 1)
|
query := make(url.Values, 1)
|
||||||
query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API.
|
query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API.
|
||||||
|
|
||||||
apiPath := fmt.Sprintf("/containers/%s/archive", container)
|
apiPath := "/containers/" + container + "/archive"
|
||||||
response, err := cli.get(ctx, apiPath, query, nil)
|
response, err := cli.get(ctx, apiPath, query, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, types.ContainerPathStat{}, err
|
return nil, types.ContainerPathStat{}, err
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
@ -10,7 +8,7 @@ import (
|
||||||
// Ping pings the server and returns the value of the "Docker-Experimental", "OS-Type" & "API-Version" headers
|
// Ping pings the server and returns the value of the "Docker-Experimental", "OS-Type" & "API-Version" headers
|
||||||
func (cli *Client) Ping(ctx context.Context) (types.Ping, error) {
|
func (cli *Client) Ping(ctx context.Context) (types.Ping, error) {
|
||||||
var ping types.Ping
|
var ping types.Ping
|
||||||
req, err := cli.buildRequest("GET", fmt.Sprintf("%s/_ping", cli.basePath), nil, nil)
|
req, err := cli.buildRequest("GET", cli.basePath+"/_ping", nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ping, err
|
return ping, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
@ -33,5 +32,5 @@ func (cli *Client) PluginUpgrade(ctx context.Context, name string, options types
|
||||||
|
|
||||||
func (cli *Client) tryPluginUpgrade(ctx context.Context, query url.Values, privileges types.PluginPrivileges, name, registryAuth string) (serverResponse, error) {
|
func (cli *Client) tryPluginUpgrade(ctx context.Context, query url.Values, privileges types.PluginPrivileges, name, registryAuth string) (serverResponse, error) {
|
||||||
headers := map[string][]string{"X-Registry-Auth": {registryAuth}}
|
headers := map[string][]string{"X-Registry-Auth": {registryAuth}}
|
||||||
return cli.post(ctx, fmt.Sprintf("/plugins/%s/upgrade", name), query, privileges, headers)
|
return cli.post(ctx, "/plugins/"+name+"/upgrade", query, privileges, headers)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue