Skip to content

Commit

Permalink
check service names based on project, not running containers
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 21, 2022
1 parent 91371fe commit 3b8a178
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/compose/ps.go
Expand Up @@ -96,6 +96,16 @@ func runPs(ctx context.Context, streams api.Streams, backend api.Service, servic
if err != nil {
return err
}

if project != nil && len(services) > 0 {
names := project.ServiceNames()
for _, service := range services {
if !utils.StringContains(names, service) {
return fmt.Errorf("no such service: %s", service)
}
}
}

containers, err := backend.Ps(ctx, name, api.PsOptions{
Project: project,
All: opts.All,
Expand All @@ -112,7 +122,6 @@ SERVICES:
continue SERVICES
}
}
return fmt.Errorf("no such service: %s", s)
}

if len(opts.Status) != 0 {
Expand Down

0 comments on commit 3b8a178

Please sign in to comment.