pkg/command: wrap jsonmessage.DisplayJSONMessagesStream with go context
Allows for the `jsonmessage.DisplayJSONMessagesStream` function
to correctly return when the context is cancelled with the appropriate
reason (`ctx.Error()`) instead of just a nil error.
Follow-up to 30a73ff19c
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Co-authored-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@ -10,8 +10,8 @@ import (
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/completion"
|
||||
"github.com/docker/cli/cli/command/swarm/progress"
|
||||
"github.com/docker/cli/cli/internal/jsonstream"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
@ -120,7 +120,7 @@ func attach(ctx context.Context, dockerCli command.Cli, opts caOptions) error {
|
||||
return <-errChan
|
||||
}
|
||||
|
||||
err := jsonmessage.DisplayJSONMessagesToStream(pipeReader, dockerCli.Out(), nil)
|
||||
err := jsonstream.Display(ctx, pipeReader, dockerCli.Out())
|
||||
if err == nil {
|
||||
err = <-errChan
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user