mirror of https://github.com/docker/compose.git
use project we just created to start services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
7fea9f7e8b
commit
db698562a9
|
@ -204,6 +204,7 @@ func runUp(ctx context.Context, backend api.Service, createOptions createOptions
|
|||
return backend.Up(ctx, project, api.UpOptions{
|
||||
Create: create,
|
||||
Start: api.StartOptions{
|
||||
Project: project,
|
||||
Attach: consumer,
|
||||
AttachTo: attachTo,
|
||||
ExitCodeFrom: upOptions.exitCodeFrom,
|
||||
|
|
|
@ -117,6 +117,8 @@ type CreateOptions struct {
|
|||
|
||||
// StartOptions group options of the Start API
|
||||
type StartOptions struct {
|
||||
// Project is the compose project used to define this app. Might be nil if user ran `start` just with project name
|
||||
Project *types.Project
|
||||
// Attach to container and forward logs if not nil
|
||||
Attach LogConsumer
|
||||
// AttachTo set the services to attach to
|
||||
|
|
|
@ -35,16 +35,19 @@ func (s *composeService) Start(ctx context.Context, projectName string, options
|
|||
}
|
||||
|
||||
func (s *composeService) start(ctx context.Context, projectName string, options api.StartOptions, listener api.ContainerEventListener) error {
|
||||
project := options.Project
|
||||
if project == nil {
|
||||
var containers Containers
|
||||
containers, err := s.getContainers(ctx, projectName, oneOffExclude, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
project, err := s.projectFromName(containers, projectName, options.AttachTo...)
|
||||
project, err = s.projectFromName(containers, projectName, options.AttachTo...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
||||
if listener != nil {
|
||||
|
@ -60,7 +63,7 @@ func (s *composeService) start(ctx context.Context, projectName string, options
|
|||
})
|
||||
}
|
||||
|
||||
err = InDependencyOrder(ctx, project, func(c context.Context, name string) error {
|
||||
err := InDependencyOrder(ctx, project, func(c context.Context, name string) error {
|
||||
service, err := project.GetService(name)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue