Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit c64317a

Browse files
authored
Merge pull request #1627 from ulyssessouza/add-services-on-ps
Add support for services on ps command
2 parents ebbe86f + 36d6c40 commit c64317a

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

api/compose/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ type ListOptions struct {
268268

269269
// PsOptions group options of the Ps API
270270
type PsOptions struct {
271-
All bool
271+
All bool
272+
Services []string
272273
}
273274

274275
// PortPublisher hold status about published port

cli/cmd/compose/ps.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func psCommand(p *projectOptions, backend compose.Service) *cobra.Command {
4747
Use: "ps",
4848
Short: "List containers",
4949
RunE: Adapt(func(ctx context.Context, args []string) error {
50-
return runPs(ctx, backend, opts)
50+
return runPs(ctx, backend, args, opts)
5151
}),
5252
}
5353
psCmd.Flags().StringVar(&opts.Format, "format", "pretty", "Format the output. Values: [pretty | json].")
@@ -57,13 +57,14 @@ func psCommand(p *projectOptions, backend compose.Service) *cobra.Command {
5757
return psCmd
5858
}
5959

60-
func runPs(ctx context.Context, backend compose.Service, opts psOptions) error {
60+
func runPs(ctx context.Context, backend compose.Service, services []string, opts psOptions) error {
6161
projectName, err := opts.toProjectName()
6262
if err != nil {
6363
return err
6464
}
6565
containers, err := backend.Ps(ctx, projectName, compose.PsOptions{
66-
All: opts.All,
66+
All: opts.All,
67+
Services: services,
6768
})
6869
if err != nil {
6970
return err

local/compose/ps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

2828
func (s *composeService) Ps(ctx context.Context, projectName string, options compose.PsOptions) ([]compose.ContainerSummary, error) {
29-
containers, err := s.getContainers(ctx, projectName, oneOffInclude, options.All)
29+
containers, err := s.getContainers(ctx, projectName, oneOffInclude, options.All, options.Services...)
3030
if err != nil {
3131
return nil, err
3232
}

0 commit comments

Comments
 (0)