NewComposeService creates a Compose service using Docker CLI. This is the standard constructor that requires command.Cli for full functionality. Example usage: dockerCli, _ := command.NewDockerCli() service := NewComposeService(dockerCli) For advanced configuration with custom overrides, use Se
(dockerCli command.Cli, options ...Option)
| 64 | // service := NewComposeService(dockerCli, |
| 65 | // WithStreams(customOut, customErr, customIn)) |
| 66 | func NewComposeService(dockerCli command.Cli, options ...Option) (api.Compose, error) { |
| 67 | s := &composeService{ |
| 68 | dockerCli: dockerCli, |
| 69 | clock: clockwork.NewRealClock(), |
| 70 | maxConcurrency: -1, |
| 71 | dryRun: false, |
| 72 | } |
| 73 | for _, option := range options { |
| 74 | if err := option(s); err != nil { |
| 75 | return nil, err |
| 76 | } |
| 77 | } |
| 78 | if s.prompt == nil { |
| 79 | s.prompt = func(message string, defaultValue bool) (bool, error) { |
| 80 | fmt.Println(message) |
| 81 | logrus.Warning("Compose is running without a 'prompt' component to interact with user") |
| 82 | return defaultValue, nil |
| 83 | } |
| 84 | } |
| 85 | if s.events == nil { |
| 86 | s.events = &ignore{} |
| 87 | } |
| 88 | |
| 89 | // If custom streams were provided, wrap the Docker CLI to use them |
| 90 | if s.outStream != nil || s.errStream != nil || s.inStream != nil { |
| 91 | s.dockerCli = s.wrapDockerCliWithStreams(dockerCli) |
| 92 | } |
| 93 | |
| 94 | return s, nil |
| 95 | } |
| 96 | |
| 97 | // WithStreams sets custom I/O streams for output and interaction |
| 98 | func WithStreams(out, err io.Writer, in io.Reader) Option { |