MCPcopy Create free account
hub / github.com/containerd/nerdctl / listContainersTargetedForCopy

Method listContainersTargetedForCopy

pkg/composer/copy.go:126–152  ·  view source on GitHub ↗
(ctx context.Context, index int, direction copyDirection, serviceName string)

Source from the content-addressed store, hash-verified

124}
125
126func (c *Composer) listContainersTargetedForCopy(ctx context.Context, index int, direction copyDirection, serviceName string) ([]containerd.Container, error) {
127 var containers []containerd.Container
128 var err error
129
130 containers, err = c.Containers(ctx, serviceName)
131 if err != nil {
132 return nil, err
133 }
134
135 if index > 0 {
136 if index > len(containers) {
137 return nil, fmt.Errorf("index (%d) out of range: only %d running instances from service %s",
138 index, len(containers), serviceName)
139 }
140 container := containers[index-1]
141 return []containerd.Container{container}, nil
142 }
143
144 if len(containers) < 1 {
145 return nil, fmt.Errorf("no container found for service %q", serviceName)
146 }
147 if direction == fromService {
148 return containers[:1], err
149
150 }
151 return containers, err
152}
153
154// isAbs is a platform-agnostic wrapper for filepath.IsAbs.
155// From https://github.com/moby/moby/blob/v28.5.2/pkg/system/filesys.go#L9-L19

Callers 1

CopyMethod · 0.95

Calls 1

ContainersMethod · 0.95

Tested by

no test coverage detected