forked from netobserv/netobserv-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoptions.go
More file actions
82 lines (74 loc) · 2.43 KB
/
options.go
File metadata and controls
82 lines (74 loc) · 2.43 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package cmd
type option struct {
all []optionItem
current int
}
type optionItem struct {
name string
ids []string
}
var (
allOptions = "All"
noOptions = "None"
// displays
rawDisplay = "Raw"
standardDisplay = "Standard"
pktDropFeature = "pktDrop"
dnsFeature = "dnsTracking"
rttFeature = "flowRTT"
networkEventsDisplay = "networkEvents"
display = option{
all: []optionItem{
// exclusive displays
{name: rawDisplay},
{name: standardDisplay},
// per feature displays
{name: "Packet drops", ids: []string{pktDropFeature}},
{name: "DNS", ids: []string{dnsFeature}},
{name: "RTT", ids: []string{rttFeature}},
{name: "Network events", ids: []string{networkEventsDisplay}},
// all features display
{name: allOptions, ids: []string{pktDropFeature, dnsFeature, rttFeature, networkEventsDisplay}},
},
// standard display by default
current: 1,
}
// enrichments
enrichment = option{
all: []optionItem{
// no enrichment
{name: noOptions},
// per field enrichments
{name: "Cluster", ids: []string{"ClusterName"}},
{name: "Zone", ids: []string{"SrcZone", "DstZone"}},
{name: "Host", ids: []string{"SrcK8S_HostIP", "DstK8S_HostIP", "SrcK8S_HostName", "DstK8S_HostName", "FlowDirection"}},
{name: "Namespace", ids: []string{"SrcK8S_Namespace", "DstK8S_Namespace"}},
{name: "Owner", ids: []string{"SrcK8S_OwnerType", "DstK8S_OwnerType", "SrcK8S_OwnerName", "DstK8S_OwnerName", "SrcK8S_Namespace", "DstK8S_Namespace"}},
{name: "Resource", ids: []string{"SrcK8S_Type", "DstK8S_Type", "SrcK8S_Name", "DstK8S_Name", "SrcK8S_Namespace", "DstK8S_Namespace"}},
{name: "SubnetLabel", ids: []string{"SrcSubnetLabel", "DstSubnetLabel"}},
// all fields
{name: allOptions, ids: []string{
"ClusterName",
"SrcZone", "DstZone",
"SrcK8S_HostIP", "DstK8S_HostIP", "SrcK8S_HostName", "DstK8S_HostName",
"SrcK8S_Namespace", "DstK8S_Namespace",
"SrcK8S_OwnerType", "DstK8S_OwnerType", "SrcK8S_OwnerName", "DstK8S_OwnerName",
"SrcK8S_Type", "DstK8S_Type", "SrcK8S_Name", "DstK8S_Name",
"SrcSubnetLabel", "DstSubnetLabel",
}},
},
// resource enrichment by default
current: 6,
}
)
func (opt *option) getCurrentItem() optionItem {
return opt.all[opt.current]
}
func (opt *option) prev() {
opt.current += len(opt.all) - 1
opt.current %= len(opt.all)
}
func (opt *option) next() {
opt.current++
opt.current %= len(opt.all)
}