Update api/client file to use context

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 8567286ed65c8aca180b4590acf7d9ef61e15955
Component: engine
This commit is contained in:
Vincent Demeester
2016-03-16 20:19:22 +01:00
parent c7abc234c4
commit 44ad0dbdfd
34 changed files with 117 additions and 59 deletions

View File

@ -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 {