Explorar o código

don't try to start dependencies when there are none

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof %!s(int64=3) %!d(string=hai) anos
pai
achega
dbe7de50a7
Modificáronse 2 ficheiros con 9 adicións e 4 borrados
  1. 8 3
      cmd/compose/run.go
  2. 1 1
      pkg/compose/compose.go

+ 8 - 3
cmd/compose/run.go

@@ -245,10 +245,15 @@ func startDependencies(ctx context.Context, backend api.Service, project types.P
 
 	project.Services = dependencies
 	project.DisabledServices = append(project.DisabledServices, requestedService)
-	if err := backend.Create(ctx, &project, api.CreateOptions{
+	err := backend.Create(ctx, &project, api.CreateOptions{
 		IgnoreOrphans: ignoreOrphans,
-	}); err != nil {
+	})
+	if err != nil {
 		return err
 	}
-	return backend.Start(ctx, project.Name, api.StartOptions{})
+
+	if len(dependencies) > 0 {
+		return backend.Start(ctx, project.Name, api.StartOptions{})
+	}
+	return nil
 }

+ 1 - 1
pkg/compose/compose.go

@@ -100,7 +100,7 @@ func (s *composeService) projectFromName(containers Containers, projectName stri
 		Name: projectName,
 	}
 	if len(containers) == 0 {
-		return project, errors.New("no such project: " + projectName)
+		return project, errors.Wrap(api.ErrNotFound, fmt.Sprintf("no container found for project %q", projectName))
 	}
 	set := map[string]*types.ServiceConfig{}
 	for _, c := range containers {