-
Notifications
You must be signed in to change notification settings - Fork 152
/
filter_opt.go
42 lines (37 loc) · 994 Bytes
/
filter_opt.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
32
33
34
35
36
37
38
39
40
41
42
package filter
type (
FilterOpt func(*filter)
Operand uint64
)
const (
bitOnProjectName uint64 = 1 << 0
bitOnJobName uint64 = 1 << 1
bitOnResourceDestination uint64 = 1 << 2
bitOnNamespaceNames uint64 = 1 << 3
bitOnJobNames uint64 = 1 << 4
bitOnNamespaceName uint64 = 1 << 5
)
const (
ProjectName = Operand(bitOnProjectName)
NamespaceName = Operand(bitOnNamespaceName)
NamespaceNames = Operand(bitOnNamespaceNames)
JobName = Operand(bitOnJobName)
JobNames = Operand(bitOnJobNames)
ResourceDestination = Operand(bitOnResourceDestination)
)
func WithString(operand Operand, value string) FilterOpt {
return func(f *filter) {
if value != "" {
f.bits |= uint64(operand)
f.value[operand] = value
}
}
}
func WithStringArray(operand Operand, value []string) FilterOpt {
return func(f *filter) {
if len(value) > 0 {
f.bits |= uint64(operand)
f.value[operand] = value
}
}
}