forked from percipia/eslgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter.go
31 lines (28 loc) · 792 Bytes
/
filter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* Copyright (c) 2020 Percipia
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Contributor(s):
* Andrew Querol <aquerol@percipia.com>
*/
package command
import "fmt"
type Filter struct {
Delete bool
EventHeader string
FilterValue string
}
func (f Filter) BuildMessage() string {
if f.Delete {
if len(f.FilterValue) > 0 {
// Clear just the specific header value
return fmt.Sprintf("filter delete %s %s", f.EventHeader, f.FilterValue)
}
// Clears all filters for the header
return fmt.Sprintf("filter delete %s", f.EventHeader)
}
return fmt.Sprintf("filter %s %s", f.EventHeader, f.FilterValue)
}