MCPcopy
hub / github.com/docker/compose / WithServices

Method WithServices

cmd/compose/compose.go:169–190  ·  cmd/compose/compose.go::ProjectOptions.WithServices

WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services

(dockerCli command.Cli, fn ProjectServicesFunc)

Source from the content-addressed store, hash-verified

167
168// WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services
169func (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
192type jsonErrorData struct {
193 Error bool `json:"error,omitempty"`

Callers 3

WithProjectMethod · 0.95
upCommandFunction · 0.80
createCommandFunction · 0.80

Calls 3

ToProjectMethod · 0.95
NewComposeServiceFunction · 0.92
AdaptFunction · 0.85

Tested by

no test coverage detected