mirror of https://github.com/docker/compose.git
Merge pull request #1627 from ulyssessouza/add-services-on-ps
Add support for services on ps command
This commit is contained in:
commit
c64317a981
|
@ -268,7 +268,8 @@ type ListOptions struct {
|
||||||
|
|
||||||
// PsOptions group options of the Ps API
|
// PsOptions group options of the Ps API
|
||||||
type PsOptions struct {
|
type PsOptions struct {
|
||||||
All bool
|
All bool
|
||||||
|
Services []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// PortPublisher hold status about published port
|
// PortPublisher hold status about published port
|
||||||
|
|
|
@ -47,7 +47,7 @@ func psCommand(p *projectOptions, backend compose.Service) *cobra.Command {
|
||||||
Use: "ps",
|
Use: "ps",
|
||||||
Short: "List containers",
|
Short: "List containers",
|
||||||
RunE: Adapt(func(ctx context.Context, args []string) error {
|
RunE: Adapt(func(ctx context.Context, args []string) error {
|
||||||
return runPs(ctx, backend, opts)
|
return runPs(ctx, backend, args, opts)
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
psCmd.Flags().StringVar(&opts.Format, "format", "pretty", "Format the output. Values: [pretty | json].")
|
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 {
|
||||||
return psCmd
|
return psCmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPs(ctx context.Context, backend compose.Service, opts psOptions) error {
|
func runPs(ctx context.Context, backend compose.Service, services []string, opts psOptions) error {
|
||||||
projectName, err := opts.toProjectName()
|
projectName, err := opts.toProjectName()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
containers, err := backend.Ps(ctx, projectName, compose.PsOptions{
|
containers, err := backend.Ps(ctx, projectName, compose.PsOptions{
|
||||||
All: opts.All,
|
All: opts.All,
|
||||||
|
Services: services,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -26,7 +26,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *composeService) Ps(ctx context.Context, projectName string, options compose.PsOptions) ([]compose.ContainerSummary, error) {
|
func (s *composeService) Ps(ctx context.Context, projectName string, options compose.PsOptions) ([]compose.ContainerSummary, error) {
|
||||||
containers, err := s.getContainers(ctx, projectName, oneOffInclude, options.All)
|
containers, err := s.getContainers(ctx, projectName, oneOffInclude, options.All, options.Services...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue