From 6e164db2e02a83e936bf262ed412877b0a2301e8 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 --- TODO.md | 2 ++ vms/list.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 4b51155..9f4a1cc 100644 --- a/TODO.md +++ b/TODO.md @@ -9,3 +9,5 @@ - consider use google drive (https://drive.google.com/uc?export=download&confirm=htAy&id=) - https://wasabi.com/ * Work on Clone to clone a VM (export: [vboxmanage export vm_01 --ovf20 -o ~/Documents/temp.ova] then import) +* Implement docker container names & ids (https://github.com/moby/moby/blob/634a848b8e3bdd8aed834559f3b2e0dfc7f5ae3a/pkg/stringid/stringid.go, https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go) + 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 }