@@ -61,11 +61,6 @@ func (s *composeService) copy(ctx context.Context, projectName string, options a
61
61
direction |= fromService
62
62
serviceName = srcService
63
63
copyFunc = s .copyFromContainer
64
-
65
- // copying from multiple containers of a services doesn't make sense.
66
- if options .All {
67
- return errors .New ("cannot use the --all flag when copying from a service" )
68
- }
69
64
}
70
65
if destService != "" {
71
66
direction |= toService
@@ -80,7 +75,7 @@ func (s *composeService) copy(ctx context.Context, projectName string, options a
80
75
return errors .New ("unknown copy direction" )
81
76
}
82
77
83
- containers , err := s .listContainersTargetedForCopy (ctx , projectName , options . Index , direction , serviceName )
78
+ containers , err := s .listContainersTargetedForCopy (ctx , projectName , options , direction , serviceName )
84
79
if err != nil {
85
80
return err
86
81
}
@@ -119,18 +114,22 @@ func (s *composeService) copy(ctx context.Context, projectName string, options a
119
114
return g .Wait ()
120
115
}
121
116
122
- func (s * composeService ) listContainersTargetedForCopy (ctx context.Context , projectName string , index int , direction copyDirection , serviceName string ) (Containers , error ) {
117
+ func (s * composeService ) listContainersTargetedForCopy (ctx context.Context , projectName string , options api. CopyOptions , direction copyDirection , serviceName string ) (Containers , error ) {
123
118
var containers Containers
124
119
var err error
125
120
switch {
126
- case index > 0 :
127
- ctr , err := s .getSpecifiedContainer (ctx , projectName , oneOffExclude , true , serviceName , index )
121
+ case options . Index > 0 :
122
+ ctr , err := s .getSpecifiedContainer (ctx , projectName , oneOffExclude , true , serviceName , options . Index )
128
123
if err != nil {
129
124
return nil , err
130
125
}
131
126
return append (containers , ctr ), nil
132
127
default :
133
- containers , err = s .getContainers (ctx , projectName , oneOffExclude , true , serviceName )
128
+ withOneOff := oneOffExclude
129
+ if options .All {
130
+ withOneOff = oneOffInclude
131
+ }
132
+ containers , err = s .getContainers (ctx , projectName , withOneOff , true , serviceName )
134
133
if err != nil {
135
134
return nil , err
136
135
}
0 commit comments