refactor linux dashboard

This commit is contained in:
Ulric Qin 2022-07-27 19:05:00 +08:00
parent 7c351e09e5
commit 64646d2ace
3 changed files with 1572 additions and 1526 deletions

File diff suppressed because it is too large Load Diff

View File

@ -13,10 +13,10 @@ import (
type TagFilter struct {
Key string `json:"key"` // tag key
Func string `json:"func"` // == | =~ | in
Func string `json:"func"` // `==` | `=~` | `in` | `!=` | `!~` | `not in`
Value string `json:"value"` // tag value
Regexp *regexp.Regexp // parse value to regexp if func = '=~'
Vset map[string]struct{} // parse value to regexp if func = 'in'
Regexp *regexp.Regexp // parse value to regexp if func = '=~' or '!~'
Vset map[string]struct{} // parse value to regexp if func = 'in' or 'not in'
}
type AlertMute struct {

View File

@ -88,12 +88,12 @@ func (s *AlertSubscribe) Parse() error {
}
for i := 0; i < len(s.ITags); i++ {
if s.ITags[i].Func == "=~" {
if s.ITags[i].Func == "=~" || s.ITags[i].Func == "!~" {
s.ITags[i].Regexp, err = regexp.Compile(s.ITags[i].Value)
if err != nil {
return err
}
} else if s.ITags[i].Func == "in" {
} else if s.ITags[i].Func == "in" || s.ITags[i].Func == "not in" {
arr := strings.Fields(s.ITags[i].Value)
s.ITags[i].Vset = make(map[string]struct{})
for j := 0; j < len(arr); j++ {