Skip to content

Commit

Permalink
enable case insensitivity comparison in filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mhewedy committed May 30, 2020
1 parent 486e865 commit 6e164db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
- consider use google drive (https://drive.google.com/uc?export=download&confirm=htAy&id=<fileid>)
- 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)

4 changes: 2 additions & 2 deletions vms/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 6e164db

Please sign in to comment.