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

Code before:
}

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
}

func (d *DryRunClient) NetworkRemove(ctx context.Context, networkName string) error {
	return ErrNotImplemented
}

func (d *DryRunClient) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
	return volume.Volume{}, ErrNotImplemented
}

func (d *DryRunClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
	return ErrNotImplemented
}

func (d *DryRunClient) ContainerExecCreate(ctx context.Context, container string, config moby.ExecConfig) (moby.IDResponse, error) {
	fmt.Printf("%sCreating Exec configuration for container %s with command '%s'\n", DRYRUN_PREFIX, container, strings.Join(config.Cmd, " "))
	config.Cmd = []string{"true"}
	return d.apiClient.ContainerExecCreate(ctx, container, config)
}

func (d *DryRunClient) ContainerExecStart(ctx context.Context, execID string, config moby.ExecStartCheck) error {
	fmt.Printf("%sExecuting command in detach mode\n", DRYRUN_PREFIX)
	return nil
}

// Functions delegated to original APIClient (not used by Compose or not modifying the Compose stack

func (d *DryRunClient) ConfigList(ctx context.Context, options moby.ConfigListOptions) ([]swarm.Config, error) {
	return d.apiClient.ConfigList(ctx, options)
}

func (d *DryRunClient) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (moby.ConfigCreateResponse, error) {
	return d.apiClient.ConfigCreate(ctx, config)
}

func (d *DryRunClient) ConfigRemove(ctx context.Context, id string) error {
	return d.apiClient.ConfigRemove(ctx, id)
}

func (d *DryRunClient) ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error) {
	return d.apiClient.ConfigInspectWithRaw(ctx, name)
}


Review comment (suggestion):
Should this be `return nil`?

I know we aren't _starting_ the command here, but not sure of any other possible implications here

Code after:
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
}

func (d *DryRunClient) NetworkRemove(ctx context.Context, networkName string) error {
	return ErrNotImplemented
}

func (d *DryRunClient) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) {
	return volume.Volume{}, ErrNotImplemented
}

func (d *DryRunClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error {
	return ErrNotImplemented
}

func (d *DryRunClient) ContainerExecCreate(ctx context.Context, container string, config moby.ExecConfig) (moby.IDResponse, error) {
	id := uuid.Generate().String()
	d.execs.Store(id, execDetails{
		container: container,
		command:   config.Cmd,
	})
	return moby.IDResponse{
		ID: id,
	}, nil
}

func (d *DryRunClient) ContainerExecStart(ctx context.Context, execID string, config moby.ExecStartCheck) error {
	v, ok := d.execs.LoadAndDelete(execID)
	if !ok {
		return fmt.Errorf("invalid exec ID %q", execID)
	}
	details := v.(execDetails)
	fmt.Printf("%sExecuting command %q in %s (detached mode)\n", DRYRUN_PREFIX, details.command, details.container)
	return nil