@@ -6,11 +6,10 @@ use crate::configure::context::{Context, ProcessMode};
6
6
use crate :: configure:: { config_doc:: RestartRequired , parameters:: Input } ;
7
7
use crate :: discovery:: discovery_trait:: DiscoveryFilter ;
8
8
use crate :: dscerror:: DscError ;
9
- use crate :: dscresources:: invoke_result:: ExportResult ;
10
9
use 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 } ,
14
13
} ;
15
14
use crate :: DscResource ;
16
15
use crate :: discovery:: Discovery ;
@@ -177,7 +176,7 @@ fn escape_property_values(properties: &Map<String, Value>) -> Result<Option<Map<
177
176
}
178
177
179
178
fn 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 {
181
180
// add metadata to the properties so the adapter knows this is a config
182
181
let mut metadata: Map < String , Value > = Map :: new ( ) ;
183
182
if let Some ( resource_metadata) = resource_metadata {
@@ -319,6 +318,15 @@ impl Configurator {
319
318
& self . config
320
319
}
321
320
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
+
322
330
fn get_properties ( & mut self , resource : & Resource , resource_kind : & Kind ) -> Result < Option < Map < String , Value > > , DscError > {
323
331
match resource_kind {
324
332
Kind :: Group => {
@@ -342,14 +350,14 @@ impl Configurator {
342
350
/// This function will return an error if the underlying resource fails.
343
351
pub fn invoke_get ( & mut self ) -> Result < ConfigurationGetResult , DscError > {
344
352
self . unroll_copy_loops ( ) ?;
345
-
353
+
346
354
let mut result = ConfigurationGetResult :: new ( ) ;
347
355
let resources = get_resource_invocation_order ( & self . config , & mut self . statement_parser , & self . context ) ?;
348
356
let mut progress = ProgressBar :: new ( resources. len ( ) as u64 , self . progress_format ) ?;
349
357
let discovery = & mut self . discovery . clone ( ) ;
350
358
for resource in resources {
351
359
let evaluated_name = self . evaluate_resource_name ( & resource. name ) ?;
352
-
360
+
353
361
progress. set_resource ( & evaluated_name, & resource. resource_type ) ;
354
362
progress. write_activity ( format ! ( "Get '{evaluated_name}'" ) . as_str ( ) ) ;
355
363
if self . skip_resource ( & resource) ? {
@@ -424,14 +432,14 @@ impl Configurator {
424
432
#[ allow( clippy:: too_many_lines) ]
425
433
pub fn invoke_set ( & mut self , skip_test : bool ) -> Result < ConfigurationSetResult , DscError > {
426
434
self . unroll_copy_loops ( ) ?;
427
-
435
+
428
436
let mut result = ConfigurationSetResult :: new ( ) ;
429
437
let resources = get_resource_invocation_order ( & self . config , & mut self . statement_parser , & self . context ) ?;
430
438
let mut progress = ProgressBar :: new ( resources. len ( ) as u64 , self . progress_format ) ?;
431
439
let discovery = & mut self . discovery . clone ( ) ;
432
440
for resource in resources {
433
441
let evaluated_name = self . evaluate_resource_name ( & resource. name ) ?;
434
-
442
+
435
443
progress. set_resource ( & evaluated_name, & resource. resource_type ) ;
436
444
progress. write_activity ( format ! ( "Set '{evaluated_name}'" ) . as_str ( ) ) ;
437
445
if self . skip_resource ( & resource) ? {
@@ -580,14 +588,14 @@ impl Configurator {
580
588
/// This function will return an error if the underlying resource fails.
581
589
pub fn invoke_test ( & mut self ) -> Result < ConfigurationTestResult , DscError > {
582
590
self . unroll_copy_loops ( ) ?;
583
-
591
+
584
592
let mut result = ConfigurationTestResult :: new ( ) ;
585
593
let resources = get_resource_invocation_order ( & self . config , & mut self . statement_parser , & self . context ) ?;
586
594
let mut progress = ProgressBar :: new ( resources. len ( ) as u64 , self . progress_format ) ?;
587
595
let discovery = & mut self . discovery . clone ( ) ;
588
596
for resource in resources {
589
597
let evaluated_name = self . evaluate_resource_name ( & resource. name ) ?;
590
-
598
+
591
599
progress. set_resource ( & evaluated_name, & resource. resource_type ) ;
592
600
progress. write_activity ( format ! ( "Test '{evaluated_name}'" ) . as_str ( ) ) ;
593
601
if self . skip_resource ( & resource) ? {
@@ -658,7 +666,7 @@ impl Configurator {
658
666
/// This function will return an error if the underlying resource fails.
659
667
pub fn invoke_export ( & mut self ) -> Result < ConfigurationExportResult , DscError > {
660
668
self . unroll_copy_loops ( ) ?;
661
-
669
+
662
670
let mut result = ConfigurationExportResult :: new ( ) ;
663
671
let mut conf = config_doc:: Configuration :: new ( ) ;
664
672
conf. metadata . clone_from ( & self . config . metadata ) ;
@@ -668,7 +676,7 @@ impl Configurator {
668
676
let discovery = & mut self . discovery . clone ( ) ;
669
677
for resource in & resources {
670
678
let evaluated_name = self . evaluate_resource_name ( & resource. name ) ?;
671
-
679
+
672
680
progress. set_resource ( & evaluated_name, & resource. resource_type ) ;
673
681
progress. write_activity ( format ! ( "Export '{evaluated_name}'" ) . as_str ( ) ) ;
674
682
if self . skip_resource ( resource) ? {
@@ -916,7 +924,7 @@ impl Configurator {
916
924
fn unroll_copy_loops ( & mut self ) -> Result < ( ) , DscError > {
917
925
let mut config = self . config . clone ( ) ;
918
926
let config_copy = config. clone ( ) ;
919
-
927
+
920
928
for resource in config_copy. resources {
921
929
// if the resource contains `Copy`, unroll it
922
930
if let Some ( copy) = & resource. copy {
@@ -931,7 +939,7 @@ impl Configurator {
931
939
return Err ( DscError :: Parser ( t ! ( "configure.mod.copyNameResultNotString" ) . to_string ( ) ) )
932
940
} ;
933
941
new_resource. name = new_name. to_string ( ) ;
934
-
942
+
935
943
new_resource. copy = None ;
936
944
copy_resources. push ( new_resource) ;
937
945
}
@@ -941,7 +949,7 @@ impl Configurator {
941
949
config. resources . extend ( copy_resources) ;
942
950
}
943
951
}
944
-
952
+
945
953
self . config = config;
946
954
Ok ( ( ) )
947
955
}
@@ -967,12 +975,12 @@ impl Configurator {
967
975
if self . context . process_mode == ProcessMode :: Copy {
968
976
return Ok ( name. to_string ( ) ) ;
969
977
}
970
-
978
+
971
979
// evaluate the resource name (handles both expressions and literals)
972
980
let Value :: String ( evaluated_name) = self . statement_parser . parse_and_execute ( name, & self . context ) ? else {
973
981
return Err ( DscError :: Parser ( t ! ( "configure.mod.nameResultNotString" ) . to_string ( ) ) )
974
982
} ;
975
-
983
+
976
984
Ok ( evaluated_name)
977
985
}
978
986
0 commit comments