@@ -24,6 +24,7 @@ import (
24
24
"path/filepath"
25
25
"strings"
26
26
27
+ "github.com/docker/compose/v2/pkg/progress"
27
28
"golang.org/x/sync/errgroup"
28
29
29
30
"github.com/docker/cli/cli/command"
@@ -43,6 +44,12 @@ const (
43
44
)
44
45
45
46
func (s * composeService ) Copy (ctx context.Context , projectName string , options api.CopyOptions ) error {
47
+ return progress .Run (ctx , func (ctx context.Context ) error {
48
+ return s .copy (ctx , projectName , options )
49
+ }, s .stderr ())
50
+ }
51
+
52
+ func (s * composeService ) copy (ctx context.Context , projectName string , options api.CopyOptions ) error {
46
53
projectName = strings .ToLower (projectName )
47
54
srcService , srcPath := splitCpArg (options .Source )
48
55
destService , dstPath := splitCpArg (options .Destination )
@@ -78,18 +85,33 @@ func (s *composeService) Copy(ctx context.Context, projectName string, options a
78
85
return err
79
86
}
80
87
88
+ w := progress .ContextWriter (ctx )
81
89
g := errgroup.Group {}
82
90
for _ , cont := range containers {
83
91
container := cont
84
92
g .Go (func () error {
93
+ name := getCanonicalContainerName (container )
94
+ var msg string
95
+ if direction == fromService {
96
+ msg = fmt .Sprintf ("copy %s:%s to %s" , name , srcPath , dstPath )
97
+ } else {
98
+ msg = fmt .Sprintf ("copy %s to %s:%s" , srcPath , name , dstPath )
99
+ }
100
+ w .Event (progress.Event {
101
+ ID : name ,
102
+ Text : msg ,
103
+ Status : progress .Working ,
104
+ StatusText : "Copying" ,
105
+ })
85
106
if err := copyFunc (ctx , container .ID , srcPath , dstPath , options ); err != nil {
86
107
return err
87
108
}
88
- fromOrInside := "inside"
89
- if direction == fromService {
90
- fromOrInside = "from"
91
- }
92
- fmt .Fprintf (s .stderr (), "Copy %s to path %s %s %s service container\n " , srcPath , dstPath , fromOrInside , getCanonicalContainerName (container ))
109
+ w .Event (progress.Event {
110
+ ID : name ,
111
+ Text : msg ,
112
+ Status : progress .Done ,
113
+ StatusText : "Copied" ,
114
+ })
93
115
return nil
94
116
})
95
117
}
0 commit comments