@@ -24,8 +24,8 @@ type AttachOptions struct {
2424 DetachKeys string
2525}
2626
27- func inspectContainerAndCheckState (ctx context.Context , cli client.APIClient , args string ) (* types.ContainerJSON , error ) {
28- c , err := cli .ContainerInspect (ctx , args )
27+ func inspectContainerAndCheckState (ctx context.Context , apiClient client.APIClient , args string ) (* types.ContainerJSON , error ) {
28+ c , err := apiClient .ContainerInspect (ctx , args )
2929 if err != nil {
3030 return nil , err
3131 }
@@ -45,21 +45,21 @@ func inspectContainerAndCheckState(ctx context.Context, cli client.APIClient, ar
4545// NewAttachCommand creates a new cobra.Command for `docker attach`
4646func NewAttachCommand (dockerCli command.Cli ) * cobra.Command {
4747 var opts AttachOptions
48- var container string
48+ var ctr string
4949
5050 cmd := & cobra.Command {
5151 Use : "attach [OPTIONS] CONTAINER" ,
5252 Short : "Attach local standard input, output, and error streams to a running container" ,
5353 Args : cli .ExactArgs (1 ),
5454 RunE : func (cmd * cobra.Command , args []string ) error {
55- container = args [0 ]
56- return RunAttach (context .Background (), dockerCli , container , & opts )
55+ ctr = args [0 ]
56+ return RunAttach (context .Background (), dockerCli , ctr , & opts )
5757 },
5858 Annotations : map [string ]string {
5959 "aliases" : "docker container attach, docker attach" ,
6060 },
61- ValidArgsFunction : completion .ContainerNames (dockerCli , false , func (container types.Container ) bool {
62- return container .State != "paused"
61+ ValidArgsFunction : completion .ContainerNames (dockerCli , false , func (ctr types.Container ) bool {
62+ return ctr .State != "paused"
6363 }),
6464 }
6565
@@ -71,8 +71,8 @@ func NewAttachCommand(dockerCli command.Cli) *cobra.Command {
7171}
7272
7373// RunAttach executes an `attach` command
74- func RunAttach (ctx context.Context , dockerCli command.Cli , target string , opts * AttachOptions ) error {
75- apiClient := dockerCli .Client ()
74+ func RunAttach (ctx context.Context , dockerCLI command.Cli , target string , opts * AttachOptions ) error {
75+ apiClient := dockerCLI .Client ()
7676
7777 // request channel to wait for client
7878 resultC , errC := apiClient .ContainerWait (ctx , target , "" )
@@ -82,11 +82,11 @@ func RunAttach(ctx context.Context, dockerCli command.Cli, target string, opts *
8282 return err
8383 }
8484
85- if err := dockerCli .In ().CheckTty (! opts .NoStdin , c .Config .Tty ); err != nil {
85+ if err := dockerCLI .In ().CheckTty (! opts .NoStdin , c .Config .Tty ); err != nil {
8686 return err
8787 }
8888
89- detachKeys := dockerCli .ConfigFile ().DetachKeys
89+ detachKeys := dockerCLI .ConfigFile ().DetachKeys
9090 if opts .DetachKeys != "" {
9191 detachKeys = opts .DetachKeys
9292 }
@@ -101,7 +101,7 @@ func RunAttach(ctx context.Context, dockerCli command.Cli, target string, opts *
101101
102102 var in io.ReadCloser
103103 if options .Stdin {
104- in = dockerCli .In ()
104+ in = dockerCLI .In ()
105105 }
106106
107107 if opts .Proxy && ! c .Config .Tty {
@@ -129,15 +129,15 @@ func RunAttach(ctx context.Context, dockerCli command.Cli, target string, opts *
129129 return err
130130 }
131131
132- if c .Config .Tty && dockerCli .Out ().IsTerminal () {
133- resizeTTY (ctx , dockerCli , target )
132+ if c .Config .Tty && dockerCLI .Out ().IsTerminal () {
133+ resizeTTY (ctx , dockerCLI , target )
134134 }
135135
136136 streamer := hijackedIOStreamer {
137- streams : dockerCli ,
137+ streams : dockerCLI ,
138138 inputStream : in ,
139- outputStream : dockerCli .Out (),
140- errorStream : dockerCli .Err (),
139+ outputStream : dockerCLI .Out (),
140+ errorStream : dockerCLI .Err (),
141141 resp : resp ,
142142 tty : c .Config .Tty ,
143143 detachKeys : options .DetachKeys ,
0 commit comments