| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package selector |
| 4 | |
| 5 | import "github.com/netdata/netdata/go/plugins/pkg/selectorcore" |
| 6 | |
| 7 | type Expr struct { |
| 8 | Allow []string `yaml:"allow,omitempty" json:"allow"` |
| 9 | Deny []string `yaml:"deny,omitempty" json:"deny"` |
| 10 | } |
| 11 | |
| 12 | func (e Expr) Empty() bool { |
| 13 | return len(e.Allow) == 0 && len(e.Deny) == 0 |
| 14 | |
| 15 | } |
| 16 | |
| 17 | func (e Expr) Parse() (Selector, error) { |
| 18 | sel, err := selectorcore.Expr{ |
| 19 | Allow: append([]string(nil), e.Allow...), |
| 20 | Deny: append([]string(nil), e.Deny...), |
| 21 | }.Parse() |
| 22 | if err != nil { |
| 23 | return nil, err |
| 24 | } |
| 25 | return wrapCoreSelector(sel), nil |
| 26 | } |