Skip to content

Commit db69856

Browse files
committed
use project we just created to start services
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 7fea9f7 commit db69856

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

cmd/compose/up.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ func runUp(ctx context.Context, backend api.Service, createOptions createOptions
204204
return backend.Up(ctx, project, api.UpOptions{
205205
Create: create,
206206
Start: api.StartOptions{
207+
Project: project,
207208
Attach: consumer,
208209
AttachTo: attachTo,
209210
ExitCodeFrom: upOptions.exitCodeFrom,

pkg/api/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ type CreateOptions struct {
117117

118118
// StartOptions group options of the Start API
119119
type StartOptions struct {
120+
// Project is the compose project used to define this app. Might be nil if user ran `start` just with project name
121+
Project *types.Project
120122
// Attach to container and forward logs if not nil
121123
Attach LogConsumer
122124
// AttachTo set the services to attach to

pkg/compose/start.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ func (s *composeService) Start(ctx context.Context, projectName string, options
3535
}
3636

3737
func (s *composeService) start(ctx context.Context, projectName string, options api.StartOptions, listener api.ContainerEventListener) error {
38-
var containers Containers
39-
containers, err := s.getContainers(ctx, projectName, oneOffExclude, true)
40-
if err != nil {
41-
return err
42-
}
38+
project := options.Project
39+
if project == nil {
40+
var containers Containers
41+
containers, err := s.getContainers(ctx, projectName, oneOffExclude, true)
42+
if err != nil {
43+
return err
44+
}
4345

44-
project, err := s.projectFromName(containers, projectName, options.AttachTo...)
45-
if err != nil {
46-
return err
46+
project, err = s.projectFromName(containers, projectName, options.AttachTo...)
47+
if err != nil {
48+
return err
49+
}
4750
}
4851

4952
eg, ctx := errgroup.WithContext(ctx)
@@ -60,7 +63,7 @@ func (s *composeService) start(ctx context.Context, projectName string, options
6063
})
6164
}
6265

63-
err = InDependencyOrder(ctx, project, func(c context.Context, name string) error {
66+
err := InDependencyOrder(ctx, project, func(c context.Context, name string) error {
6467
service, err := project.GetService(name)
6568
if err != nil {
6669
return err

0 commit comments

Comments
 (0)