Browse Source

Update api/client file to use context

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Vincent Demeester 9 năm trước cách đây
mục cha
commit
8567286ed6

+ 4 - 2
api/client/attach.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"io"
 
+	"golang.org/x/net/context"
+
 	"github.com/Sirupsen/logrus"
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -24,7 +26,7 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
 
 	cmd.ParseFlags(args, true)
 
-	c, err := cli.client.ContainerInspect(cmd.Arg(0))
+	c, err := cli.client.ContainerInspect(context.Background(), cmd.Arg(0))
 	if err != nil {
 		return err
 	}
@@ -64,7 +66,7 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
 		defer signal.StopCatch(sigc)
 	}
 
-	resp, err := cli.client.ContainerAttach(options)
+	resp, err := cli.client.ContainerAttach(context.Background(), options)
 	if err != nil {
 		return err
 	}

+ 3 - 1
api/client/commit.go

@@ -5,6 +5,8 @@ import (
 	"errors"
 	"fmt"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	"github.com/docker/docker/opts"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -73,7 +75,7 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
 		Config:         config,
 	}
 
-	response, err := cli.client.ContainerCommit(options)
+	response, err := cli.client.ContainerCommit(context.Background(), options)
 	if err != nil {
 		return err
 	}

+ 1 - 1
api/client/cp.go

@@ -127,7 +127,7 @@ func splitCpArg(arg string) (container, path string) {
 }
 
 func (cli *DockerCli) statContainerPath(containerName, path string) (types.ContainerPathStat, error) {
-	return cli.client.ContainerStatPath(containerName, path)
+	return cli.client.ContainerStatPath(context.Background(), containerName, path)
 }
 
 func resolveLocalPath(localPath string) (absPath string, err error) {

+ 2 - 2
api/client/create.go

@@ -111,7 +111,7 @@ func (cli *DockerCli) createContainer(config *container.Config, hostConfig *cont
 	}
 
 	//create the container
-	response, err := cli.client.ContainerCreate(config, hostConfig, networkingConfig, name)
+	response, err := cli.client.ContainerCreate(context.Background(), config, hostConfig, networkingConfig, name)
 
 	//if image not found try to pull it
 	if err != nil {
@@ -129,7 +129,7 @@ func (cli *DockerCli) createContainer(config *container.Config, hostConfig *cont
 			}
 			// Retry
 			var retryErr error
-			response, retryErr = cli.client.ContainerCreate(config, hostConfig, networkingConfig, name)
+			response, retryErr = cli.client.ContainerCreate(context.Background(), config, hostConfig, networkingConfig, name)
 			if retryErr != nil {
 				return nil, retryErr
 			}

+ 3 - 1
api/client/diff.go

@@ -3,6 +3,8 @@ package client
 import (
 	"fmt"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	"github.com/docker/docker/pkg/archive"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -25,7 +27,7 @@ func (cli *DockerCli) CmdDiff(args ...string) error {
 		return fmt.Errorf("Container name cannot be empty")
 	}
 
-	changes, err := cli.client.ContainerDiff(cmd.Arg(0))
+	changes, err := cli.client.ContainerDiff(context.Background(), cmd.Arg(0))
 	if err != nil {
 		return err
 	}

+ 5 - 3
api/client/exec.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"io"
 
+	"golang.org/x/net/context"
+
 	"github.com/Sirupsen/logrus"
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -31,7 +33,7 @@ func (cli *DockerCli) CmdExec(args ...string) error {
 	// Send client escape keys
 	execConfig.DetachKeys = cli.configFile.DetachKeys
 
-	response, err := cli.client.ContainerExecCreate(*execConfig)
+	response, err := cli.client.ContainerExecCreate(context.Background(), *execConfig)
 	if err != nil {
 		return err
 	}
@@ -53,7 +55,7 @@ func (cli *DockerCli) CmdExec(args ...string) error {
 			Tty:    execConfig.Tty,
 		}
 
-		if err := cli.client.ContainerExecStart(execID, execStartCheck); err != nil {
+		if err := cli.client.ContainerExecStart(context.Background(), execID, execStartCheck); err != nil {
 			return err
 		}
 		// For now don't print this - wait for when we support exec wait()
@@ -82,7 +84,7 @@ func (cli *DockerCli) CmdExec(args ...string) error {
 		}
 	}
 
-	resp, err := cli.client.ContainerExecAttach(execID, *execConfig)
+	resp, err := cli.client.ContainerExecAttach(context.Background(), execID, *execConfig)
 	if err != nil {
 		return err
 	}

+ 3 - 1
api/client/history.go

@@ -7,6 +7,8 @@ import (
 	"text/tabwriter"
 	"time"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 	"github.com/docker/docker/pkg/stringid"
@@ -26,7 +28,7 @@ func (cli *DockerCli) CmdHistory(args ...string) error {
 
 	cmd.ParseFlags(args, true)
 
-	history, err := cli.client.ImageHistory(cmd.Arg(0))
+	history, err := cli.client.ImageHistory(context.Background(), cmd.Arg(0))
 	if err != nil {
 		return err
 	}

+ 3 - 1
api/client/images.go

@@ -1,6 +1,8 @@
 package client
 
 import (
+	"golang.org/x/net/context"
+
 	"github.com/docker/docker/api/client/formatter"
 	Cli "github.com/docker/docker/cli"
 	"github.com/docker/docker/opts"
@@ -48,7 +50,7 @@ func (cli *DockerCli) CmdImages(args ...string) error {
 		Filters:   imageFilterArgs,
 	}
 
-	images, err := cli.client.ImageList(options)
+	images, err := cli.client.ImageList(context.Background(), options)
 	if err != nil {
 		return err
 	}

+ 3 - 1
api/client/info.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	"github.com/docker/docker/pkg/ioutils"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -20,7 +22,7 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
 
 	cmd.ParseFlags(args, true)
 
-	info, err := cli.client.Info()
+	info, err := cli.client.Info(context.Background())
 	if err != nil {
 		return err
 	}

+ 6 - 4
api/client/inspect.go

@@ -3,6 +3,8 @@ package client
 import (
 	"fmt"
 
+	"golang.org/x/net/context"
+
 	"github.com/docker/docker/api/client/inspect"
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -41,23 +43,23 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
 
 func (cli *DockerCli) inspectContainers(getSize bool) inspectSearcher {
 	return func(ref string) (interface{}, []byte, error) {
-		return cli.client.ContainerInspectWithRaw(ref, getSize)
+		return cli.client.ContainerInspectWithRaw(context.Background(), ref, getSize)
 	}
 }
 
 func (cli *DockerCli) inspectImages(getSize bool) inspectSearcher {
 	return func(ref string) (interface{}, []byte, error) {
-		return cli.client.ImageInspectWithRaw(ref, getSize)
+		return cli.client.ImageInspectWithRaw(context.Background(), ref, getSize)
 	}
 }
 
 func (cli *DockerCli) inspectAll(getSize bool) inspectSearcher {
 	return func(ref string) (interface{}, []byte, error) {
-		c, rawContainer, err := cli.client.ContainerInspectWithRaw(ref, getSize)
+		c, rawContainer, err := cli.client.ContainerInspectWithRaw(context.Background(), ref, getSize)
 		if err != nil {
 			// Search for image with that id if a container doesn't exist.
 			if client.IsErrContainerNotFound(err) {
-				i, rawImage, err := cli.client.ImageInspectWithRaw(ref, getSize)
+				i, rawImage, err := cli.client.ImageInspectWithRaw(context.Background(), ref, getSize)
 				if err != nil {
 					if client.IsErrImageNotFound(err) {
 						return nil, nil, fmt.Errorf("Error: No such image or container: %s", ref)

+ 3 - 1
api/client/kill.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 )
@@ -20,7 +22,7 @@ func (cli *DockerCli) CmdKill(args ...string) error {
 
 	var errs []string
 	for _, name := range cmd.Args() {
-		if err := cli.client.ContainerKill(name, *signal); err != nil {
+		if err := cli.client.ContainerKill(context.Background(), name, *signal); err != nil {
 			errs = append(errs, err.Error())
 		} else {
 			fmt.Fprintf(cli.out, "%s\n", name)

+ 3 - 1
api/client/login.go

@@ -8,6 +8,8 @@ import (
 	"runtime"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	"github.com/docker/docker/cliconfig"
 	"github.com/docker/docker/cliconfig/credentials"
@@ -52,7 +54,7 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
 		return err
 	}
 
-	response, err := cli.client.RegistryLogin(authConfig)
+	response, err := cli.client.RegistryLogin(context.Background(), authConfig)
 	if err != nil {
 		return err
 	}

+ 1 - 1
api/client/logs.go

@@ -32,7 +32,7 @@ func (cli *DockerCli) CmdLogs(args ...string) error {
 
 	name := cmd.Arg(0)
 
-	c, err := cli.client.ContainerInspect(name)
+	c, err := cli.client.ContainerInspect(context.Background(), name)
 	if err != nil {
 		return err
 	}

+ 8 - 6
api/client/network.go

@@ -7,6 +7,8 @@ import (
 	"strings"
 	"text/tabwriter"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	"github.com/docker/docker/opts"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -82,7 +84,7 @@ func (cli *DockerCli) CmdNetworkCreate(args ...string) error {
 		EnableIPv6:     *flIPv6,
 	}
 
-	resp, err := cli.client.NetworkCreate(nc)
+	resp, err := cli.client.NetworkCreate(context.Background(), nc)
 	if err != nil {
 		return err
 	}
@@ -102,7 +104,7 @@ func (cli *DockerCli) CmdNetworkRm(args ...string) error {
 
 	status := 0
 	for _, net := range cmd.Args() {
-		if err := cli.client.NetworkRemove(net); err != nil {
+		if err := cli.client.NetworkRemove(context.Background(), net); err != nil {
 			fmt.Fprintf(cli.err, "%s\n", err)
 			status = 1
 			continue
@@ -137,7 +139,7 @@ func (cli *DockerCli) CmdNetworkConnect(args ...string) error {
 		Links:   flLinks.GetAll(),
 		Aliases: flAliases.GetAll(),
 	}
-	return cli.client.NetworkConnect(cmd.Arg(0), cmd.Arg(1), epConfig)
+	return cli.client.NetworkConnect(context.Background(), cmd.Arg(0), cmd.Arg(1), epConfig)
 }
 
 // CmdNetworkDisconnect disconnects a container from a network
@@ -151,7 +153,7 @@ func (cli *DockerCli) CmdNetworkDisconnect(args ...string) error {
 		return err
 	}
 
-	return cli.client.NetworkDisconnect(cmd.Arg(0), cmd.Arg(1), *force)
+	return cli.client.NetworkDisconnect(context.Background(), cmd.Arg(0), cmd.Arg(1), *force)
 }
 
 // CmdNetworkLs lists all the networks managed by docker daemon
@@ -184,7 +186,7 @@ func (cli *DockerCli) CmdNetworkLs(args ...string) error {
 		Filters: netFilterArgs,
 	}
 
-	networkResources, err := cli.client.NetworkList(options)
+	networkResources, err := cli.client.NetworkList(context.Background(), options)
 	if err != nil {
 		return err
 	}
@@ -236,7 +238,7 @@ func (cli *DockerCli) CmdNetworkInspect(args ...string) error {
 	}
 
 	inspectSearcher := func(name string) (interface{}, []byte, error) {
-		i, err := cli.client.NetworkInspect(name)
+		i, err := cli.client.NetworkInspect(context.Background(), name)
 		return i, nil, err
 	}
 

+ 3 - 1
api/client/pause.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 )
@@ -19,7 +21,7 @@ func (cli *DockerCli) CmdPause(args ...string) error {
 
 	var errs []string
 	for _, name := range cmd.Args() {
-		if err := cli.client.ContainerPause(name); err != nil {
+		if err := cli.client.ContainerPause(context.Background(), name); err != nil {
 			errs = append(errs, err.Error())
 		} else {
 			fmt.Fprintf(cli.out, "%s\n", name)

+ 3 - 1
api/client/port.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 	"github.com/docker/go-connections/nat"
@@ -19,7 +21,7 @@ func (cli *DockerCli) CmdPort(args ...string) error {
 
 	cmd.ParseFlags(args, true)
 
-	c, err := cli.client.ContainerInspect(cmd.Arg(0))
+	c, err := cli.client.ContainerInspect(context.Background(), cmd.Arg(0))
 	if err != nil {
 		return err
 	}

+ 3 - 1
api/client/ps.go

@@ -1,6 +1,8 @@
 package client
 
 import (
+	"golang.org/x/net/context"
+
 	"github.com/docker/docker/api/client/formatter"
 	Cli "github.com/docker/docker/cli"
 	"github.com/docker/docker/opts"
@@ -56,7 +58,7 @@ func (cli *DockerCli) CmdPs(args ...string) error {
 		Filter: psFilterArgs,
 	}
 
-	containers, err := cli.client.ContainerList(options)
+	containers, err := cli.client.ContainerList(context.Background(), options)
 	if err != nil {
 		return err
 	}

+ 3 - 1
api/client/rename.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 )
@@ -24,7 +26,7 @@ func (cli *DockerCli) CmdRename(args ...string) error {
 		return fmt.Errorf("Error: Neither old nor new names may be empty")
 	}
 
-	if err := cli.client.ContainerRename(oldName, newName); err != nil {
+	if err := cli.client.ContainerRename(context.Background(), oldName, newName); err != nil {
 		fmt.Fprintf(cli.err, "%s\n", err)
 		return fmt.Errorf("Error: failed to rename container named %s", oldName)
 	}

+ 3 - 1
api/client/restart.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 )
@@ -20,7 +22,7 @@ func (cli *DockerCli) CmdRestart(args ...string) error {
 
 	var errs []string
 	for _, name := range cmd.Args() {
-		if err := cli.client.ContainerRestart(name, *nSeconds); err != nil {
+		if err := cli.client.ContainerRestart(context.Background(), name, *nSeconds); err != nil {
 			errs = append(errs, err.Error())
 		} else {
 			fmt.Fprintf(cli.out, "%s\n", name)

+ 3 - 1
api/client/rm.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 	"github.com/docker/engine-api/types"
@@ -47,7 +49,7 @@ func (cli *DockerCli) removeContainer(containerID string, removeVolumes, removeL
 		RemoveLinks:   removeLinks,
 		Force:         force,
 	}
-	if err := cli.client.ContainerRemove(options); err != nil {
+	if err := cli.client.ContainerRemove(context.Background(), options); err != nil {
 		return err
 	}
 	return nil

+ 3 - 1
api/client/rmi.go

@@ -5,6 +5,8 @@ import (
 	"net/url"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 	"github.com/docker/engine-api/types"
@@ -37,7 +39,7 @@ func (cli *DockerCli) CmdRmi(args ...string) error {
 			PruneChildren: !*noprune,
 		}
 
-		dels, err := cli.client.ImageRemove(options)
+		dels, err := cli.client.ImageRemove(context.Background(), options)
 		if err != nil {
 			errs = append(errs, err.Error())
 		} else {

+ 3 - 3
api/client/run.go

@@ -203,7 +203,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
 			DetachKeys:  cli.configFile.DetachKeys,
 		}
 
-		resp, err := cli.client.ContainerAttach(options)
+		resp, err := cli.client.ContainerAttach(context.Background(), options)
 		if err != nil {
 			return err
 		}
@@ -227,7 +227,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
 	}
 
 	//start the container
-	if err := cli.client.ContainerStart(createResponse.ID); err != nil {
+	if err := cli.client.ContainerStart(context.Background(), createResponse.ID); err != nil {
 		cmd.ReportError(err.Error(), false)
 		return runStartContainerErr(err)
 	}
@@ -257,7 +257,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
 	// Attached mode
 	if *flAutoRemove {
 		// Warn user if they detached us
-		js, err := cli.client.ContainerInspect(createResponse.ID)
+		js, err := cli.client.ContainerInspect(context.Background(), createResponse.ID)
 		if err != nil {
 			return runStartContainerErr(err)
 		}

+ 3 - 1
api/client/search.go

@@ -7,6 +7,8 @@ import (
 	"strings"
 	"text/tabwriter"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 	"github.com/docker/docker/pkg/stringutils"
@@ -49,7 +51,7 @@ func (cli *DockerCli) CmdSearch(args ...string) error {
 		RegistryAuth: encodedAuth,
 	}
 
-	unorderedResults, err := cli.client.ImageSearch(options, requestPrivilege)
+	unorderedResults, err := cli.client.ImageSearch(context.Background(), options, requestPrivilege)
 	if err != nil {
 		return err
 	}

+ 7 - 5
api/client/start.go

@@ -6,6 +6,8 @@ import (
 	"os"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	"github.com/Sirupsen/logrus"
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -34,7 +36,7 @@ func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal {
 				continue
 			}
 
-			if err := cli.client.ContainerKill(cid, sig); err != nil {
+			if err := cli.client.ContainerKill(context.Background(), cid, sig); err != nil {
 				logrus.Debugf("Error sending signal: %s", err)
 			}
 		}
@@ -63,7 +65,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
 
 		// 2. Attach to the container.
 		containerID := cmd.Arg(0)
-		c, err := cli.client.ContainerInspect(containerID)
+		c, err := cli.client.ContainerInspect(context.Background(), containerID)
 		if err != nil {
 			return err
 		}
@@ -91,7 +93,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
 			in = cli.in
 		}
 
-		resp, err := cli.client.ContainerAttach(options)
+		resp, err := cli.client.ContainerAttach(context.Background(), options)
 		if err != nil {
 			return err
 		}
@@ -108,7 +110,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
 		})
 
 		// 3. Start the container.
-		if err := cli.client.ContainerStart(containerID); err != nil {
+		if err := cli.client.ContainerStart(context.Background(), containerID); err != nil {
 			return err
 		}
 
@@ -140,7 +142,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
 func (cli *DockerCli) startContainersWithoutAttachments(containerIDs []string) error {
 	var failedContainers []string
 	for _, containerID := range containerIDs {
-		if err := cli.client.ContainerStart(containerID); err != nil {
+		if err := cli.client.ContainerStart(context.Background(), containerID); err != nil {
 			fmt.Fprintf(cli.err, "%s\n", err)
 			failedContainers = append(failedContainers, containerID)
 		} else {

+ 1 - 1
api/client/stats.go

@@ -70,7 +70,7 @@ func (cli *DockerCli) CmdStats(args ...string) error {
 		options := types.ContainerListOptions{
 			All: *all,
 		}
-		cs, err := cli.client.ContainerList(options)
+		cs, err := cli.client.ContainerList(context.Background(), options)
 		if err != nil {
 			closeChan <- err
 		}

+ 3 - 1
api/client/stop.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 )
@@ -22,7 +24,7 @@ func (cli *DockerCli) CmdStop(args ...string) error {
 
 	var errs []string
 	for _, name := range cmd.Args() {
-		if err := cli.client.ContainerStop(name, *nSeconds); err != nil {
+		if err := cli.client.ContainerStop(context.Background(), name, *nSeconds); err != nil {
 			errs = append(errs, err.Error())
 		} else {
 			fmt.Fprintf(cli.out, "%s\n", name)

+ 3 - 1
api/client/tag.go

@@ -3,6 +3,8 @@ package client
 import (
 	"errors"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 	"github.com/docker/docker/reference"
@@ -40,5 +42,5 @@ func (cli *DockerCli) CmdTag(args ...string) error {
 		Force:          *force,
 	}
 
-	return cli.client.ImageTag(options)
+	return cli.client.ImageTag(context.Background(), options)
 }

+ 3 - 1
api/client/top.go

@@ -5,6 +5,8 @@ import (
 	"strings"
 	"text/tabwriter"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 )
@@ -23,7 +25,7 @@ func (cli *DockerCli) CmdTop(args ...string) error {
 		arguments = cmd.Args()[1:]
 	}
 
-	procList, err := cli.client.ContainerTop(cmd.Arg(0), arguments)
+	procList, err := cli.client.ContainerTop(context.Background(), cmd.Arg(0), arguments)
 	if err != nil {
 		return err
 	}

+ 3 - 1
api/client/trust.go

@@ -15,6 +15,8 @@ import (
 	"strconv"
 	"time"
 
+	"golang.org/x/net/context"
+
 	"github.com/Sirupsen/logrus"
 	"github.com/docker/distribution/digest"
 	"github.com/docker/distribution/registry/client/auth"
@@ -276,7 +278,7 @@ func (cli *DockerCli) tagTrusted(trustedRef reference.Canonical, ref reference.N
 		Force:          true,
 	}
 
-	return cli.client.ImageTag(options)
+	return cli.client.ImageTag(context.Background(), options)
 }
 
 func notaryError(repoName string, err error) error {

+ 3 - 1
api/client/unpause.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 )
@@ -19,7 +21,7 @@ func (cli *DockerCli) CmdUnpause(args ...string) error {
 
 	var errs []string
 	for _, name := range cmd.Args() {
-		if err := cli.client.ContainerUnpause(name); err != nil {
+		if err := cli.client.ContainerUnpause(context.Background(), name); err != nil {
 			errs = append(errs, err.Error())
 		} else {
 			fmt.Fprintf(cli.out, "%s\n", name)

+ 3 - 1
api/client/update.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	flag "github.com/docker/docker/pkg/mflag"
 	"github.com/docker/docker/runconfig/opts"
@@ -100,7 +102,7 @@ func (cli *DockerCli) CmdUpdate(args ...string) error {
 	names := cmd.Args()
 	var errs []string
 	for _, name := range names {
-		if err := cli.client.ContainerUpdate(name, updateConfig); err != nil {
+		if err := cli.client.ContainerUpdate(context.Background(), name, updateConfig); err != nil {
 			errs = append(errs, err.Error())
 		} else {
 			fmt.Fprintf(cli.out, "%s\n", name)

+ 7 - 5
api/client/utils.go

@@ -12,6 +12,8 @@ import (
 	"runtime"
 	"time"
 
+	"golang.org/x/net/context"
+
 	"github.com/Sirupsen/logrus"
 	"github.com/docker/docker/pkg/signal"
 	"github.com/docker/docker/pkg/term"
@@ -27,7 +29,7 @@ func (cli *DockerCli) electAuthServer() string {
 	// example a Linux client might be interacting with a Windows daemon, hence
 	// the default registry URL might be Windows specific.
 	serverAddress := registry.IndexServer
-	if info, err := cli.client.Info(); err != nil {
+	if info, err := cli.client.Info(context.Background()); err != nil {
 		fmt.Fprintf(cli.out, "Warning: failed to get default registry endpoint from daemon (%v). Using system default: %s\n", err, serverAddress)
 	} else {
 		serverAddress = info.IndexServerAddress
@@ -74,9 +76,9 @@ func (cli *DockerCli) resizeTtyTo(id string, height, width int, isExec bool) {
 
 	var err error
 	if isExec {
-		err = cli.client.ContainerExecResize(options)
+		err = cli.client.ContainerExecResize(context.Background(), options)
 	} else {
-		err = cli.client.ContainerResize(options)
+		err = cli.client.ContainerResize(context.Background(), options)
 	}
 
 	if err != nil {
@@ -87,7 +89,7 @@ func (cli *DockerCli) resizeTtyTo(id string, height, width int, isExec bool) {
 // getExitCode perform an inspect on the container. It returns
 // the running state and the exit code.
 func getExitCode(cli *DockerCli, containerID string) (bool, int, error) {
-	c, err := cli.client.ContainerInspect(containerID)
+	c, err := cli.client.ContainerInspect(context.Background(), containerID)
 	if err != nil {
 		// If we can't connect, then the daemon probably died.
 		if err != client.ErrConnectionFailed {
@@ -102,7 +104,7 @@ func getExitCode(cli *DockerCli, containerID string) (bool, int, error) {
 // getExecExitCode perform an inspect on the exec command. It returns
 // the running state and the exit code.
 func getExecExitCode(cli *DockerCli, execID string) (bool, int, error) {
-	resp, err := cli.client.ContainerExecInspect(execID)
+	resp, err := cli.client.ContainerExecInspect(context.Background(), execID)
 	if err != nil {
 		// If we can't connect, then the daemon probably died.
 		if err != client.ErrConnectionFailed {

+ 3 - 1
api/client/version.go

@@ -5,6 +5,8 @@ import (
 	"text/template"
 	"time"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	"github.com/docker/docker/dockerversion"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -67,7 +69,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
 		},
 	}
 
-	serverVersion, err := cli.client.ServerVersion()
+	serverVersion, err := cli.client.ServerVersion(context.Background())
 	if err == nil {
 		vd.Server = &serverVersion
 	}

+ 6 - 4
api/client/volume.go

@@ -5,6 +5,8 @@ import (
 	"sort"
 	"text/tabwriter"
 
+	"golang.org/x/net/context"
+
 	Cli "github.com/docker/docker/cli"
 	"github.com/docker/docker/opts"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -59,7 +61,7 @@ func (cli *DockerCli) CmdVolumeLs(args ...string) error {
 		}
 	}
 
-	volumes, err := cli.client.VolumeList(volFilterArgs)
+	volumes, err := cli.client.VolumeList(context.Background(), volFilterArgs)
 	if err != nil {
 		return err
 	}
@@ -108,7 +110,7 @@ func (cli *DockerCli) CmdVolumeInspect(args ...string) error {
 	}
 
 	inspectSearcher := func(name string) (interface{}, []byte, error) {
-		i, err := cli.client.VolumeInspect(name)
+		i, err := cli.client.VolumeInspect(context.Background(), name)
 		return i, nil, err
 	}
 
@@ -135,7 +137,7 @@ func (cli *DockerCli) CmdVolumeCreate(args ...string) error {
 		Name:       *flName,
 	}
 
-	vol, err := cli.client.VolumeCreate(volReq)
+	vol, err := cli.client.VolumeCreate(context.Background(), volReq)
 	if err != nil {
 		return err
 	}
@@ -155,7 +157,7 @@ func (cli *DockerCli) CmdVolumeRm(args ...string) error {
 	var status = 0
 
 	for _, name := range cmd.Args() {
-		if err := cli.client.VolumeRemove(name); err != nil {
+		if err := cli.client.VolumeRemove(context.Background(), name); err != nil {
 			fmt.Fprintf(cli.err, "%s\n", err)
 			status = 1
 			continue