Skip to content

Commit 574001c

Browse files
Merge pull request #213 from kate-goldenring/remove-retain-module
cleanup: use component filtering utils from Spin crates
2 parents dcd9a3b + a22b851 commit 574001c

File tree

4 files changed

+17
-250
lines changed

4 files changed

+17
-250
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
88

99
### Changed
1010

11+
- Use component filtering utils from Spin crate, removing redundant `retain` module ([#213](https://github.com/spinkube/containerd-shim-spin/pull/213))
1112
- Bump Spin dependencies to v3.1.2 ([#263](https://github.com/spinkube/containerd-shim-spin/pull/263))
1213
- Updated the minimum required Rust version to 1.81
1314

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)