Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ wasmtime = "25.0.3"
wasmtime-wasi = "25.0.0"
wasmtime-wasi-http = "25.0.0"

wasm-encoder = "0.217"
wasm-metadata = "0.217"
wasmparser = "0.217"
wit-component = "0.217"
wit-parser = "0.217"

spin-componentize = { path = "crates/componentize" }

[workspace.lints.clippy]
Expand Down
10 changes: 5 additions & 5 deletions crates/componentize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ rust-version.workspace = true
[dependencies]
anyhow = { workspace = true }
tracing = { workspace = true }
wasm-encoder = "0.217"
wasm-metadata = "0.217"
wasmparser = "0.217"
wit-component = "0.217"
wit-parser = "0.217"
wasm-encoder = { workspace = true }
wasm-metadata = { workspace = true }
wasmparser = { workspace = true }
wit-component = { workspace = true }
wit-parser = { workspace = true }

[dev-dependencies]
async-trait = { workspace = true }
Expand Down
3 changes: 3 additions & 0 deletions crates/compose/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ async-trait = { workspace = true }
indexmap = "2"
semver = "1"
spin-app = { path = "../app" }
spin-common = { path = "../common" }
spin-componentize = { path = "../componentize" }
spin-serde = { path = "../serde" }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["fs"] }
wac-graph = "0.6"

[lints]
Expand Down
31 changes: 31 additions & 0 deletions crates/compose/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use anyhow::Context;
use indexmap::IndexMap;
use semver::Version;
use spin_app::locked::{self, InheritConfiguration, LockedComponent, LockedComponentDependency};
use spin_common::{ui::quoted_path, url::parse_file_url};
use spin_serde::{DependencyName, KebabId};
use std::collections::BTreeMap;
use thiserror::Error;
Expand Down Expand Up @@ -42,6 +43,36 @@ pub trait ComponentSourceLoader {
) -> anyhow::Result<Vec<u8>>;
}

/// A ComponentSourceLoader that loads component sources from the filesystem.
pub struct ComponentSourceLoaderFs;

#[async_trait::async_trait]
impl ComponentSourceLoader for ComponentSourceLoaderFs {
async fn load_component_source(
&self,
source: &locked::LockedComponentSource,
) -> anyhow::Result<Vec<u8>> {
let source = source
.content
.source
.as_ref()
.context("LockedComponentSource missing source field")?;

let path = parse_file_url(source)?;

let bytes: Vec<u8> = tokio::fs::read(&path).await.with_context(|| {
format!(
"failed to read component source from disk at path {}",
quoted_path(&path)
)
})?;

let component = spin_componentize::componentize_if_necessary(&bytes)?;

Ok(component.into())
}
}

/// Represents an error that can occur when composing dependencies.
#[derive(Debug, Error)]
pub enum ComposeError {
Expand Down
6 changes: 6 additions & 0 deletions crates/oci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ reqwest = "0.12"
serde = { workspace = true }
serde_json = { workspace = true }
spin-common = { path = "../common" }
spin-compose = { path = "../compose" }
spin-loader = { path = "../loader" }
spin-locked-app = { path = "../locked-app" }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["fs"] }
tokio-util = { version = "0.7", features = ["compat"] }
tracing = { workspace = true }
walkdir = "2"

[dev-dependencies]
wasm-encoder = { workspace = true }
wit-component = { workspace = true, features = ["dummy-module"] }
wit-parser = { workspace = true }
Loading
Loading