Use Regexp in volume ls --filter name

Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
This commit is contained in:
Boaz Shuster
2022-06-15 12:40:11 +03:00
parent 9c4b8a29b0
commit 3b10c1b78a
3 changed files with 60 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package filters
import (
"net/url"
"regexp"
"strings"
"github.com/containers/podman/v4/libpod"
@ -15,9 +16,12 @@ func GenerateVolumeFilters(filters url.Values) ([]libpod.VolumeFilter, error) {
for _, val := range v {
switch filter {
case "name":
nameVal := val
nameRegexp, err := regexp.Compile(val)
if err != nil {
return nil, err
}
vf = append(vf, func(v *libpod.Volume) bool {
return nameVal == v.Name()
return nameRegexp.MatchString(v.Name())
})
case "driver":
driverVal := val