console/filter: accept empty filters

This commit is contained in:
Vincent Bernat
2022-05-27 08:59:51 +02:00
parent e114affdad
commit 36a101fd90
2 changed files with 28 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package console
import (
"errors"
"fmt"
"strings"
"akvorado/common/helpers"
"akvorado/console/filter"
@@ -98,6 +99,10 @@ func (gf queryFilter) MarshalText() ([]byte, error) {
return []byte(gf.filter), nil
}
func (gf *queryFilter) UnmarshalText(input []byte) error {
if strings.TrimSpace(string(input)) == "" {
*gf = queryFilter{""}
return nil
}
got, err := filter.Parse("", input)
if err != nil {
return fmt.Errorf("cannot parse filter: %s", filter.HumanError(err))