Skip to content

Commit 082668b

Browse files
committed
fix(codecs): Move protobuf codec options under a protobuf key
Follow up to #18019 (comment) The option "namespacing" is per: https://github.com/vectordotdev/vector/blob/master/docs/specs/configuration.md#polymorphism Signed-off-by: Jesse Szwedko <[email protected]>
1 parent a06c711 commit 082668b

19 files changed

+327
-223
lines changed

lib/codecs/src/decoding/format/protobuf.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::path::PathBuf;
44

55
use bytes::Bytes;
66
use chrono::Utc;
7+
use derivative::Derivative;
78
use ordered_float::NotNan;
89
use prost_reflect::{DescriptorPool, DynamicMessage, MessageDescriptor, ReflectMessage};
910
use smallvec::{smallvec, SmallVec};
@@ -22,11 +23,12 @@ use super::Deserializer;
2223
#[configurable_component]
2324
#[derive(Debug, Clone, Default)]
2425
pub struct ProtobufDeserializerConfig {
25-
/// Path to desc file
26-
desc_file: PathBuf,
27-
28-
/// message type. e.g package.message
29-
message_type: String,
26+
/// Protobuf-specific decoding options.
27+
#[serde(
28+
default,
29+
skip_serializing_if = "vector_core::serde::skip_serializing_if_default"
30+
)]
31+
pub protobuf: ProtobufDeserializerOptions,
3032
}
3133

3234
impl ProtobufDeserializerConfig {
@@ -66,6 +68,18 @@ impl ProtobufDeserializerConfig {
6668
}
6769
}
6870

