@@ -232,6 +232,18 @@ impl Configurator {
232232 & self . config
233233 }
234234
235+ fn get_properties ( & mut self , resource : & Resource , resource_kind : & Kind ) -> Result < Option < Map < String , Value > > , DscError > {
236+ match resource_kind {
237+ Kind :: Group => {
238+ // if Group resource, we leave it to the resource to handle expressions
239+ Ok ( resource. properties . clone ( ) )
240+ } ,
241+ _ => {
242+ Ok ( self . invoke_property_expressions ( resource. properties . as_ref ( ) ) ?)
243+ } ,
244+ }
245+ }
246+
235247 /// Invoke the get operation on a resource.
236248 ///
237249 /// # Returns
@@ -252,15 +264,7 @@ impl Configurator {
252264 let Some ( dsc_resource) = discovery. find_resource ( & resource. resource_type ) else {
253265 return Err ( DscError :: ResourceNotFound ( resource. resource_type ) ) ;
254266 } ;
255- let properties = match & dsc_resource. kind {
256- Kind :: Group => {
257- // if Group resource, we leave it to the resource to handle expressions
258- resource. properties . clone ( )
259- } ,
260- _ => {
261- self . invoke_property_expressions ( resource. properties . as_ref ( ) ) ?
262- } ,
263- } ;
267+ let properties = self . get_properties ( & resource, & dsc_resource. kind ) ?;
264268 debug ! ( "resource_type {}" , & resource. resource_type) ;
265269 let filter = add_metadata ( & dsc_resource. kind , properties) ?;
266270 trace ! ( "filter: {filter}" ) ;
@@ -338,15 +342,7 @@ impl Configurator {
338342 let Some ( dsc_resource) = discovery. find_resource ( & resource. resource_type ) else {
339343 return Err ( DscError :: ResourceNotFound ( resource. resource_type ) ) ;
340344 } ;
341- let properties = match & dsc_resource. kind {
342- Kind :: Group => {
343- // if Group resource, we leave it to the resource to handle expressions
344- resource. properties . clone ( )
345- } ,
346- _ => {
347- self . invoke_property_expressions ( resource. properties . as_ref ( ) ) ?
348- } ,
349- } ;
345+ let properties = self . get_properties ( & resource, & dsc_resource. kind ) ?;
350346 debug ! ( "resource_type {}" , & resource. resource_type) ;
351347
352348 // see if the properties contains `_exist` and is false
@@ -491,15 +487,7 @@ impl Configurator {
491487 let Some ( dsc_resource) = discovery. find_resource ( & resource. resource_type ) else {
492488 return Err ( DscError :: ResourceNotFound ( resource. resource_type ) ) ;
493489 } ;
494- let properties = match & dsc_resource. kind {
495- Kind :: Group => {
496- // if Group resource, we leave it to the resource to handle expressions
497- resource. properties . clone ( )
498- } ,
499- _ => {
500- self . invoke_property_expressions ( resource. properties . as_ref ( ) ) ?
501- } ,
502- } ;
490+ let properties = self . get_properties ( & resource, & dsc_resource. kind ) ?;
503491 debug ! ( "resource_type {}" , & resource. resource_type) ;
504492 let expected = add_metadata ( & dsc_resource. kind , properties) ?;
505493 trace ! ( "{}" , t!( "configure.mod.expectedState" , state = expected) ) ;
@@ -575,15 +563,7 @@ impl Configurator {
575563 let Some ( dsc_resource) = discovery. find_resource ( & resource. resource_type ) else {
576564 return Err ( DscError :: ResourceNotFound ( resource. resource_type . clone ( ) ) ) ;
577565 } ;
578- let properties = match & dsc_resource. kind {
579- Kind :: Group => {
580- // if Group resource, we leave it to the resource to handle expressions
581- resource. properties . clone ( )
582- } ,
583- _ => {
584- self . invoke_property_expressions ( resource. properties . as_ref ( ) ) ?
585- } ,
586- } ;
566+ let properties = self . get_properties ( resource, & dsc_resource. kind ) ?;
587567 let input = add_metadata ( & dsc_resource. kind , properties) ?;
588568 trace ! ( "{}" , t!( "configure.mod.exportInput" , input = input) ) ;
589569 let export_result = match add_resource_export_results_to_configuration ( dsc_resource, Some ( dsc_resource) , & mut conf, input. as_str ( ) ) {
0 commit comments