@@ -208,7 +208,7 @@ func resolveLocalPath(localPath string) (absPath string, err error) {
208208 return archive .PreserveTrailingDotOrSeparator (absPath , localPath ), nil
209209}
210210
211- func copyFromContainer (ctx context.Context , dockerCli command.Cli , copyConfig cpConfig ) (err error ) {
211+ func copyFromContainer (ctx context.Context , dockerCLI command.Cli , copyConfig cpConfig ) (err error ) {
212212 dstPath := copyConfig .destPath
213213 srcPath := copyConfig .sourcePath
214214
@@ -224,11 +224,11 @@ func copyFromContainer(ctx context.Context, dockerCli command.Cli, copyConfig cp
224224 return err
225225 }
226226
227- client := dockerCli .Client ()
227+ apiClient := dockerCLI .Client ()
228228 // if client requests to follow symbol link, then must decide target file to be copied
229229 var rebaseName string
230230 if copyConfig .followLink {
231- srcStat , err := client .ContainerStatPath (ctx , copyConfig .container , srcPath )
231+ srcStat , err := apiClient .ContainerStatPath (ctx , copyConfig .container , srcPath )
232232
233233 // If the destination is a symbolic link, we should follow it.
234234 if err == nil && srcStat .Mode & os .ModeSymlink != 0 {
@@ -247,14 +247,14 @@ func copyFromContainer(ctx context.Context, dockerCli command.Cli, copyConfig cp
247247 ctx , cancel := signal .NotifyContext (ctx , os .Interrupt )
248248 defer cancel ()
249249
250- content , stat , err := client .CopyFromContainer (ctx , copyConfig .container , srcPath )
250+ content , stat , err := apiClient .CopyFromContainer (ctx , copyConfig .container , srcPath )
251251 if err != nil {
252252 return err
253253 }
254254 defer content .Close ()
255255
256256 if dstPath == "-" {
257- _ , err = io .Copy (dockerCli .Out (), content )
257+ _ , err = io .Copy (dockerCLI .Out (), content )
258258 return err
259259 }
260260
@@ -283,12 +283,12 @@ func copyFromContainer(ctx context.Context, dockerCli command.Cli, copyConfig cp
283283 return archive .CopyTo (preArchive , srcInfo , dstPath )
284284 }
285285
286- restore , done := copyProgress (ctx , dockerCli .Err (), copyFromContainerHeader , & copiedSize )
286+ restore , done := copyProgress (ctx , dockerCLI .Err (), copyFromContainerHeader , & copiedSize )
287287 res := archive .CopyTo (preArchive , srcInfo , dstPath )
288288 cancel ()
289289 <- done
290290 restore ()
291- fmt .Fprintln (dockerCli .Err (), "Successfully copied" , progressHumanSize (copiedSize ), "to" , dstPath )
291+ _ , _ = fmt .Fprintln (dockerCLI .Err (), "Successfully copied" , progressHumanSize (copiedSize ), "to" , dstPath )
292292
293293 return res
294294}
@@ -297,7 +297,7 @@ func copyFromContainer(ctx context.Context, dockerCli command.Cli, copyConfig cp
297297// about both the source and destination. The API is a simple tar
298298// archive/extract API but we can use the stat info header about the
299299// destination to be more informed about exactly what the destination is.
300- func copyToContainer (ctx context.Context , dockerCli command.Cli , copyConfig cpConfig ) (err error ) {
300+ func copyToContainer (ctx context.Context , dockerCLI command.Cli , copyConfig cpConfig ) (err error ) {
301301 srcPath := copyConfig .sourcePath
302302 dstPath := copyConfig .destPath
303303
@@ -309,10 +309,10 @@ func copyToContainer(ctx context.Context, dockerCli command.Cli, copyConfig cpCo
309309 }
310310 }
311311
312- client := dockerCli .Client ()
312+ apiClient := dockerCLI .Client ()
313313 // Prepare destination copy info by stat-ing the container path.
314314 dstInfo := archive.CopyInfo {Path : dstPath }
315- dstStat , err := client .ContainerStatPath (ctx , copyConfig .container , dstPath )
315+ dstStat , err := apiClient .ContainerStatPath (ctx , copyConfig .container , dstPath )
316316
317317 // If the destination is a symbolic link, we should evaluate it.
318318 if err == nil && dstStat .Mode & os .ModeSymlink != 0 {
@@ -324,7 +324,8 @@ func copyToContainer(ctx context.Context, dockerCli command.Cli, copyConfig cpCo
324324 }
325325
326326 dstInfo .Path = linkTarget
327- dstStat , err = client .ContainerStatPath (ctx , copyConfig .container , linkTarget )
327+ dstStat , err = apiClient .ContainerStatPath (ctx , copyConfig .container , linkTarget )
328+ // FIXME(thaJeztah): unhandled error (should this return?)
328329 }
329330
330331 // Validate the destination path
@@ -401,16 +402,16 @@ func copyToContainer(ctx context.Context, dockerCli command.Cli, copyConfig cpCo
401402 }
402403
403404 if copyConfig .quiet {
404- return client .CopyToContainer (ctx , copyConfig .container , resolvedDstPath , content , options )
405+ return apiClient .CopyToContainer (ctx , copyConfig .container , resolvedDstPath , content , options )
405406 }
406407
407408 ctx , cancel := signal .NotifyContext (ctx , os .Interrupt )
408- restore , done := copyProgress (ctx , dockerCli .Err (), copyToContainerHeader , & copiedSize )
409- res := client .CopyToContainer (ctx , copyConfig .container , resolvedDstPath , content , options )
409+ restore , done := copyProgress (ctx , dockerCLI .Err (), copyToContainerHeader , & copiedSize )
410+ res := apiClient .CopyToContainer (ctx , copyConfig .container , resolvedDstPath , content , options )
410411 cancel ()
411412 <- done
412413 restore ()
413- fmt .Fprintln (dockerCli .Err (), "Successfully copied" , progressHumanSize (copiedSize ), "to" , copyConfig .container + ":" + dstInfo .Path )
414+ fmt .Fprintln (dockerCLI .Err (), "Successfully copied" , progressHumanSize (copiedSize ), "to" , copyConfig .container + ":" + dstInfo .Path )
414415
415416 return res
416417}
0 commit comments