MCPcopy
hub / github.com/docker/compose / listContainersTargetedForCopy

Method listContainersTargetedForCopy

pkg/compose/cp.go:115–143  ·  pkg/compose/cp.go::composeService.listContainersTargetedForCopy
(ctx context.Context, projectName string, options api.CopyOptions, direction copyDirection, serviceName string)

Source from the content-addressed store, hash-verified

113}
114
115func (s *composeService) listContainersTargetedForCopy(ctx context.Context, projectName string, options api.CopyOptions, direction copyDirection, serviceName string) (Containers, error) {
116 var containers Containers
117 var err error
118 switch {
119 case options.Index > 0:
120 ctr, err := s.getSpecifiedContainer(ctx, projectName, oneOffExclude, true, serviceName, options.Index)
121 if err != nil {
122 return nil, err
123 }
124 return append(containers, ctr), nil
125 default:
126 withOneOff := oneOffExclude
127 if options.All {
128 withOneOff = oneOffInclude
129 }
130 containers, err = s.getContainers(ctx, projectName, withOneOff, true, serviceName)
131 if err != nil {
132 return nil, err
133 }
134
135 if len(containers) < 1 {
136 return nil, fmt.Errorf("no container found for service %q", serviceName)
137 }
138 if direction == fromService {
139 return containers[:1], err
140 }
141 return containers, err
142 }
143}
144
145func (s *composeService) copyToContainer(ctx context.Context, containerID string, srcPath string, dstPath string, opts api.CopyOptions) error {
146 var err error

Callers 1

copyMethod · 0.95

Calls 2

getSpecifiedContainerMethod · 0.95
getContainersMethod · 0.95

Tested by

no test coverage detected