@@ -19,7 +19,7 @@ use crate::manifest::component_build_configs;
19
19
pub async fn build (
20
20
manifest_file : & Path ,
21
21
component_ids : & [ String ] ,
22
- skip_target_checks : bool ,
22
+ target_checks : TargetChecking ,
23
23
cache_root : Option < PathBuf > ,
24
24
) -> Result < ( ) > {
25
25
let build_info = component_build_configs ( manifest_file)
@@ -42,7 +42,7 @@ pub async fn build(
42
42
// Checking deployment targets requires a healthy manifest (because trigger types etc.),
43
43
// if any of these were specified, warn they are being skipped.
44
44
let should_have_checked_targets =
45
- !skip_target_checks && build_info. has_deployment_targets ( ) ;
45
+ target_checks . check ( ) && build_info. has_deployment_targets ( ) ;
46
46
if should_have_checked_targets {
47
47
terminal:: warn!(
48
48
"The manifest error(s) prevented Spin from checking the deployment targets."
@@ -59,7 +59,7 @@ pub async fn build(
59
59
return Ok ( ( ) ) ;
60
60
} ;
61
61
62
- if !skip_target_checks {
62
+ if target_checks . check ( ) {
63
63
let application = spin_environments:: ApplicationToValidate :: new (
64
64
manifest. clone ( ) ,
65
65
manifest_file. parent ( ) . unwrap ( ) ,
@@ -207,6 +207,21 @@ fn construct_workdir(app_dir: &Path, workdir: Option<impl AsRef<Path>>) -> Resul
207
207
Ok ( cwd)
208
208
}
209
209
210
+ /// Specifies target environment checking behaviour
211
+ pub enum TargetChecking {
212
+ /// The build should check that all components are compatible with all target environments.
213
+ Check ,
214
+ /// The build should not check target environments.
215
+ Skip ,
216
+ }
217
+
218
+ impl TargetChecking {
219
+ /// Should the build check target environments?
220
+ fn check ( & self ) -> bool {
221
+ matches ! ( self , Self :: Check )
222
+ }
223
+ }
224
+
210
225
#[ cfg( test) ]
211
226
mod tests {
212
227
use super :: * ;
@@ -219,6 +234,8 @@ mod tests {
219
234
#[ tokio:: test]
220
235
async fn can_load_even_if_trigger_invalid ( ) {
221
236
let bad_trigger_file = test_data_root ( ) . join ( "bad_trigger.toml" ) ;
222
- build ( & bad_trigger_file, & [ ] , true , None ) . await . unwrap ( ) ;
237
+ build ( & bad_trigger_file, & [ ] , TargetChecking :: Skip , None )
238
+ . await
239
+ . unwrap ( ) ;
223
240
}
224
241
}
0 commit comments