Skip to content

Commit

Permalink
Fix corner case when there's no container to attach to
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Dec 9, 2022
1 parent 0234e13 commit 8f991a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/compose/attach.go
Expand Up @@ -37,6 +37,9 @@ func (s *composeService) attach(ctx context.Context, project *types.Project, lis
if err != nil {
return nil, err
}
if len(containers) == 0 {
return containers, nil
}

containers.sorted() // This enforce predictable colors assignment

Expand Down
6 changes: 5 additions & 1 deletion pkg/compose/start.go
Expand Up @@ -110,8 +110,12 @@ func getDependencyCondition(service types.ServiceConfig, project *types.Project)
type containerWatchFn func(container moby.Container) error

// watchContainers uses engine events to capture container start/die and notify ContainerEventListener
func (s *composeService) watchContainers(ctx context.Context, projectName string, services, required []string,
func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
projectName string, services, required []string,
listener api.ContainerEventListener, containers Containers, onStart containerWatchFn) error {
if len(containers) == 0 {
return nil
}
if len(required) == 0 {
required = services
}
Expand Down

0 comments on commit 8f991a2

Please sign in to comment.