WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services
(dockerCli command.Cli, fn ProjectServicesFunc)
| 167 | |
| 168 | // WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services |
| 169 | func (o *ProjectOptions) WithServices(dockerCli command.Cli, fn ProjectServicesFunc) func(cmd *cobra.Command, args []string) error { |
| 170 | return Adapt(func(ctx context.Context, services []string) error { |
| 171 | backend, err := compose.NewComposeService(dockerCli) |
| 172 | if err != nil { |
| 173 | return err |
| 174 | } |
| 175 | |
| 176 | project, metrics, err := o.ToProject(ctx, dockerCli, backend, services, cli.WithoutEnvironmentResolution) |
| 177 | if err != nil { |
| 178 | return err |
| 179 | } |
| 180 | |
| 181 | ctx = context.WithValue(ctx, tracing.MetricsKey{}, metrics) |
| 182 | |
| 183 | project, err = project.WithServicesEnvironmentResolved(true) |
| 184 | if err != nil { |
| 185 | return err |
| 186 | } |
| 187 | |
| 188 | return fn(ctx, project, services) |
| 189 | }) |
| 190 | } |
| 191 | |
| 192 | type jsonErrorData struct { |
| 193 | Error bool `json:"error,omitempty"` |
no test coverage detected