mirror of
https://github.com/prymitive/karma
synced 2026-08-23 11:56:20 +00:00
feat(api): extra fields with parsed filter data in the API response
This commit is contained in:
@@ -15,6 +15,9 @@ type FilterT interface {
|
||||
GetRawText() string
|
||||
GetHits() int
|
||||
GetIsValid() bool
|
||||
GetName() string
|
||||
GetMatcher() string
|
||||
GetValue() string
|
||||
}
|
||||
|
||||
type alertFilter struct {
|
||||
@@ -49,6 +52,21 @@ func (filter *alertFilter) GetIsValid() bool {
|
||||
return filter.IsValid
|
||||
}
|
||||
|
||||
func (filter *alertFilter) GetName() string {
|
||||
return filter.Matched
|
||||
}
|
||||
|
||||
func (filter *alertFilter) GetMatcher() string {
|
||||
if filter.Matcher == nil {
|
||||
return ""
|
||||
}
|
||||
return filter.Matcher.GetOperator()
|
||||
}
|
||||
|
||||
func (filter *alertFilter) GetValue() string {
|
||||
return fmt.Sprintf("%s", filter.Value)
|
||||
}
|
||||
|
||||
type newFilterFactory func() FilterT
|
||||
|
||||
// NewFilter creates new filter object from filter expression like "key=value"
|
||||
|
||||
@@ -3,6 +3,9 @@ package models
|
||||
// Filter holds returned data on any filter passed by the user as part of the query
|
||||
type Filter struct {
|
||||
Text string `json:"text"`
|
||||
Name string `json:"name"`
|
||||
Matcher string `json:"matcher"`
|
||||
Value string `json:"value"`
|
||||
Hits int `json:"hits"`
|
||||
IsValid bool `json:"isValid"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user