Răsfoiți Sursa

Merge pull request #1649 from ndeloof/ps_all

Nicolas De loof 4 ani în urmă
părinte
comite
59efedf043
2 a modificat fișierele cu 8 adăugiri și 2 ștergeri
  1. 5 1
      local/compose/ps.go
  2. 3 1
      local/compose/ps_test.go

+ 5 - 1
local/compose/ps.go

@@ -26,7 +26,11 @@ import (
 )
 
 func (s *composeService) Ps(ctx context.Context, projectName string, options compose.PsOptions) ([]compose.ContainerSummary, error) {
-	containers, err := s.getContainers(ctx, projectName, oneOffInclude, options.All, options.Services...)
+	oneOff := oneOffExclude
+	if options.All {
+		oneOff = oneOffInclude
+	}
+	containers, err := s.getContainers(ctx, projectName, oneOff, true, options.Services...)
 	if err != nil {
 		return nil, err
 	}

+ 3 - 1
local/compose/ps_test.go

@@ -37,7 +37,9 @@ func TestPs(t *testing.T) {
 	tested.apiClient = api
 
 	ctx := context.Background()
-	listOpts := apitypes.ContainerListOptions{Filters: filters.NewArgs(projectFilter(testProject)), All: false}
+	args := filters.NewArgs(projectFilter(testProject))
+	args.Add("label", "com.docker.compose.oneoff=False")
+	listOpts := apitypes.ContainerListOptions{Filters: args, All: true}
 	c1, inspect1 := containerDetails("service1", "123", "Running", "healthy")
 	c2, inspect2 := containerDetails("service1", "456", "Running", "")
 	c2.Ports = []apitypes.Port{{PublicPort: 80, PrivatePort: 90, IP: "localhost"}}