Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkg/domain/filters/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo
}, nil
case "label!":
return func(c *libpod.Container) bool {
return !filters.MatchLabelFilters(filterValues, c.Labels())
return filters.MatchNegatedLabelFilters(filterValues, c.Labels())
}, nil
case "name":
// we only have to match one name
Expand Down Expand Up @@ -309,7 +309,7 @@ func GeneratePruneContainerFilterFuncs(filter string, filterValues []string, _ *
}, nil
case "label!":
return func(c *libpod.Container) bool {
return !filters.MatchLabelFilters(filterValues, c.Labels())
return filters.MatchNegatedLabelFilters(filterValues, c.Labels())
}, nil
case "until":
return prepareUntilFilterFunc(filterValues)
Expand Down Expand Up @@ -478,7 +478,11 @@ func GenerateExternalContainerFilterFuncs(filter string, filterValues []string,
}, nil
case "label":
return func(listContainer *types.ListContainer) bool {
return !filters.MatchLabelFilters(filterValues, listContainer.Labels)
return filters.MatchLabelFilters(filterValues, listContainer.Labels)
}, nil
case "label!":
return func(listContainer *types.ListContainer) bool {
return filters.MatchNegatedLabelFilters(filterValues, listContainer.Labels)
}, nil
case "pod":
var pods []*libpod.Pod
Expand Down
2 changes: 1 addition & 1 deletion pkg/domain/filters/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func GeneratePodFilterFunc(filter string, filterValues []string, r *libpod.Runti
case "label!":
return func(p *libpod.Pod) bool {
labels := p.Labels()
return !filters.MatchLabelFilters(filterValues, labels)
return filters.MatchNegatedLabelFilters(filterValues, labels)
}, nil
case "until":
return func(p *libpod.Pod) bool {
Expand Down
4 changes: 2 additions & 2 deletions pkg/domain/filters/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func GenerateVolumeFilters(filter string, filterValues []string, runtime *libpod
}, nil
case "label!":
return func(v *libpod.Volume) bool {
return !filters.MatchLabelFilters(filterValues, v.Labels())
return filters.MatchNegatedLabelFilters(filterValues, v.Labels())
}, nil
case "opt":
return func(v *libpod.Volume) bool {
Expand Down Expand Up @@ -101,7 +101,7 @@ func GeneratePruneVolumeFilters(filter string, filterValues []string, runtime *l
}, nil
case "label!":
return func(v *libpod.Volume) bool {
return !filters.MatchLabelFilters(filterValues, v.Labels())
return filters.MatchNegatedLabelFilters(filterValues, v.Labels())
}, nil
case "until":
return createUntilFilterVolumeFunction(filterValues)
Expand Down
11 changes: 9 additions & 2 deletions test/e2e/volume_ls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ var _ = Describe("Podman volume ls", func() {

vol1Name := session.OutputToString()

session = podmanTest.Podman([]string{"volume", "create", "--label", "b=c", "--label", "a=b", "vol2"})
session = podmanTest.Podman([]string{"volume", "create", "--label", "a=b", "--label", "b=c", "--label", "d=e", "vol2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

Expand All @@ -208,11 +208,18 @@ var _ = Describe("Podman volume ls", func() {
Expect(session.OutputToStringArray()[0]).To(Equal(vol1Name))
Expect(session.OutputToStringArray()[1]).To(Equal(vol2Name))

session = podmanTest.Podman([]string{"volume", "ls", "-q", "--filter", "label=c=d", "--filter", "label=b=c"})
session = podmanTest.Podman([]string{"volume", "ls", "-q", "--filter", "label=b=c", "--filter", "label=c=d"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(HaveLen(1))
Expect(session.OutputToStringArray()[0]).To(Equal(vol3Name))

// Filters with label! key
session = podmanTest.Podman([]string{"volume", "ls", "-q", "--filter", "label!=c=d", "--filter", "label!=d=e"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(HaveLen(1))
Expect(session.OutputToStringArray()[0]).To(Equal(vol1Name))
})

It("podman ls volume with --filter since/after", func() {
Expand Down