github.com/zhgqiang/libcompose@v0.4.1-0.20210112080336-bff7ba3690e1/project/project_ps.go (about) 1 package project 2 3 import "golang.org/x/net/context" 4 5 // Ps list containers for the specified services. 6 func (p *Project) Ps(ctx context.Context, services ...string) (InfoSet, error) { 7 allInfo := InfoSet{} 8 9 if len(services) == 0 { 10 services = p.ServiceConfigs.Keys() 11 } 12 13 for _, name := range services { 14 15 service, err := p.CreateService(name) 16 if err != nil { 17 return nil, err 18 } 19 20 info, err := service.Info(ctx) 21 if err != nil { 22 return nil, err 23 } 24 25 allInfo = append(allInfo, info...) 26 } 27 return allInfo, nil 28 }