1+ #![ warn( clippy:: pedantic) ]
2+
13use indexmap:: { IndexMap , IndexSet } ;
24use std:: sync:: Arc ;
35use vector_lib:: config:: ComponentKey ;
@@ -8,6 +10,8 @@ use super::{
810 sink:: SinkOuter , transform:: get_transform_output_ids, validation,
911} ;
1012
13+ // https://github.com/vectordotdev/vector/issues/23659
14+ #[ allow( clippy:: too_many_lines, reason = "Preserve existing control flow" ) ]
1115pub fn compile ( mut builder : ConfigBuilder ) -> Result < ( Config , Vec < String > ) , Vec < String > > {
1216 let mut errors = Vec :: new ( ) ;
1317
@@ -112,15 +116,15 @@ pub fn compile(mut builder: ConfigBuilder) -> Result<(Config, Vec<String>), Vec<
112116
113117 if errors. is_empty ( ) {
114118 let mut config = Config {
115- global,
116119 #[ cfg( feature = "api" ) ]
117120 api,
118121 schema,
122+ global,
119123 healthchecks,
120- enrichment_tables,
121124 sources,
122125 sinks,
123126 transforms,
127+ enrichment_tables,
124128 tests,
125129 secret,
126130 graceful_shutdown_duration,
@@ -166,11 +170,11 @@ pub(crate) fn expand_globs(config: &mut ConfigBuilder) {
166170 . map ( |output_id| output_id. to_string ( ) )
167171 . collect :: < IndexSet < String > > ( ) ;
168172
169- for ( id, transform) in config. transforms . iter_mut ( ) {
173+ for ( id, transform) in & mut config. transforms {
170174 expand_globs_inner ( & mut transform. inputs , & id. to_string ( ) , & candidates) ;
171175 }
172176
173- for ( id, sink) in config. sinks . iter_mut ( ) {
177+ for ( id, sink) in & mut config. sinks {
174178 expand_globs_inner ( & mut sink. inputs , & id. to_string ( ) , & candidates) ;
175179 }
176180}
@@ -184,7 +188,7 @@ fn validate_sinks(config: &mut Config) -> Vec<String> {
184188 let mut errors = Vec :: new ( ) ;
185189
186190 // Validate direct sinks
187- for ( key, sink) in config. sinks . iter_mut ( ) {
191+ for ( key, sink) in & mut config. sinks {
188192 let dyn_sink: & dyn DynValidatedSink = sink. inner . as_ref ( ) ;
189193 match dyn_sink. validate_dyn ( ) {
190194 Ok ( state) => sink. validated = Some ( Arc :: from ( state) ) ,
@@ -193,7 +197,7 @@ fn validate_sinks(config: &mut Config) -> Vec<String> {
193197 }
194198
195199 // Validate enrichment table sinks with resolved inputs.
196- for ( key, table) in config. enrichment_tables . iter_mut ( ) {
200+ for ( key, table) in & mut config. enrichment_tables {
197201 if let Some ( ( _, sink) ) = table. as_sink ( key) {
198202 let dyn_sink: & dyn DynValidatedSink = sink. inner . as_ref ( ) ;
199203 match dyn_sink. validate_dyn ( ) {
@@ -215,7 +219,7 @@ enum InputMatcher {
215219
216220impl InputMatcher {
217221 fn matches ( & self , candidate : & str ) -> bool {
218- use InputMatcher :: * ;
222+ use InputMatcher :: { Pattern , String } ;
219223
220224 match self {
221225 Pattern ( pattern) => pattern. matches ( candidate) ,
@@ -224,26 +228,29 @@ impl InputMatcher {
224228 }
225229}
226230
231+ // https://github.com/vectordotdev/vector/issues/23659
232+ #[ allow( clippy:: similar_names, reason = "Naming cleanup deferred" ) ]
227233fn expand_globs_inner ( inputs : & mut Inputs < String > , id : & str , candidates : & IndexSet < String > ) {
228234 let raw_inputs = std:: mem:: take ( inputs) ;
229235 for raw_input in raw_inputs {
230- let matcher = glob:: Pattern :: new ( & raw_input)
231- . map ( InputMatcher :: Pattern )
232- . unwrap_or_else ( |error| {
236+ let matcher = glob:: Pattern :: new ( & raw_input) . map_or_else (
237+ |error| {
233238 warn ! ( message = "Invalid glob pattern for input." , component_id = %id, %error) ;
234- InputMatcher :: String ( raw_input. to_string ( ) )
235- } ) ;
239+ InputMatcher :: String ( raw_input. clone ( ) )
240+ } ,
241+ InputMatcher :: Pattern ,
242+ ) ;
236243 let mut matched = false ;
237244 for input in candidates {
238245 if matcher. matches ( input) && input != id {
239246 matched = true ;
240- inputs. extend ( Some ( input. to_string ( ) ) )
247+ inputs. extend ( Some ( input. clone ( ) ) ) ;
241248 }
242249 }
243250 // If it didn't work as a glob pattern, leave it in the inputs as-is. This lets us give
244251 // more accurate error messages about nonexistent inputs.
245252 if !matched {
246- inputs. extend ( Some ( raw_input) )
253+ inputs. extend ( Some ( raw_input) ) ;
247254 }
248255 }
249256}
0 commit comments