@@ -6,11 +6,10 @@ use crate::configure::context::{Context, ProcessMode};
66use crate :: configure:: { config_doc:: RestartRequired , parameters:: Input } ;
77use crate :: discovery:: discovery_trait:: DiscoveryFilter ;
88use crate :: dscerror:: DscError ;
9- use crate :: dscresources:: invoke_result:: ExportResult ;
109use crate :: dscresources:: {
11- { dscresource:: { Capability , Invoke , get_diff, validate_properties} ,
12- invoke_result:: { GetResult , SetResult , TestResult , ResourceSetResponse } } ,
13- resource_manifest:: Kind ,
10+ { dscresource:: { Capability , Invoke , get_diff, validate_properties, get_adapter_input_kind } ,
11+ invoke_result:: { GetResult , SetResult , TestResult , ExportResult , ResourceSetResponse } } ,
12+ resource_manifest:: { AdapterInputKind , Kind } ,
1413} ;
1514use crate :: DscResource ;
1615use crate :: discovery:: Discovery ;
@@ -177,7 +176,7 @@ fn escape_property_values(properties: &Map<String, Value>) -> Result<Option<Map<
177176}
178177
179178fn add_metadata ( dsc_resource : & DscResource , mut properties : Option < Map < String , Value > > , resource_metadata : Option < Metadata > ) -> Result < String , DscError > {
180- if dsc_resource. kind == Kind :: Adapter {
179+ if dsc_resource. kind == Kind :: Adapter && get_adapter_input_kind ( dsc_resource ) ? == AdapterInputKind :: Full {
181180 // add metadata to the properties so the adapter knows this is a config
182181 let mut metadata: Map < String , Value > = Map :: new ( ) ;
183182 if let Some ( resource_metadata) = resource_metadata {
@@ -319,6 +318,15 @@ impl Configurator {
319318 & self . config
320319 }
321320
321+ /// Get the discovery.
322+ ///
323+ /// # Returns
324+ ///
325+ /// * `&Discovery` - The discovery.
326+ pub fn discovery ( & mut self ) -> & mut Discovery {
327+ & mut self . discovery
328+ }
329+
322330 fn get_properties ( & mut self , resource : & Resource , resource_kind : & Kind ) -> Result < Option < Map < String , Value > > , DscError > {
323331 match resource_kind {
324332 Kind :: Group => {
@@ -342,14 +350,14 @@ impl Configurator {
342350 /// This function will return an error if the underlying resource fails.
343351 pub fn invoke_get ( & mut self ) -> Result < ConfigurationGetResult , DscError > {
344352 self . unroll_copy_loops ( ) ?;
345-
353+
346354 let mut result = ConfigurationGetResult :: new ( ) ;
347355 let resources = get_resource_invocation_order ( & self . config , & mut self . statement_parser , & self . context ) ?;
348356 let mut progress = ProgressBar :: new ( resources. len ( ) as u64 , self . progress_format ) ?;
349357 let discovery = & mut self . discovery . clone ( ) ;
350358 for resource in resources {
351359 let evaluated_name = self . evaluate_resource_name ( & resource. name ) ?;
352-
360+
353361 progress. set_resource ( & evaluated_name, & resource. resource_type ) ;
354362 progress. write_activity ( format ! ( "Get '{evaluated_name}'" ) . as_str ( ) ) ;
355363 if self . skip_resource ( & resource) ? {
@@ -424,14 +432,14 @@ impl Configurator {
424432 #[ allow( clippy:: too_many_lines) ]
425433 pub fn invoke_set ( & mut self , skip_test : bool ) -> Result < ConfigurationSetResult , DscError > {
426434 self . unroll_copy_loops ( ) ?;
427-
435+
428436 let mut result = ConfigurationSetResult :: new ( ) ;
429437 let resources = get_resource_invocation_order ( & self . config , & mut self . statement_parser , & self . context ) ?;
430438 let mut progress = ProgressBar :: new ( resources. len ( ) as u64 , self . progress_format ) ?;
431439 let discovery = & mut self . discovery . clone ( ) ;
432440 for resource in resources {
433441 let evaluated_name = self . evaluate_resource_name ( & resource. name ) ?;
434-
442+
435443 progress. set_resource ( & evaluated_name, & resource. resource_type ) ;
436444 progress. write_activity ( format ! ( "Set '{evaluated_name}'" ) . as_str ( ) ) ;
437445 if self . skip_resource ( & resource) ? {
@@ -580,14 +588,14 @@ impl Configurator {
580588 /// This function will return an error if the underlying resource fails.
581589 pub fn invoke_test ( & mut self ) -> Result < ConfigurationTestResult , DscError > {
582590 self . unroll_copy_loops ( ) ?;
583-
591+
584592 let mut result = ConfigurationTestResult :: new ( ) ;
585593 let resources = get_resource_invocation_order ( & self . config , & mut self . statement_parser , & self . context ) ?;
586594 let mut progress = ProgressBar :: new ( resources. len ( ) as u64 , self . progress_format ) ?;
587595 let discovery = & mut self . discovery . clone ( ) ;
588596 for resource in resources {
589597 let evaluated_name = self . evaluate_resource_name ( & resource. name ) ?;
590-
598+
591599 progress. set_resource ( & evaluated_name, & resource. resource_type ) ;
592600 progress. write_activity ( format ! ( "Test '{evaluated_name}'" ) . as_str ( ) ) ;
593601 if self . skip_resource ( & resource) ? {
@@ -658,7 +666,7 @@ impl Configurator {
658666 /// This function will return an error if the underlying resource fails.
659667 pub fn invoke_export ( & mut self ) -> Result < ConfigurationExportResult , DscError > {
660668 self . unroll_copy_loops ( ) ?;
661-
669+
662670 let mut result = ConfigurationExportResult :: new ( ) ;
663671 let mut conf = config_doc:: Configuration :: new ( ) ;
664672 conf. metadata . clone_from ( & self . config . metadata ) ;
@@ -668,7 +676,7 @@ impl Configurator {
668676 let discovery = & mut self . discovery . clone ( ) ;
669677 for resource in & resources {
670678 let evaluated_name = self . evaluate_resource_name ( & resource. name ) ?;
671-
679+
672680 progress. set_resource ( & evaluated_name, & resource. resource_type ) ;
673681 progress. write_activity ( format ! ( "Export '{evaluated_name}'" ) . as_str ( ) ) ;
674682 if self . skip_resource ( resource) ? {
@@ -916,7 +924,7 @@ impl Configurator {
916924 fn unroll_copy_loops ( & mut self ) -> Result < ( ) , DscError > {
917925 let mut config = self . config . clone ( ) ;
918926 let config_copy = config. clone ( ) ;
919-
927+
920928 for resource in config_copy. resources {
921929 // if the resource contains `Copy`, unroll it
922930 if let Some ( copy) = & resource. copy {
@@ -931,7 +939,7 @@ impl Configurator {
931939 return Err ( DscError :: Parser ( t ! ( "configure.mod.copyNameResultNotString" ) . to_string ( ) ) )
932940 } ;
933941 new_resource. name = new_name. to_string ( ) ;
934-
942+
935943 new_resource. copy = None ;
936944 copy_resources. push ( new_resource) ;
937945 }
@@ -941,7 +949,7 @@ impl Configurator {
941949 config. resources . extend ( copy_resources) ;
942950 }
943951 }
944-
952+
945953 self . config = config;
946954 Ok ( ( ) )
947955 }
@@ -967,12 +975,12 @@ impl Configurator {
967975 if self . context . process_mode == ProcessMode :: Copy {
968976 return Ok ( name. to_string ( ) ) ;
969977 }
970-
978+
971979 // evaluate the resource name (handles both expressions and literals)
972980 let Value :: String ( evaluated_name) = self . statement_parser . parse_and_execute ( name, & self . context ) ? else {
973981 return Err ( DscError :: Parser ( t ! ( "configure.mod.nameResultNotString" ) . to_string ( ) ) )
974982 } ;
975-
983+
976984 Ok ( evaluated_name)
977985 }
978986
0 commit comments