Repository: docker/compose
File: pkg/api/dryrunclient.go (Go)

Code before:

func (d *DryRunClient) ContainerStart(ctx context.Context, container string, options moby.ContainerStartOptions) error {
	return ErrNotImplemented
}

func (d *DryRunClient) ContainerStop(ctx context.Context, container string, options containerType.StopOptions) error {
	return ErrNotImplemented
}

func (d *DryRunClient) ContainerUnpause(ctx context.Context, container string) error {
	return nil
}

func (d *DryRunClient) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, moby.ContainerPathStat, error) {
	rc := io.NopCloser(strings.NewReader(""))
	if _, err := d.ContainerStatPath(ctx, container, srcPath); err != nil {
		return rc, moby.ContainerPathStat{}, fmt.Errorf(" %s Could not find the file %s in container %s", DRYRUN_PREFIX, srcPath, container)
	}
	return rc, moby.ContainerPathStat{}, nil
}

func (d *DryRunClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options moby.CopyToContainerOptions) error {
	return nil
}

func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options moby.ImageBuildOptions) (moby.ImageBuildResponse, error) {
	return moby.ImageBuildResponse{}, ErrNotImplemented
}

func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options moby.ImagePullOptions) (io.ReadCloser, error) {
	return nil, ErrNotImplemented
}

func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options moby.ImagePushOptions) (io.ReadCloser, error) {
	return nil, ErrNotImplemented
}

func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, options moby.ImageRemoveOptions) ([]moby.ImageDeleteResponseItem, error) {
	return nil, ErrNotImplemented
}

func (d *DryRunClient) NetworkConnect(ctx context.Context, networkName, container string, config *network.EndpointSettings) error {
	return ErrNotImplemented
}

func (d *DryRunClient) NetworkCreate(ctx context.Context, name string, options moby.NetworkCreate) (moby.NetworkCreateResponse, error) {
	return moby.NetworkCreateResponse{}, ErrNotImplemented
}

func (d *DryRunClient) NetworkDisconnect(ctx context.Context, networkName, container string, force bool) error {
	return ErrNotImplemented

Review comment (suggestion):
To match the above, we might want to `ContainerStatPath(path.Dir(path))` and ensure it exists:

```
docker compose cp myfile svc:/this/path/does/not/exist
Error response from daemon: Could not find the file /this/path/does/not in container 281c3fe9c0f876d37c0953574e1fcb0385a133447fe39fb50a44369ef032b962
```

Code after:

func (d *DryRunClient) ContainerStart(ctx context.Context, container string, options moby.ContainerStartOptions) error {
	return ErrNotImplemented
}

func (d *DryRunClient) ContainerStop(ctx context.Context, container string, options containerType.StopOptions) error {
	return ErrNotImplemented
}

func (d *DryRunClient) ContainerUnpause(ctx context.Context, container string) error {
	return nil
}

func (d *DryRunClient) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, moby.ContainerPathStat, error) {
	rc := io.NopCloser(strings.NewReader(""))
	if _, err := d.ContainerStatPath(ctx, container, srcPath); err != nil {
		return rc, moby.ContainerPathStat{}, fmt.Errorf(" %s Could not find the file %s in container %s", DRYRUN_PREFIX, srcPath, container)
	}
	return rc, moby.ContainerPathStat{}, nil
}

func (d *DryRunClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options moby.CopyToContainerOptions) error {
	if _, err := d.ContainerStatPath(ctx, container, path); err != nil {
		return fmt.Errorf(" %s Could not find the file %s in container %s", DRYRUN_PREFIX, path, container)
	}
	return nil
}

func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options moby.ImageBuildOptions) (moby.ImageBuildResponse, error) {
	return moby.ImageBuildResponse{}, ErrNotImplemented
}

func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options moby.ImagePullOptions) (io.ReadCloser, error) {
	return nil, ErrNotImplemented
}

func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options moby.ImagePushOptions) (io.ReadCloser, error) {
	return nil, ErrNotImplemented
}

func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, options moby.ImageRemoveOptions) ([]moby.ImageDeleteResponseItem, error) {
	return nil, ErrNotImplemented
}

func (d *DryRunClient) NetworkConnect(ctx context.Context, networkName, container string, config *network.EndpointSettings) error {
	return ErrNotImplemented
}

func (d *DryRunClient) NetworkCreate(ctx context.Context, name string, options moby.NetworkCreate) (moby.NetworkCreateResponse, error) {
	return moby.NetworkCreateResponse{}, ErrNotImplemented
}