This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
flow.go
68 lines (62 loc) · 1.57 KB
/
flow.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
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
package logging
type FlowConfig struct {
Name string
Namespace string
SelectLabels map[string]string
Outputs []string
ParserType string
}
type Parse struct {
Type string `yaml:"type"`
}
type Parser struct {
RemoveKeyNameField bool `yaml:"remove_key_name_field"`
ReserveData bool `yaml:"reserve_data"`
Parse *Parse `yaml:"parse"`
}
type Filter struct {
Parser *Parser `yaml:"parser,omitempty"`
TagNormaliser map[string]string `yaml:"tag_normaliser,omitempty"`
}
type FlowSpec struct {
Filters []*Filter `yaml:"filters,omitempty"`
Selectors map[string]string `yaml:"selectors,omitempty"`
OutputRefs []string `yaml:"outputRefs"`
}
type Flow struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
Metadata *Metadata `yaml:"metadata"`
Spec *FlowSpec `yaml:"spec"`
}
func NewFlow(conf *FlowConfig) *Flow {
return &Flow{
APIVersion: "logging.banzaicloud.io/v1beta1",
Kind: "Flow",
Metadata: &Metadata{
Name: conf.Name,
Namespace: conf.Namespace,
},
Spec: &FlowSpec{
Filters: []*Filter{
&Filter{
Parser: &Parser{
RemoveKeyNameField: true,
ReserveData: true,
Parse: &Parse{
Type: conf.ParserType,
},
},
},
&Filter{
TagNormaliser: map[string]string{
"metadata": "${namespace}.${container}.${pod}",
"metadata_name": "${namespace_name}.${container_name}.${pod_name}",
},
},
},
Selectors: conf.SelectLabels,
OutputRefs: conf.Outputs,
},
}
}