Show error on bad name filter in podman ps

Signed-off-by: Joel Smith <joelsmith@redhat.com>
This commit is contained in:
Joel Smith 2020-11-06 09:05:01 -07:00
parent dc58d4e285
commit 708d62078d
2 changed files with 4 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/containers/podman/v2/pkg/timetype"
"github.com/containers/podman/v2/pkg/util"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
// GenerateContainerFilterFuncs return ContainerFilter functions based of filter.
@ -40,6 +41,7 @@ func GenerateContainerFilterFuncs(filter, filterValue string, r *libpod.Runtime)
return func(c *libpod.Container) bool {
match, err := regexp.MatchString(filterValue, c.Name())
if err != nil {
logrus.Errorf("Failed to compile regex for 'name' filter: %v", err)
return false
}
return match

View File

@ -9,6 +9,7 @@ import (
"github.com/containers/podman/v2/libpod/define"
"github.com/containers/podman/v2/pkg/util"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
// GeneratePodFilterFunc takes a filter and filtervalue (key, value)
@ -81,6 +82,7 @@ func GeneratePodFilterFunc(filter, filterValue string) (
return func(p *libpod.Pod) bool {
match, err := regexp.MatchString(filterValue, p.Name())
if err != nil {
logrus.Errorf("Failed to compile regex for 'name' filter: %v", err)
return false
}
return match