@@ -66,22 +66,27 @@ pub fn add_resource_export_results_to_configuration(resource: &DscResource, conf
66
66
}
67
67
} else {
68
68
for ( i, instance) in export_result. actual_state . iter ( ) . enumerate ( ) {
69
- let mut r = config_doc:: Resource :: new ( ) ;
69
+ let mut r: Resource = config_doc:: Resource :: new ( ) ;
70
+ r. resource_type . clone_from ( & resource. type_name ) ;
70
71
let mut props: Map < String , Value > = serde_json:: from_value ( instance. clone ( ) ) ?;
71
72
if let Some ( kind) = props. remove ( "_kind" ) {
73
+ if !kind. is_string ( ) {
74
+ return Err ( DscError :: Parser ( t ! ( "configure.mod.propertyNotString" , name = "_kind" , value = kind) . to_string ( ) ) ) ;
75
+ }
72
76
r. kind = kind. as_str ( ) . map ( std:: string:: ToString :: to_string) ;
73
77
}
74
78
if let Some ( security_context) = props. remove ( "_securityContext" ) {
75
- r. security_context = security_context. as_str ( ) . map ( std:: string:: ToString :: to_string) ;
79
+ let mut metadata = Map :: new ( ) ;
80
+ metadata. insert ( "securityContext" . to_string ( ) , security_context. clone ( ) ) ;
81
+ r. metadata = Some ( metadata) ;
76
82
}
77
83
r. name = if let Some ( name) = props. remove ( "_name" ) {
78
84
name. as_str ( )
79
85
. map ( std:: string:: ToString :: to_string)
80
- . ok_or_else ( || DscError :: Parser ( t ! ( "configure.mod.valueCouldNotBeTransformedAsString " , value = name) . to_string ( ) ) ) ?
86
+ . ok_or_else ( || DscError :: Parser ( t ! ( "configure.mod.propertyNotString" , name = "_name ", value = name) . to_string ( ) ) ) ?
81
87
} else {
82
- format ! ( "{}-{}" , r. resource_type, i )
88
+ format ! ( "{}-{i }" , r. resource_type)
83
89
} ;
84
- r. resource_type . clone_from ( & resource. type_name ) ;
85
90
r. properties = escape_property_values ( & props) ?;
86
91
87
92
conf. resources . push ( r) ;
0 commit comments