Skip to content

Commit 4549b72

Browse files
Merge pull request #229 from OlivierCazade/api-omitempty
Add omitempty flag to stage config
2 parents 217223d + 18be06a commit 4549b72

13 files changed

+58
-58
lines changed

pkg/api/conn_track.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import "time"
2121

2222
type ConnTrack struct {
2323
// TODO: should by a pointer instead?
24-
KeyDefinition KeyDefinition `yaml:"keyDefinition" doc:"fields that are used to identify the connection"`
25-
OutputRecordTypes []string `yaml:"outputRecordTypes" enum:"ConnTrackOutputRecordTypeEnum" doc:"output record types to emit"`
26-
OutputFields []OutputField `yaml:"outputFields" doc:"list of output fields"`
27-
EndConnectionTimeout time.Duration `yaml:"endConnectionTimeout" doc:"duration of time to wait from the last flow log to end a connection"`
24+
KeyDefinition KeyDefinition `yaml:"keyDefinition,omitempty" doc:"fields that are used to identify the connection"`
25+
OutputRecordTypes []string `yaml:"outputRecordTypes,omitempty" enum:"ConnTrackOutputRecordTypeEnum" doc:"output record types to emit"`
26+
OutputFields []OutputField `yaml:"outputFields,omitempty" doc:"list of output fields"`
27+
EndConnectionTimeout time.Duration `yaml:"endConnectionTimeout,omitempty" doc:"duration of time to wait from the last flow log to end a connection"`
2828
}
2929

