From a3a714e7014b484646412ff6401e0d59226ebf23 Mon Sep 17 00:00:00 2001 From: Muhammad Hewedy Date: Sun, 31 May 2020 01:24:20 +0300 Subject: [PATCH] enable case insensitivity comparison in filter --- vms/list.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vms/list.go b/vms/list.go index 67216a1..c9f1b5d 100644 --- a/vms/list.go +++ b/vms/list.go @@ -62,7 +62,7 @@ func (f filter) apply(list vmInfoList) vmInfoList { rv := reflect.ValueOf(e) for _, field := range fields { - if f.name == field && strings.Contains(rv.FieldByName(field).String(), f.value) { + if f.name == field && strings.Contains(strings.ToLower(rv.FieldByName(field).String()), f.value) { filtered = append(filtered, e) } } @@ -109,7 +109,7 @@ func parseFilters(filters []string) ([]filter, error) { if len(parts) != 2 || len(parts[1]) == 0 { return nil, fmt.Errorf("Failed to parse fitler: %s\n", f) } - out[i] = filter{name: parts[0], value: parts[1]} + out[i] = filter{name: strings.ToLower(parts[0]), value: strings.ToLower(parts[1])} } return out, nil }