@@ -753,6 +753,11 @@ impl Configurator {
753753 Ok ( false )
754754 }
755755
756+ /// Process the outputs defined in the configuration.
757+ ///
758+ /// # Errors
759+ ///
760+ /// This function will return an error if the output processing fails.
756761 pub fn process_output ( & mut self ) -> Result < ( ) , DscError > {
757762 if self . config . outputs . is_none ( ) || self . context . execution_type == ExecutionKind :: WhatIf {
758763 return Ok ( ( ) ) ;
@@ -767,26 +772,22 @@ impl Configurator {
767772 }
768773 }
769774
770- match & output. value_or_copy {
771- ValueOrCopy :: Value ( value) => {
772- let value_result = self . statement_parser . parse_and_execute ( & value, & self . context ) ?;
773- if output. r#type == DataType :: SecureString || output. r#type == DataType :: SecureObject {
774- warn ! ( "{}" , t!( "configure.mod.secureOutputSkipped" , name = name) ) ;
775- continue ;
776- }
777- if value_result. is_string ( ) && output. r#type != DataType :: String ||
778- value_result. is_i64 ( ) && output. r#type != DataType :: Int ||
779- value_result. is_boolean ( ) && output. r#type != DataType :: Bool ||
780- value_result. is_array ( ) && output. r#type != DataType :: Array ||
781- value_result. is_object ( ) && output. r#type != DataType :: Object {
782- return Err ( DscError :: Validation ( t ! ( "configure.mod.outputTypeNotMatch" , name = name, expected_type = output. r#type) . to_string ( ) ) ) ;
783- }
784- self . context . outputs . insert ( name. clone ( ) , value_result) ;
785- } ,
786- _ => {
787- warn ! ( "{}" , t!( "configure.mod.copyNotSupported" , name = name) ) ;
775+ if let ValueOrCopy :: Value ( value) = & output. value_or_copy {
776+ let value_result = self . statement_parser . parse_and_execute ( value, & self . context ) ?;
777+ if output. r#type == DataType :: SecureString || output. r#type == DataType :: SecureObject {
778+ warn ! ( "{}" , t!( "configure.mod.secureOutputSkipped" , name = name) ) ;
788779 continue ;
789780 }
781+ if value_result. is_string ( ) && output. r#type != DataType :: String ||
782+ value_result. is_i64 ( ) && output. r#type != DataType :: Int ||
783+ value_result. is_boolean ( ) && output. r#type != DataType :: Bool ||
784+ value_result. is_array ( ) && output. r#type != DataType :: Array ||
785+ value_result. is_object ( ) && output. r#type != DataType :: Object {
786+ return Err ( DscError :: Validation ( t ! ( "configure.mod.outputTypeNotMatch" , name = name, expected_type = output. r#type) . to_string ( ) ) ) ;
787+ }
788+ self . context . outputs . insert ( name. clone ( ) , value_result) ;
789+ } else {
790+ warn ! ( "{}" , t!( "configure.mod.copyNotSupported" , name = name) ) ;
790791 }
791792 }
792793 }
0 commit comments