71+
/// Protobuf-specific decoding options.
72+
#[configurable_component]
73+
#[derive(Debug, Clone, PartialEq, Eq, Derivative)]
74+
#[derivative(Default)]
75+
pub struct ProtobufDeserializerOptions {
76+
/// Path to desc file
77+
desc_file: PathBuf,
78+
79+
/// message type. e.g package.message
80+
message_type: String,
81+
}
82+
6983
/// Deserializer that builds `Event`s from a byte frame containing protobuf.
7084
#[derive(Debug, Clone)]
7185
pub struct ProtobufDeserializer {
@@ -125,8 +139,8 @@ impl TryFrom<&ProtobufDeserializerConfig> for ProtobufDeserializer {
125139
type Error = vector_common::Error;
126140
fn try_from(config: &ProtobufDeserializerConfig) -> vector_common::Result<Self> {
127141
let message_descriptor = ProtobufDeserializer::get_message_descriptor(
128-
&config.desc_file,
129-
config.message_type.clone(),
142+
&config.protobuf.desc_file,
143+
config.protobuf.message_type.clone(),
130144
)?;
131145
Ok(Self::new(message_descriptor))
132146
}

website/cue/reference/components/sources/base/amqp.cue

+17-12
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ base: components: sources: amqp: configuration: {
100100
}
101101
}
102102
}
103-
desc_file: {
104-
description: "Path to desc file"
105-
relevant_when: "codec = \"protobuf\""
106-
required: true
107-
type: string: {}
108-
}
109103
gelf: {
110104
description: "GELF-specific decoding options."
111105
relevant_when: "codec = \"gelf\""
@@ -138,12 +132,6 @@ base: components: sources: amqp: configuration: {
138132
type: bool: default: true
139133
}
140134
}
141-
message_type: {
142-
description: "message type. e.g package.message"
143-
relevant_when: "codec = \"protobuf\""
144-
required: true
145-
type: string: {}
146-
}
147135
native_json: {
148136
description: "Vector's native JSON-specific decoding options."
149137
relevant_when: "codec = \"native_json\""
@@ -160,6 +148,23 @@ base: components: sources: amqp: configuration: {
160148
type: bool: default: true
161149
}
162150
}
151+
protobuf: {
152+
description: "Protobuf-specific decoding options."
153+
relevant_when: "codec = \"protobuf\""
154+
required: false
155+
type: object: options: {
156+
desc_file: {
157+
description: "Path to desc file"
158+
required: false
159+
type: string: default: ""
160+
}
161+
message_type: {
162+
description: "message type. e.g package.message"
163+
required: false
164+
type: string: default: ""
165+
}
166+
}
167+
}
163168
syslog: {
164169
description: "Syslog-specific decoding options."
165170
relevant_when: "codec = \"syslog\""

website/cue/reference/components/sources/base/aws_kinesis_firehose.cue

+17-12
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ base: components: sources: aws_kinesis_firehose: configuration: {
103103
}
104104
}
105105
}
106-
desc_file: {
107-
description: "Path to desc file"
108-
relevant_when: "codec = \"protobuf\""
109-
required: true
110-
type: string: {}
111-
}
112106
gelf: {
113107
description: "GELF-specific decoding options."
114108
relevant_when: "codec = \"gelf\""
@@ -141,12 +135,6 @@ base: components: sources: aws_kinesis_firehose: configuration: {
141135
type: bool: default: true
142136
}
143137
}
144-
message_type: {
145-
description: "message type. e.g package.message"
146-
relevant_when: "codec = \"protobuf\""
147-
required: true
148-
type: string: {}
149-
}
150138
native_json: {
151139
description: "Vector's native JSON-specific decoding options."
152140
relevant_when: "codec = \"native_json\""
@@ -163,6 +151,23 @@ base: components: sources: aws_kinesis_firehose: configuration: {
163151
type: bool: default: true
164152
}
165153
}
154+
protobuf: {
155+
description: "Protobuf-specific decoding options."
156+
relevant_when: "codec = \"protobuf\""
157+
required: false
158+
type: object: options: {
159+
desc_file: {
160+
description: "Path to desc file"
161+
required: false
162+
type: string: default: ""
163+
}
164+
message_type: {
165+
description: "message type. e.g package.message"
166+
required: false
167+
type: string: default: ""
168+
}
169+
}
170+
}
166171
syslog: {
167172
description: "Syslog-specific decoding options."
168173
relevant_when: "codec = \"syslog\""

website/cue/reference/components/sources/base/aws_s3.cue

+17-12
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,6 @@ base: components: sources: aws_s3: configuration: {
198198
}
199199
}
200200
}
201-
desc_file: {
202-
description: "Path to desc file"
203-
relevant_when: "codec = \"protobuf\""
204-
required: true
205-
type: string: {}
206-
}
207201
gelf: {
208202
description: "GELF-specific decoding options."
209203
relevant_when: "codec = \"gelf\""
@@ -236,12 +230,6 @@ base: components: sources: aws_s3: configuration: {
236230
type: bool: default: true
237231
}
238232
}
239-
message_type: {
240-
description: "message type. e.g package.message"
241-
relevant_when: "codec = \"protobuf\""
242-
required: true
243-
type: string: {}
244-
}
245233
native_json: {
246234
description: "Vector's native JSON-specific decoding options."
247235
relevant_when: "codec = \"native_json\""
@@ -258,6 +246,23 @@ base: components: sources: aws_s3: configuration: {
258246
type: bool: default: true
259247
}
260248
}
249+
protobuf: {
250+
description: "Protobuf-specific decoding options."
251+
relevant_when: "codec = \"protobuf\""
252+
required: false
253+
type: object: options: {
254+
desc_file: {
255+
description: "Path to desc file"
256+
required: false
257+
type: string: default: ""
258+
}
259+
message_type: {
260+
description: "message type. e.g package.message"
261+
required: false
262+
type: string: default: ""
263+
}
264+
}
265+
}
261266
syslog: {
262267
description: "Syslog-specific decoding options."
263268
relevant_when: "codec = \"syslog\""

website/cue/reference/components/sources/base/aws_sqs.cue

+17-12
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,6 @@ base: components: sources: aws_sqs: configuration: {
193193
}
194194
}
195195
}
196-
desc_file: {
197-
description: "Path to desc file"
198-
relevant_when: "codec = \"protobuf\""
199-
required: true
200-
type: string: {}
201-
}
202196
gelf: {
203197
description: "GELF-specific decoding options."
204198
relevant_when: "codec = \"gelf\""
@@ -231,12 +225,6 @@ base: components: sources: aws_sqs: configuration: {
231225
type: bool: default: true
232226
}
233227
}
234-
message_type: {
235-
description: "message type. e.g package.message"
236-
relevant_when: "codec = \"protobuf\""
237-
required: true
238-
type: string: {}
239-
}
240228
native_json: {
241229
description: "Vector's native JSON-specific decoding options."
242230
relevant_when: "codec = \"native_json\""
@@ -253,6 +241,23 @@ base: components: sources: aws_sqs: configuration: {
253241
type: bool: default: true
254242
}
255243
}
244+
protobuf: {
245+
description: "Protobuf-specific decoding options."
246+
relevant_when: "codec = \"protobuf\""
247+
required: false
248+
type: object: options: {
249+
desc_file: {
250+
description: "Path to desc file"
251+
required: false
252+
type: string: default: ""
253+
}
254+
message_type: {
255+
description: "message type. e.g package.message"
256+
required: false
257+
type: string: default: ""
258+
}
259+
}
260+
}
256261
syslog: {
257262
description: "Syslog-specific decoding options."
258263
relevant_when: "codec = \"syslog\""

website/cue/reference/components/sources/base/datadog_agent.cue

+17-12
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ base: components: sources: datadog_agent: configuration: {
8585
}
8686
}
8787
}
88-
desc_file: {
89-
description: "Path to desc file"
90-
relevant_when: "codec = \"protobuf\""
91-
required: true
92-
type: string: {}
93-
}
9488
gelf: {
9589
description: "GELF-specific decoding options."
9690
relevant_when: "codec = \"gelf\""
@@ -123,12 +117,6 @@ base: components: sources: datadog_agent: configuration: {
123117
type: bool: default: true
124118
}
125119
}
126-
message_type: {
127-
description: "message type. e.g package.message"
128-
relevant_when: "codec = \"protobuf\""
129-
required: true
130-
type: string: {}
131-
}
132120
native_json: {
133121
description: "Vector's native JSON-specific decoding options."
134122
relevant_when: "codec = \"native_json\""
@@ -145,6 +133,23 @@ base: components: sources: datadog_agent: configuration: {
145133
type: bool: default: true
146134
}
147135
}
136+
protobuf: {
137+
description: "Protobuf-specific decoding options."
138+
relevant_when: "codec = \"protobuf\""
139+
required: false
140+
type: object: options: {
141+
desc_file: {
142+
description: "Path to desc file"
143+
required: false
144+
type: string: default: ""
145+
}
146+
message_type: {
147+
description: "message type. e.g package.message"
148+
required: false
149+
type: string: default: ""
150+
}
151+
}
152+
}
148153
syslog: {
149154
description: "Syslog-specific decoding options."
150155
relevant_when: "codec = \"syslog\""

website/cue/reference/components/sources/base/demo_logs.cue

+17-12
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ base: components: sources: demo_logs: configuration: {
6464
}
6565
}
6666
}
67-
desc_file: {
68-
description: "Path to desc file"
69-
relevant_when: "codec = \"protobuf\""
70-
required: true
71-
type: string: {}
72-
}
7367
gelf: {
7468
description: "GELF-specific decoding options."
7569
relevant_when: "codec = \"gelf\""
@@ -102,12 +96,6 @@ base: components: sources: demo_logs: configuration: {
10296
type: bool: default: true
10397
}
10498
}
105-
message_type: {
106-
description: "message type. e.g package.message"
107-
relevant_when: "codec = \"protobuf\""
108-
required: true
109-
type: string: {}
110-
}
11199
native_json: {
112100
description: "Vector's native JSON-specific decoding options."
113101
relevant_when: "codec = \"native_json\""
@@ -124,6 +112,23 @@ base: components: sources: demo_logs: configuration: {
124112
type: bool: default: true
125113
}
126114
}
115+
protobuf: {
116+
description: "Protobuf-specific decoding options."
117+
relevant_when: "codec = \"protobuf\""
118+
required: false
119+
type: object: options: {
120+
desc_file: {
121+
description: "Path to desc file"
122+
required: false
123+
type: string: default: ""
124+
}
125+
message_type: {
126+
description: "message type. e.g package.message"
127+
required: false
128+
type: string: default: ""
129+
}
130+
}
131+
}
127132
syslog: {
128133
description: "Syslog-specific decoding options."
129134
relevant_when: "codec = \"syslog\""

0 commit comments

Comments
 (0)