From 0082310aa5e5680cada4e41ddcd9fdec8d104770 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 29 Sep 2017 14:18:19 +0200 Subject: [PATCH] Fixes for updated dependencies Signed-off-by: Sebastiaan van Stijn --- cli/command/container/cp.go | 2 +- cli/command/container/exec.go | 32 ++++++++++++++----------- cli/command/container/run.go | 33 +++++++++++++------------- cli/command/container/start.go | 38 +++++++++++++++++------------- cli/command/image/build.go | 4 ++-- cli/command/image/build_session.go | 4 +++- cli/command/plugin/install.go | 14 +++++++---- 7 files changed, 72 insertions(+), 55 deletions(-) diff --git a/cli/command/container/cp.go b/cli/command/container/cp.go index 17a4030135..2f054b12e2 100644 --- a/cli/command/container/cp.go +++ b/cli/command/container/cp.go @@ -113,7 +113,7 @@ func resolveLocalPath(localPath string) (absPath string, err error) { return } - return archive.PreserveTrailingDotOrSeparator(absPath, localPath), nil + return archive.PreserveTrailingDotOrSeparator(absPath, localPath, filepath.Separator), nil } func copyFromContainer(ctx context.Context, dockerCli *command.DockerCli, srcContainer, srcPath, dstPath string, cpParam *cpConfig) (err error) { diff --git a/cli/command/container/exec.go b/cli/command/container/exec.go index f6860db578..8eb57cff7f 100644 --- a/cli/command/container/exec.go +++ b/cli/command/container/exec.go @@ -10,7 +10,6 @@ import ( "github.com/docker/cli/opts" "github.com/docker/docker/api/types" apiclient "github.com/docker/docker/client" - "github.com/docker/docker/pkg/promise" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -106,7 +105,6 @@ func interactiveExec(ctx context.Context, dockerCli command.Cli, execConfig *typ var ( out, stderr io.Writer in io.ReadCloser - errCh chan error ) if execConfig.AttachStdin { @@ -129,19 +127,25 @@ func interactiveExec(ctx context.Context, dockerCli command.Cli, execConfig *typ return err } defer resp.Close() - errCh = promise.Go(func() error { - streamer := hijackedIOStreamer{ - streams: dockerCli, - inputStream: in, - outputStream: out, - errorStream: stderr, - resp: resp, - tty: execConfig.Tty, - detachKeys: execConfig.DetachKeys, - } - return streamer.stream(ctx) - }) + errCh := make(chan error, 1) + + go func() { + defer close(errCh) + errCh <- func() error { + streamer := hijackedIOStreamer{ + streams: dockerCli, + inputStream: in, + outputStream: out, + errorStream: stderr, + resp: resp, + tty: execConfig.Tty, + detachKeys: execConfig.DetachKeys, + } + + return streamer.stream(ctx) + }() + }() if execConfig.Tty && dockerCli.In().IsTerminal() { if err := MonitorTtySize(ctx, dockerCli, execID, true); err != nil { diff --git a/cli/command/container/run.go b/cli/command/container/run.go index 7ebea722dc..c7aa60d6ab 100644 --- a/cli/command/container/run.go +++ b/cli/command/container/run.go @@ -15,7 +15,6 @@ import ( "github.com/docker/cli/opts" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" - "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/signal" "github.com/docker/docker/pkg/term" "github.com/pkg/errors" @@ -291,22 +290,24 @@ func attachContainer( return nil, errAttach } - *errCh = promise.Go(func() error { - streamer := hijackedIOStreamer{ - streams: dockerCli, - inputStream: in, - outputStream: out, - errorStream: cerr, - resp: resp, - tty: config.Tty, - detachKeys: options.DetachKeys, - } + go func() { + *errCh <- func() error { + streamer := hijackedIOStreamer{ + streams: dockerCli, + inputStream: in, + outputStream: out, + errorStream: cerr, + resp: resp, + tty: config.Tty, + detachKeys: options.DetachKeys, + } - if errHijack := streamer.stream(ctx); errHijack != nil { - return errHijack - } - return errAttach - }) + if errHijack := streamer.stream(ctx); errHijack != nil { + return errHijack + } + return errAttach + }() + }() return resp.Close, nil } diff --git a/cli/command/container/start.go b/cli/command/container/start.go index 6cd4751117..0717fb4a3b 100644 --- a/cli/command/container/start.go +++ b/cli/command/container/start.go @@ -9,7 +9,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/docker/api/types" - "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/signal" "github.com/docker/docker/pkg/term" "github.com/pkg/errors" @@ -103,23 +102,28 @@ func runStart(dockerCli *command.DockerCli, opts *startOptions) error { return errAttach } defer resp.Close() - cErr := promise.Go(func() error { - streamer := hijackedIOStreamer{ - streams: dockerCli, - inputStream: in, - outputStream: dockerCli.Out(), - errorStream: dockerCli.Err(), - resp: resp, - tty: c.Config.Tty, - detachKeys: options.DetachKeys, - } - errHijack := streamer.stream(ctx) - if errHijack == nil { - return errAttach - } - return errHijack - }) + cErr := make(chan error, 1) + + go func() { + cErr <- func() error { + streamer := hijackedIOStreamer{ + streams: dockerCli, + inputStream: in, + outputStream: dockerCli.Out(), + errorStream: dockerCli.Err(), + resp: resp, + tty: c.Config.Tty, + detachKeys: options.DetachKeys, + } + + errHijack := streamer.stream(ctx) + if errHijack == nil { + return errAttach + } + return errHijack + }() + }() // 3. We should open a channel for receiving status code of the container // no matter it's detached, removed on daemon side(--rm) or exit normally. diff --git a/cli/command/image/build.go b/cli/command/image/build.go index 19865717a6..11c4acb266 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -378,13 +378,13 @@ func runBuild(dockerCli command.Cli, options buildOptions) error { if s != nil { go func() { - logrus.Debugf("running session: %v", s.UUID()) + logrus.Debugf("running session: %v", s.ID()) if err := s.Run(ctx, dockerCli.Client().DialSession); err != nil { logrus.Error(err) cancel() // cancel progress context } }() - buildOptions.SessionID = s.UUID() + buildOptions.SessionID = s.ID() } response, err := dockerCli.Client().ImageBuild(ctx, body, buildOptions) diff --git a/cli/command/image/build_session.go b/cli/command/image/build_session.go index 4281f9fe6d..e27e67e308 100644 --- a/cli/command/image/build_session.go +++ b/cli/command/image/build_session.go @@ -53,7 +53,9 @@ func addDirToSession(session *session.Session, contextDir string, progressOutput p := &sizeProgress{out: progressOutput, action: "Streaming build context to Docker daemon"} - workdirProvider := filesync.NewFSSyncProvider(contextDir, excludes) + workdirProvider := filesync.NewFSSyncProvider([]filesync.SyncedDir{ + {Dir: contextDir, Excludes: excludes}, + }) session.Allow(workdirProvider) // this will be replaced on parallel build jobs. keep the current diff --git a/cli/command/plugin/install.go b/cli/command/plugin/install.go index 85fd8bad5f..5f187fe0d5 100644 --- a/cli/command/plugin/install.go +++ b/cli/command/plugin/install.go @@ -65,10 +65,12 @@ func (s pluginRegistryService) ResolveRepository(name reference.Named) (repoInfo return } -func newRegistryService() registry.Service { - return pluginRegistryService{ - Service: registry.NewService(registry.ServiceOptions{V2Only: true}), +func newRegistryService() (registry.Service, error) { + svc, err := registry.NewService(registry.ServiceOptions{V2Only: true}) + if err != nil { + return nil, err } + return pluginRegistryService{Service: svc}, nil } func buildPullConfig(ctx context.Context, dockerCli *command.DockerCli, opts pluginOptions, cmdName string) (types.PluginInstallOptions, error) { @@ -96,7 +98,11 @@ func buildPullConfig(ctx context.Context, dockerCli *command.DockerCli, opts plu } ctx := context.Background() - trusted, err := image.TrustedReference(ctx, dockerCli, nt, newRegistryService()) + svc, err := newRegistryService() + if err != nil { + return types.PluginInstallOptions{}, err + } + trusted, err := image.TrustedReference(ctx, dockerCli, nt, svc) if err != nil { return types.PluginInstallOptions{}, err }