Skip to content

Commit 6a876be

Browse files
cleanup: use component filtering utils from Spin crates
Signed-off-by: Kate Goldenring <[email protected]>
1 parent dcd9a3b commit 6a876be

File tree

3 files changed

+16
-250
lines changed

3 files changed

+16
-250
lines changed

containerd-shim-spin/src/engine.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use containerd_shim_wasm::{
1313
use futures::future;
1414
use log::info;
1515
use spin_app::locked::LockedApp;
16+
use spin_factor_outbound_networking::validate_service_chaining_for_components;
1617
use spin_trigger::cli::NoCliArgs;
1718
use spin_trigger_http::HttpTrigger;
1819
use spin_trigger_redis::RedisTrigger;
@@ -156,14 +157,21 @@ impl SpinEngine {
156157
let cache = initialize_cache().await?;
157158
let app_source = Source::from_ctx(ctx, &cache).await?;
158159
let mut locked_app = app_source.to_locked_app(&cache).await?;
159-
let components_to_execute = env::var(constants::SPIN_COMPONENTS_TO_RETAIN_ENV)
160-
.ok()
161-
.map(|s| s.split(',').map(|s| s.to_string()).collect::<Vec<String>>());
162-
if let Some(components) = components_to_execute {
163-
if let Err(e) = crate::retain::retain_components(&mut locked_app, &components) {
164-
println!("Error with selective deployment: {:?}", e);
165-
return Err(e);
166-
}
160+
if let Ok(components_env) = env::var(constants::SPIN_COMPONENTS_TO_RETAIN_ENV) {
161+
let components = components_env
162+
.split(',')
163+
.filter(|s| !s.is_empty())
164+
.collect::<Vec<&str>>();
165+
locked_app = spin_app::retain_components(
166+
locked_app,
167+
&components,
168+
&[&validate_service_chaining_for_components],
169+
)
170+
.with_context(|| {
171+
format!(
172+
"failed to resolve application with only [{components:?}] components retained by configured environment variable {}", constants::SPIN_COMPONENTS_TO_RETAIN_ENV
173+
)
174+
})?;
167175
}
168176
configure_application_variables_from_environment_variables(&locked_app)?;
169177
let trigger_cmds = get_supported_triggers(&locked_app)

containerd-shim-spin/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use containerd_shim_wasm::{
66

77
mod constants;
88
mod engine;
9-
mod retain;
109
mod source;
1110
mod trigger;
1211
mod utils;

containerd-shim-spin/src/retain.rs

Lines changed: 0 additions & 241 deletions
This file was deleted.

0 commit comments

Comments
 (0)