@@ -31,6 +31,7 @@ pub struct CommandDiscovery {
3131 resources : BTreeMap < String , Vec < DscResource > > ,
3232 adapters : BTreeMap < String , Vec < DscResource > > ,
3333 adapted_resources : BTreeMap < String , Vec < DscResource > > ,
34+ progress_format : ProgressFormat ,
3435}
3536
3637#[ derive( Deserialize ) ]
@@ -56,11 +57,12 @@ impl Default for ResourcePathSetting {
5657}
5758
5859impl CommandDiscovery {
59- pub fn new ( ) -> CommandDiscovery {
60+ pub fn new ( progress_format : ProgressFormat ) -> CommandDiscovery {
6061 CommandDiscovery {
6162 resources : BTreeMap :: new ( ) ,
6263 adapters : BTreeMap :: new ( ) ,
6364 adapted_resources : BTreeMap :: new ( ) ,
65+ progress_format,
6466 }
6567 }
6668
@@ -161,13 +163,13 @@ impl CommandDiscovery {
161163
162164impl Default for CommandDiscovery {
163165 fn default ( ) -> Self {
164- Self :: new ( )
166+ Self :: new ( ProgressFormat :: Default )
165167 }
166168}
167169
168170impl ResourceDiscovery for CommandDiscovery {
169171
170- fn discover_resources ( & mut self , filter : & str , progress_format : ProgressFormat ) -> Result < ( ) , DscError > {
172+ fn discover_resources ( & mut self , filter : & str ) -> Result < ( ) , DscError > {
171173 info ! ( "{}" , t!( "discovery.commandDiscovery.discoverResources" , filter = filter) ) ;
172174
173175 let regex_str = convert_wildcard_to_regex ( filter) ;
@@ -178,7 +180,7 @@ impl ResourceDiscovery for CommandDiscovery {
178180 return Err ( DscError :: Operation ( t ! ( "discovery.commandDiscovery.invalidAdapterFilter" ) . to_string ( ) ) ) ;
179181 } ;
180182
181- let mut progress = ProgressBar :: new ( 1 , progress_format) ?;
183+ let mut progress = ProgressBar :: new ( 1 , self . progress_format ) ?;
182184 progress. write_activity ( t ! ( "discovery.commandDiscovery.progressSearching" ) . to_string ( ) . as_str ( ) ) ;
183185
184186 let mut resources = BTreeMap :: < String , Vec < DscResource > > :: new ( ) ;
@@ -242,9 +244,9 @@ impl ResourceDiscovery for CommandDiscovery {
242244 Ok ( ( ) )
243245 }
244246
245- fn discover_adapted_resources ( & mut self , name_filter : & str , adapter_filter : & str , progress_format : ProgressFormat ) -> Result < ( ) , DscError > {
247+ fn discover_adapted_resources ( & mut self , name_filter : & str , adapter_filter : & str ) -> Result < ( ) , DscError > {
246248 if self . resources . is_empty ( ) && self . adapters . is_empty ( ) {
247- self . discover_resources ( "*" , progress_format ) ?;
249+ self . discover_resources ( "*" ) ?;
248250 }
249251
250252 if self . adapters . is_empty ( ) {
@@ -267,7 +269,7 @@ impl ResourceDiscovery for CommandDiscovery {
267269 return Err ( DscError :: Operation ( "Could not build Regex filter for resource name" . to_string ( ) ) ) ;
268270 } ;
269271
270- let mut progress = ProgressBar :: new ( self . adapters . len ( ) as u64 , progress_format) ?;
272+ let mut progress = ProgressBar :: new ( self . adapters . len ( ) as u64 , self . progress_format ) ?;
271273 progress. write_activity ( "Searching for adapted resources" ) ;
272274
273275 let mut adapted_resources = BTreeMap :: < String , Vec < DscResource > > :: new ( ) ;
@@ -283,7 +285,7 @@ impl ResourceDiscovery for CommandDiscovery {
283285
284286 found_adapter = true ;
285287 info ! ( "Enumerating resources for adapter '{}'" , adapter_name) ;
286- let mut adapter_progress = ProgressBar :: new ( 1 , progress_format) ?;
288+ let mut adapter_progress = ProgressBar :: new ( 1 , self . progress_format ) ?;
287289 adapter_progress. write_activity ( format ! ( "Enumerating resources for adapter '{adapter_name}'" ) . as_str ( ) ) ;
288290 let manifest = if let Some ( manifest) = & adapter. manifest {
289291 if let Ok ( manifest) = import_manifest ( manifest. clone ( ) ) {
@@ -350,18 +352,18 @@ impl ResourceDiscovery for CommandDiscovery {
350352 Ok ( ( ) )
351353 }
352354
353- fn list_available_resources ( & mut self , type_name_filter : & str , adapter_name_filter : & str , progress_format : ProgressFormat ) -> Result < BTreeMap < String , Vec < DscResource > > , DscError > {
355+ fn list_available_resources ( & mut self , type_name_filter : & str , adapter_name_filter : & str ) -> Result < BTreeMap < String , Vec < DscResource > > , DscError > {
354356
355357 trace ! ( "Listing resources with type_name_filter '{type_name_filter}' and adapter_name_filter '{adapter_name_filter}'" ) ;
356358 let mut resources = BTreeMap :: < String , Vec < DscResource > > :: new ( ) ;
357359
358360 if adapter_name_filter. is_empty ( ) {
359- self . discover_resources ( type_name_filter, progress_format ) ?;
361+ self . discover_resources ( type_name_filter) ?;
360362 resources. append ( & mut self . resources ) ;
361363 resources. append ( & mut self . adapters ) ;
362364 } else {
363- self . discover_resources ( "*" , progress_format ) ?;
364- self . discover_adapted_resources ( type_name_filter, adapter_name_filter, progress_format ) ?;
365+ self . discover_resources ( "*" ) ?;
366+ self . discover_adapted_resources ( type_name_filter, adapter_name_filter) ?;
365367
366368 // add/update found adapted resources to the lookup_table
367369 add_resources_to_lookup_table ( & self . adapted_resources ) ;
@@ -374,10 +376,10 @@ impl ResourceDiscovery for CommandDiscovery {
374376 }
375377
376378 // TODO: handle version requirements
377- fn find_resources ( & mut self , required_resource_types : & [ String ] , progress_format : ProgressFormat ) -> Result < BTreeMap < String , DscResource > , DscError >
379+ fn find_resources ( & mut self , required_resource_types : & [ String ] ) -> Result < BTreeMap < String , DscResource > , DscError >
378380 {
379381 debug ! ( "Searching for resources: {:?}" , required_resource_types) ;
380- self . discover_resources ( "*" , progress_format ) ?;
382+ self . discover_resources ( "*" ) ?;
381383
382384 // convert required_resource_types to lowercase to handle case-insentiive search
383385 let mut remaining_required_resource_types = required_resource_types. iter ( ) . map ( |x| x. to_lowercase ( ) ) . collect :: < Vec < String > > ( ) ;
@@ -426,7 +428,7 @@ impl ResourceDiscovery for CommandDiscovery {
426428 }
427429 }
428430
429- self . discover_adapted_resources ( "*" , & adapter_name, progress_format ) ?;
431+ self . discover_adapted_resources ( "*" , & adapter_name) ?;
430432 // add/update found adapted resources to the lookup_table
431433 add_resources_to_lookup_table ( & self . adapted_resources ) ;
432434
0 commit comments