3030
type ConnTrackOutputRecordTypeEnum struct {
@@ -38,12 +38,12 @@ func ConnTrackOutputRecordTypeName(operation string) string {
3838
}
3939

4040
type KeyDefinition struct {
41-
FieldGroups []FieldGroup `yaml:"fieldGroups" doc:"list of field group definitions"`
42-
Hash ConnTrackHash `yaml:"hash" doc:"how to build the connection hash"`
41+
FieldGroups []FieldGroup `yaml:"fieldGroups,omitempty" doc:"list of field group definitions"`
42+
Hash ConnTrackHash `yaml:"hash,omitempty" doc:"how to build the connection hash"`
4343
}
4444

4545
type FieldGroup struct {
46-
Name string `yaml:"name" doc:"field group name"`
46+
Name string `yaml:"name,omitempty" doc:"field group name"`
4747
Fields []string `yaml:"fields" doc:"list of fields in the group"`
4848
}
4949

@@ -54,16 +54,16 @@ type FieldGroup struct {
5454
// When they are not set, a different hash will be computed for A->B and B->A,
5555
// and they are tracked as different connections.
5656
type ConnTrackHash struct {
57-
FieldGroupRefs []string `yaml:"fieldGroupRefs" doc:"list of field group names to build the hash"`
58-
FieldGroupARef string `yaml:"fieldGroupARef" doc:"field group name of endpoint A"`
59-
FieldGroupBRef string `yaml:"fieldGroupBRef" doc:"field group name of endpoint B"`
57+
FieldGroupRefs []string `yaml:"fieldGroupRefs,omitempty" doc:"list of field group names to build the hash"`
58+
FieldGroupARef string `yaml:"fieldGroupARef,omitempty" doc:"field group name of endpoint A"`
59+
FieldGroupBRef string `yaml:"fieldGroupBRef,omitempty" doc:"field group name of endpoint B"`
6060
}
6161

6262
type OutputField struct {
63-
Name string `yaml:"name" doc:"output field name"`
64-
Operation string `yaml:"operation" enum:"ConnTrackOperationEnum" doc:"aggregate operation on the field value"`
65-
SplitAB bool `yaml:"splitAB" doc:"When true, 2 output fields will be created. One for A->B and one for B->A flows."`
66-
Input string `yaml:"input" doc:"The input field to base the operation on. When omitted, 'name' is used"`
63+
Name string `yaml:"name,omitempty" doc:"output field name"`
64+
Operation string `yaml:"operation,omitempty" enum:"ConnTrackOperationEnum" doc:"aggregate operation on the field value"`
65+
SplitAB bool `yaml:"splitAB,omitempty" doc:"When true, 2 output fields will be created. One for A->B and one for B->A flows."`
66+
Input string `yaml:"input,omitempty" doc:"The input field to base the operation on. When omitted, 'name' is used"`
6767
}
6868

6969
type ConnTrackOperationEnum struct {

pkg/api/decode_aws.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
package api
1919

2020
type DecodeAws struct {
21-
Fields []string `yaml:"fields" json:"fields" doc:"list of aws flow log fields"`
21+
Fields []string `yaml:"fields,omitempty" json:"fields" doc:"list of aws flow log fields"`
2222
}

pkg/api/encode_kafka.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ package api
2020
type EncodeKafka struct {
2121
Address string `yaml:"address" json:"address" doc:"address of kafka server"`
2222
Topic string `yaml:"topic" json:"topic" doc:"kafka topic to write to"`
23-
Balancer string `yaml:"balancer" json:"balancer" enum:"KafkaEncodeBalancerEnum" doc:"one of the following:"`
24-
WriteTimeout int64 `yaml:"writeTimeout" json:"writeTimeout" doc:"timeout (in seconds) for write operation performed by the Writer"`
25-
ReadTimeout int64 `yaml:"readTimeout" json:"readTimeout" doc:"timeout (in seconds) for read operation performed by the Writer"`
26-
BatchBytes int64 `yaml:"batchBytes" json:"batchBytes" doc:"limit the maximum size of a request in bytes before being sent to a partition"`
27-
BatchSize int `yaml:"batchSize" json:"batchSize" doc:"limit on how many messages will be buffered before being sent to a partition"`
23+
Balancer string `yaml:"balancer,omitempty" json:"balancer,omitempty" enum:"KafkaEncodeBalancerEnum" doc:"one of the following:"`
24+
WriteTimeout int64 `yaml:"writeTimeout,omitempty" json:"writeTimeout,omitempty" doc:"timeout (in seconds) for write operation performed by the Writer"`
25+
ReadTimeout int64 `yaml:"readTimeout,omitempty" json:"readTimeout,omitempty" doc:"timeout (in seconds) for read operation performed by the Writer"`
26+
BatchBytes int64 `yaml:"batchBytes,omitempty" json:"batchBytes,omitempty" doc:"limit the maximum size of a request in bytes before being sent to a partition"`
27+
BatchSize int `yaml:"batchSize,omitempty" json:"batchSize,omitempty" doc:"limit on how many messages will be buffered before being sent to a partition"`
2828
}
2929

3030
type KafkaEncodeBalancerEnum struct {

pkg/api/encode_prom.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
package api
1919

2020
type PromEncode struct {
21-
Metrics PromMetricsItems `yaml:"metrics" json:"metrics" doc:"list of prometheus metric definitions, each includes:"`
22-
Port int `yaml:"port" json:"port" doc:"port number to expose \"/metrics\" endpoint"`
23-
Prefix string `yaml:"prefix" json:"prefix" doc:"prefix added to each metric name"`
24-
ExpiryTime int `yaml:"expiryTime" json:"expiryTime" doc:"seconds of no-flow to wait before deleting prometheus data item"`
21+
Metrics PromMetricsItems `yaml:"metrics" json:"metrics,omitempty" doc:"list of prometheus metric definitions, each includes:"`
22+
Port int `yaml:"port" json:"port,omitempty" doc:"port number to expose \"/metrics\" endpoint"`
23+
Prefix string `yaml:"prefix" json:"prefix,omitempty" doc:"prefix added to each metric name"`
24+
ExpiryTime int `yaml:"expiryTime" json:"expiryTime,omitempty" doc:"seconds of no-flow to wait before deleting prometheus data item"`
2525
}
2626

2727
type PromEncodeOperationEnum struct {

pkg/api/extract_aggregate.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ type AggregateBy []string
44
type AggregateOperation string
55

66
type AggregateDefinition struct {
7-
Name string `yaml:"name" json:"name" doc:"description of aggregation result"`
8-
By AggregateBy `yaml:"by" json:"by" doc:"list of fields on which to aggregate"`
9-
Operation AggregateOperation `yaml:"operation" json:"operation" doc:"sum, min, max, avg or raw_values"`
10-
RecordKey string `yaml:"recordKey" json:"recordKey" doc:"internal field on which to perform the operation"`
11-
TopK int `yaml:"topK" json:"topK" doc:"number of highest incidence to report (default - report all)"`
7+
Name string `yaml:"name,omitempty" json:"name,omitempty" doc:"description of aggregation result"`
8+
By AggregateBy `yaml:"by,omitempty" json:"by,omitempty" doc:"list of fields on which to aggregate"`
9+
Operation AggregateOperation `yaml:"operation,omitempty" json:"operation,omitempty" doc:"sum, min, max, avg or raw_values"`
10+
RecordKey string `yaml:"recordKey,omitempty" json:"recordKey,omitempty" doc:"internal field on which to perform the operation"`
11+
TopK int `yaml:"topK,omitempty" json:"topK,omitempty" doc:"number of highest incidence to report (default - report all)"`
1212
}

pkg/api/ingest_collector.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
package api
1919

2020
type IngestCollector struct {
21-
HostName string `yaml:"hostName" json:"hostName" doc:"the hostname to listen on"`
22-
Port int `yaml:"port" json:"port" doc:"the port number to listen on, for IPFIX/NetFlow v9. Omit or set to 0 to disable IPFIX/NetFlow v9 ingestion"`
23-
PortLegacy int `yaml:"portLegacy" json:"portLegacy" doc:"the port number to listen on, for legacy NetFlow v5. Omit or set to 0 to disable NetFlow v5 ingestion"`
24-
BatchMaxLen int `yaml:"batchMaxLen" json:"batchMaxLen" doc:"the number of accumulated flows before being forwarded for processing"`
21+
HostName string `yaml:"hostName,omitempty" json:"hostName,omitempty" doc:"the hostname to listen on"`
22+
Port int `yaml:"port,omitempty" json:"port,omitempty" doc:"the port number to listen on, for IPFIX/NetFlow v9. Omit or set to 0 to disable IPFIX/NetFlow v9 ingestion"`
23+
PortLegacy int `yaml:"portLegacy,omitempty" json:"portLegacy,omitempty" doc:"the port number to listen on, for legacy NetFlow v5. Omit or set to 0 to disable NetFlow v5 ingestion"`
24+
BatchMaxLen int `yaml:"batchMaxLen,omitempty" json:"batchMaxLen,omitempty" doc:"the number of accumulated flows before being forwarded for processing"`
2525
}

pkg/api/ingest_grpc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package api
22

33
type IngestGRPCProto struct {
4-
Port int `yaml:"port" json:"port" doc:"the port number to listen on"`
5-
BufferLen int `yaml:"bufferLength" json:"bufferLength" doc:"the length of the ingest channel buffer, in groups of flows, containing each group hundreds of flows (default: 100)"`
4+
Port int `yaml:"port,omitempty" json:"port,omitempty" doc:"the port number to listen on"`
5+
BufferLen int `yaml:"bufferLength,omitempty" json:"bufferLength,omitempty" doc:"the length of the ingest channel buffer, in groups of flows, containing each group hundreds of flows (default: 100)"`
66
}

pkg/api/ingest_kafka.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
package api
1919

2020
type IngestKafka struct {
21-
Brokers []string `yaml:"brokers" json:"brokers" doc:"list of kafka broker addresses"`
22-
Topic string `yaml:"topic" json:"topic" doc:"kafka topic to listen on"`
23-
GroupId string `yaml:"groupid" json:"groupid" doc:"separate groupid for each consumer on specified topic"`
24-
GroupBalancers []string `yaml:"groupBalancers" json:"groupBalancers" doc:"list of balancing strategies (range, roundRobin, rackAffinity)"`
25-
StartOffset string `yaml:"startOffset" json:"startOffset" doc:"FirstOffset (least recent - default) or LastOffset (most recent) offset available for a partition"`
26-
BatchReadTimeout int64 `yaml:"batchReadTimeout" json:"batchReadTimeout" doc:"how often (in milliseconds) to process input"`
21+
Brokers []string `yaml:"brokers,omitempty" json:"brokers,omitempty" doc:"list of kafka broker addresses"`
22+
Topic string `yaml:"topic,omitempty" json:"topic,omitempty" doc:"kafka topic to listen on"`
23+
GroupId string `yaml:"groupid,omitempty" json:"groupid,omitempty" doc:"separate groupid for each consumer on specified topic"`
24+
GroupBalancers []string `yaml:"groupBalancers,omitempty" json:"groupBalancers,omitempty" doc:"list of balancing strategies (range, roundRobin, rackAffinity)"`
25+
StartOffset string `yaml:"startOffset,omitempty" json:"startOffset,omitempty" doc:"FirstOffset (least recent - default) or LastOffset (most recent) offset available for a partition"`
26+
BatchReadTimeout int64 `yaml:"batchReadTimeout,omitempty" json:"batchReadTimeout,omitempty" doc:"how often (in milliseconds) to process input"`
2727
}

pkg/api/transform_filter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package api
1919

2020
type TransformFilter struct {
21-
Rules []TransformFilterRule `yaml:"rules" json:"rules" doc:"list of filter rules, each includes:"`
21+
Rules []TransformFilterRule `yaml:"rules,omitempty" json:"rules,omitempty" doc:"list of filter rules, each includes:"`
2222
}
2323

2424
type TransformFilterOperationEnum struct {
@@ -32,6 +32,6 @@ func TransformFilterOperationName(operation string) string {
3232
}
3333

3434
type TransformFilterRule struct {
35-
Input string `yaml:"input" json:"input" doc:"entry input field"`
36-
Type string `yaml:"type" json:"type" enum:"TransformFilterOperationEnum" doc:"one of the following:"`
35+
Input string `yaml:"input,omitempty" json:"input,omitempty" doc:"entry input field"`
36+
Type string `yaml:"type,omitempty" json:"type,omitempty" enum:"TransformFilterOperationEnum" doc:"one of the following:"`
3737
}

pkg/api/transform_generic.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
package api
1919

2020
type TransformGeneric struct {
21-
Policy string `yaml:"policy" json:"policy" enum:"TransformGenericOperationEnum" doc:"key replacement policy; may be one of the following:"`
22-
Rules []GenericTransformRule `yaml:"rules" json:"rules" doc:"list of transform rules, each includes:"`
21+
Policy string `yaml:"policy,omitempty" json:"policy,omitempty" enum:"TransformGenericOperationEnum" doc:"key replacement policy; may be one of the following:"`
22+
Rules []GenericTransformRule `yaml:"rules,omitempty" json:"rules,omitempty" doc:"list of transform rules, each includes:"`
2323
}
2424

2525
type TransformGenericOperationEnum struct {
@@ -32,8 +32,8 @@ func TransformGenericOperationName(operation string) string {
3232
}
3333

3434
type GenericTransformRule struct {
35-
Input string `yaml:"input" json:"input" doc:"entry input field"`
36-
Output string `yaml:"output" json:"output" doc:"entry output field"`
35+
Input string `yaml:"input,omitempty" json:"input,omitempty" doc:"entry input field"`
36+
Output string `yaml:"output,omitempty" json:"output,omitempty" doc:"entry output field"`
3737
}
3838

3939
type GenericTransform []GenericTransformRule

0 commit comments

Comments
 (0)