-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
uuid.go
41 lines (33 loc) · 832 Bytes
/
uuid.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
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Hubble
package filters
import (
"context"
flowpb "github.com/cilium/cilium/api/v1/flow"
v1 "github.com/cilium/cilium/pkg/hubble/api/v1"
)
func filterByUUID(uuids []string) FilterFunc {
return func(ev *v1.Event) bool {
flow := ev.GetFlow()
if flow == nil {
return false
}
eid := flow.GetUuid()
for _, id := range uuids {
if id == eid {
return true
}
}
return false
}
}
// UUIDFilter implements filtering based on flow identifiers.
type UUIDFilter struct{}
// OnBuildFilter builds a a flow identifier filter.
func (e *UUIDFilter) OnBuildFilter(ctx context.Context, ff *flowpb.FlowFilter) ([]FilterFunc, error) {
var fs []FilterFunc
if ids := ff.GetUuid(); len(ids) > 0 {
fs = append(fs, filterByUUID(ids))
}
return fs, nil
}