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