mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #7759 from xordspar0/app-filter
Allow filtering on pod label values
This commit is contained in:
@ -73,7 +73,7 @@ func pods(cmd *cobra.Command, _ []string) error {
|
||||
if cmd.Flag("filter").Changed {
|
||||
psInput.Filters = make(map[string][]string)
|
||||
for _, f := range inputFilters {
|
||||
split := strings.Split(f, "=")
|
||||
split := strings.SplitN(f, "=", 2)
|
||||
if len(split) < 2 {
|
||||
return errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f)
|
||||
}
|
||||
|
@ -212,17 +212,17 @@ var _ = Describe("Podman ps", func() {
|
||||
Expect(ec).To(Equal(0))
|
||||
|
||||
_, ec, podid2 := podmanTest.CreatePodWithLabels("", map[string]string{
|
||||
"io.podman.test.label": "value1",
|
||||
"app": "myapp",
|
||||
"io.podman.test.key": "irrelevant-value",
|
||||
})
|
||||
Expect(ec).To(Equal(0))
|
||||
|
||||
_, ec, podid3 := podmanTest.CreatePodWithLabels("", map[string]string{
|
||||
"io.podman.test.label": "value2",
|
||||
"app": "test",
|
||||
})
|
||||
Expect(ec).To(Equal(0))
|
||||
|
||||
session := podmanTest.Podman([]string{"pod", "ps", "--no-trunc", "--filter", "label=io.podman.test.key", "--filter", "label=io.podman.test.label=value1"})
|
||||
session := podmanTest.Podman([]string{"pod", "ps", "--no-trunc", "--filter", "label=app", "--filter", "label=app=myapp"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
Expect(session.OutputToString()).To(Not(ContainSubstring(podid1)))
|
||||
|
Reference in New Issue
Block a user