@@ -8,19 +8,23 @@ pub use loader::ResolutionContext;
88use loader:: { load_and_resolve_all, ComponentToValidate } ;
99
1010pub async fn validate_application_against_environment_ids (
11- env_ids : impl Iterator < Item = & str > ,
11+ env_ids : & [ impl AsRef < str > ] ,
1212 app : & spin_manifest:: schema:: v2:: AppManifest ,
1313 resolution_context : & ResolutionContext ,
14- ) -> anyhow:: Result < ( ) > {
15- let envs = join_all_result ( env_ids. map ( load_environment) ) . await ?;
14+ ) -> anyhow:: Result < Vec < anyhow:: Error > > {
15+ if env_ids. is_empty ( ) {
16+ return Ok ( Default :: default ( ) ) ;
17+ }
18+
19+ let envs = join_all_result ( env_ids. iter ( ) . map ( load_environment) ) . await ?;
1620 validate_application_against_environments ( & envs, app, resolution_context) . await
1721}
1822
1923async fn validate_application_against_environments (
2024 envs : & [ TargetEnvironment ] ,
2125 app : & spin_manifest:: schema:: v2:: AppManifest ,
2226 resolution_context : & ResolutionContext ,
23- ) -> anyhow:: Result < ( ) > {
27+ ) -> anyhow:: Result < Vec < anyhow :: Error > > {
2428 use futures:: FutureExt ;
2529
2630 for trigger_type in app. triggers . keys ( ) {
@@ -40,31 +44,45 @@ async fn validate_application_against_environments(
4044 . await
4145 . context ( "Failed to prepare components for target environment checking" ) ?;
4246
47+ let mut errs = vec ! [ ] ;
48+
4349 for ( trigger_type, component) in components_by_trigger_type {
4450 for component in & component {
45- validate_component_against_environments ( envs, & trigger_type, component) . await ?;
51+ errs. extend (
52+ validate_component_against_environments ( envs, & trigger_type, component) . await ?,
53+ ) ;
4654 }
4755 }
4856
49- Ok ( ( ) )
57+ Ok ( errs )
5058}
5159
5260async fn validate_component_against_environments (
5361 envs : & [ TargetEnvironment ] ,
5462 trigger_type : & TriggerType ,
5563 component : & ComponentToValidate < ' _ > ,
56- ) -> anyhow:: Result < ( ) > {
64+ ) -> anyhow:: Result < Vec < anyhow:: Error > > {
65+ let mut errs = vec ! [ ] ;
66+
5767 for env in envs {
5868 let worlds = env. worlds ( trigger_type) ;
59- validate_wasm_against_any_world ( env, & worlds, component) . await ?;
69+ if let Some ( e) = validate_wasm_against_any_world ( env, & worlds, component)
70+ . await
71+ . err ( )
72+ {
73+ errs. push ( e) ;
74+ }
6075 }
6176
62- tracing:: info!(
63- "Validated component {} {} against all target worlds" ,
64- component. id( ) ,
65- component. source_description( )
66- ) ;
67- Ok ( ( ) )
77+ if errs. is_empty ( ) {
78+ tracing:: info!(
79+ "Validated component {} {} against all target worlds" ,
80+ component. id( ) ,
81+ component. source_description( )
82+ ) ;
83+ }
84+
85+ Ok ( errs)
6886}
6987
7088async fn validate_wasm_against_any_world (
0 commit comments