Skip to content

Commit

Permalink
cleanup: use component filtering utils from Spin crates
Browse files Browse the repository at this point in the history
Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
  • Loading branch information
kate-goldenring committed Jan 16, 2025
1 parent dcd9a3b commit 6a876be
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 250 deletions.
24 changes: 16 additions & 8 deletions containerd-shim-spin/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use containerd_shim_wasm::{
use futures::future;
use log::info;
use spin_app::locked::LockedApp;
use spin_factor_outbound_networking::validate_service_chaining_for_components;
use spin_trigger::cli::NoCliArgs;
use spin_trigger_http::HttpTrigger;
use spin_trigger_redis::RedisTrigger;
Expand Down Expand Up @@ -156,14 +157,21 @@ impl SpinEngine {
let cache = initialize_cache().await?;
let app_source = Source::from_ctx(ctx, &cache).await?;
let mut locked_app = app_source.to_locked_app(&cache).await?;
let components_to_execute = env::var(constants::SPIN_COMPONENTS_TO_RETAIN_ENV)
.ok()
.map(|s| s.split(',').map(|s| s.to_string()).collect::<Vec<String>>());
if let Some(components) = components_to_execute {
if let Err(e) = crate::retain::retain_components(&mut locked_app, &components) {
println!("Error with selective deployment: {:?}", e);
return Err(e);
}
if let Ok(components_env) = env::var(constants::SPIN_COMPONENTS_TO_RETAIN_ENV) {
let components = components_env
.split(',')
.filter(|s| !s.is_empty())
.collect::<Vec<&str>>();
locked_app = spin_app::retain_components(
locked_app,
&components,
&[&validate_service_chaining_for_components],
)
.with_context(|| {
format!(
"failed to resolve application with only [{components:?}] components retained by configured environment variable {}", constants::SPIN_COMPONENTS_TO_RETAIN_ENV
)
})?;
}
configure_application_variables_from_environment_variables(&locked_app)?;
let trigger_cmds = get_supported_triggers(&locked_app)
Expand Down
1 change: 0 additions & 1 deletion containerd-shim-spin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use containerd_shim_wasm::{

mod constants;
mod engine;
mod retain;
mod source;
mod trigger;
mod utils;
Expand Down
241 changes: 0 additions & 241 deletions containerd-shim-spin/src/retain.rs

This file was deleted.

0 comments on commit 6a876be

Please sign in to comment.