(expr string)
| 120 | } |
| 121 | |
| 122 | func parseExpression(expr string) (Expression, error) { |
| 123 | // Split the expression by " " to get the key, comparator and val. |
| 124 | re := regexp.MustCompile(`\s+`) |
| 125 | words := re.Split(strings.TrimSpace(expr), -1) |
| 126 | if len(words) != 3 { |
| 127 | return Expression{}, errors.Errorf("invalid expression %q", expr) |
| 128 | } |
| 129 | |
| 130 | comparator, err := getComparatorType(words[1]) |
| 131 | if err != nil { |
| 132 | return Expression{}, err |
| 133 | } |
| 134 | |
| 135 | return Expression{ |
| 136 | Key: words[0], |
| 137 | Operator: comparator, |
| 138 | Value: words[2], |
| 139 | }, nil |
| 140 | } |
| 141 | |
| 142 | func getComparatorType(op string) (OperatorType, error) { |
| 143 | switch op { |
no test coverage detected