File tree 2 files changed +27
-4
lines changed
2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change
1
+ Vector now supports YAML merges in configuration files, a part of the YAML 1.1
2
+ specification. This functionality is useful for reducing the size of transform
3
+ configurations. See YAML documentation [ here] ( https://yaml.org/type/merge.html ) .
4
+
5
+ authors: lattwood
Original file line number Diff line number Diff line change 66
66
{
67
67
match format {
68
68
Format :: Toml => toml:: from_str ( content) . map_err ( |e| vec ! [ e. to_string( ) ] ) ,
69
- Format :: Yaml => serde_yaml:: from_str ( content) . map_err ( |e| vec ! [ e. to_string( ) ] ) ,
69
+ Format :: Yaml => {
70
+ serde_yaml:: from_str :: < serde_yaml:: Value > ( content) . and_then ( |mut v| {
71
+ v. apply_merge ( ) ?;
72
+ serde_yaml:: from_value ( v)
73
+ } )
74
+ . map_err ( |e| vec ! [ e. to_string( ) ] )
75
+ }
70
76
Format :: Json => serde_json:: from_str ( content) . map_err ( |e| vec ! [ e. to_string( ) ] ) ,
71
77
}
72
78
}
@@ -171,6 +177,10 @@ mod tests {
171
177
type = "socket"
172
178
mode = "tcp"
173
179
address = "127.0.0.1:1235"
180
+ [sources.in2]
181
+ type = "socket"
182
+ mode = "tcp"
183
+ address = "127.0.0.1:1234"
174
184
[transforms.sample]
175
185
type = "sample"
176
186
inputs = ["in"]
@@ -208,10 +218,13 @@ mod tests {
208
218
r#" encoding:"# ,
209
219
r#" type: "csv""# ,
210
220
r#"sources:"# ,
211
- r#" in:"# ,
221
+ r#" in: &a "# ,
212
222
r#" type: "socket""# ,
213
- r#" mode: "tcp""# ,
223
+ r#" mode: &b "tcp""# ,
214
224
r#" address: "127.0.0.1:1235""# ,
225
+ r#" in2:"# ,
226
+ r#" <<: *a"# ,
227
+ r#" address: "127.0.0.1:1234""# ,
215
228
r#"transforms:"# ,
216
229
r#" sample:"# ,
217
230
r#" type: "sample""# ,
@@ -220,7 +233,7 @@ mod tests {
220
233
r#"sinks:"# ,
221
234
r#" out:"# ,
222
235
r#" type: "socket""# ,
223
- r#" mode: "tcp" "# ,
236
+ r#" mode: *b "# ,
224
237
r#" inputs: ["sample"]"# ,
225
238
r#" encoding:"# ,
226
239
r#" codec: "text""# ,
@@ -248,6 +261,11 @@ mod tests {
248
261
"type": "socket",
249
262
"mode": "tcp",
250
263
"address": "127.0.0.1:1235"
264
+ },
265
+ "in2": {
266
+ "type": "socket",
267
+ "mode": "tcp",
268
+ "address": "127.0.0.1:1234"
251
269
}
252
270
},
253
271
"transforms": {
You can’t perform that action at this time.
0 commit comments