Skip to content

Commit 9f772ec

Browse files
authored
Merge pull request #1906 from itowlson/free-the-locked-app-one-again
Decouple LockedApp schema from `spin-core`
2 parents 61c36a1 + 190c4b3 commit 9f772ec

File tree

16 files changed

+115
-42
lines changed

16 files changed

+115
-42
lines changed

Cargo.lock

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ spin-doctor = { path = "crates/doctor" }
5454
spin-http = { path = "crates/http" }
5555
spin-trigger-http = { path = "crates/trigger-http" }
5656
spin-loader = { path = "crates/loader" }
57+
spin-locked-app = { path = "crates/locked-app" }
5758
spin-manifest = { path = "crates/manifest" }
5859
spin-oci = { path = "crates/oci" }
5960
spin-plugins = { path = "crates/plugins" }

crates/app/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ ouroboros = "0.18.0"
1111
serde = { version = "1.0", features = ["derive"] }
1212
serde_json = "1.0"
1313
spin-core = { path = "../core" }
14+
spin-locked-app = { path = "../locked-app" }
1415
spin-serde = { path = "../serde" }
1516
thiserror = "1.0"

crates/app/src/lib.rs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@
77
#![deny(missing_docs)]
88

99
mod host_component;
10-
pub mod locked;
11-
mod metadata;
12-
pub mod values;
10+
pub use spin_locked_app::locked;
11+
pub use spin_locked_app::values;
12+
pub use spin_locked_app::{Error, MetadataKey, Result};
1313

1414
use ouroboros::self_referencing;
1515
use serde::Deserialize;
1616
use spin_core::{wasmtime, Engine, EngineBuilder, HostComponentDataHandle, StoreBuilder};
1717

1818
use host_component::DynamicHostComponents;
1919
use locked::{ContentPath, LockedApp, LockedComponent, LockedComponentSource, LockedTrigger};
20-
use metadata::MetadataExt;
20+
use spin_locked_app::MetadataExt;
2121

2222
pub use async_trait::async_trait;
2323
pub use host_component::DynamicHostComponent;
2424
pub use locked::Variable;
25-
pub use metadata::MetadataKey;
2625

2726
/// MetadataKey for extracting the application name.
2827
pub const APP_NAME_KEY: MetadataKey = MetadataKey::new("name");
@@ -397,29 +396,3 @@ impl<'a, L: MaybeLoader> AppTrigger<'a, L> {
397396
struct CommonTriggerConfig {
398397
component: Option<String>,
399398
}
400-
401-
/// Type alias for a [`Result`]s with [`Error`].
402-
pub type Result<T> = std::result::Result<T, Error>;
403-
404-
/// Errors returned by methods in this crate.
405-
#[derive(Debug, thiserror::Error)]
406-
pub enum Error {
407-
/// An error propagated from the [`spin_core`] crate.
408-
#[error("spin core error: {0:#}")]
409-
CoreError(#[source] anyhow::Error),
410-
/// An error from a [`DynamicHostComponent`].
411-
#[error("host component error: {0:#}")]
412-
HostComponentError(#[source] anyhow::Error),
413-
/// An error from a [`Loader`] implementation.
414-
#[error(transparent)]
415-
LoaderError(anyhow::Error),
416-
/// An error indicating missing or unexpected metadata.
417-
#[error("metadata error: {0}")]
418-
MetadataError(String),
419-
/// An error indicating failed JSON (de)serialization.
420-
#[error("json error: {0}")]
421-
JsonError(#[from] serde_json::Error),
422-
/// A validation error that can be presented directly to the user.
423-
#[error(transparent)]
424-
ValidationError(anyhow::Error),
425-
}

crates/loader/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ serde = { version = "1.0", features = ["derive"] }
2424
serde_json = "1.0"
2525
sha2 = "0.10.8"
2626
shellexpand = "3.1"
27-
spin-app = { path = "../app" }
27+
spin-locked-app = { path = "../locked-app" }
2828
spin-common = { path = "../common" }
2929
spin-config = { path = "../config" }
3030
spin-manifest = { path = "../manifest" }

crates/loader/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use std::path::{Path, PathBuf};
1414

1515
use anyhow::Result;
1616
use local::LocalLoader;
17-
use spin_app::locked::LockedApp;
1817
use spin_common::paths::parent_dir;
18+
use spin_locked_app::locked::LockedApp;
1919

2020
pub mod cache;
2121
mod http;

crates/loader/src/local.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ use std::path::{Path, PathBuf};
33
use anyhow::{bail, ensure, Context, Result};
44
use futures::future::try_join_all;
55
use reqwest::Url;
6-
use spin_app::{
6+
use spin_common::paths::parent_dir;
7+
use spin_locked_app::{
78
locked::{
89
self, ContentPath, ContentRef, LockedApp, LockedComponent, LockedComponentSource,
910
LockedTrigger,
1011
},
1112
values::{ValuesMap, ValuesMapBuilder},
1213
};
13-
use spin_common::paths::parent_dir;
1414
use spin_manifest::schema::v2::{self, AppManifest, KebabId, WasiFilesMount};
1515
use tokio::{fs, sync::Semaphore};
1616

crates/locked-app/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "spin-locked-app"
3+
version = { workspace = true }
4+
authors = { workspace = true }
5+
edition = { workspace = true }
6+
7+
[dependencies]
8+
anyhow = "1.0"
9+
async-trait = "0.1"
10+
ouroboros = "0.18.0"
11+
serde = { version = "1.0", features = ["derive"] }
12+
serde_json = "1.0"
13+
spin-serde = { path = "../serde" }
14+
thiserror = "1.0"

crates/locked-app/src/lib.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//! Spin internal application interfaces
2+
//!
3+
//! This crate contains interfaces to Spin application configuration to be used
4+
//! by crates that implement Spin execution environments: trigger executors and
5+
//! host components, in particular.
6+
7+
#![deny(missing_docs)]
8+
9+
pub mod locked;
10+
mod metadata;
11+
pub mod values;
12+
13+
pub use async_trait::async_trait;
14+
pub use locked::Variable;
15+
pub use metadata::{MetadataExt, MetadataKey};
16+
17+
/// MetadataKey for extracting the application name.
18+
pub const APP_NAME_KEY: MetadataKey = MetadataKey::new("name");
19+
/// MetadataKey for extracting the application version.
20+
pub const APP_VERSION_KEY: MetadataKey = MetadataKey::new("version");
21+
/// MetadataKey for extracting the application description.
22+
pub const APP_DESCRIPTION_KEY: MetadataKey = MetadataKey::new("description");
23+
/// MetadataKey for extracting the OCI image digest.
24+
pub const OCI_IMAGE_DIGEST_KEY: MetadataKey = MetadataKey::new("oci_image_digest");
25+
26+
/// Type alias for a [`Result`]s with [`Error`].
27+
pub type Result<T> = std::result::Result<T, Error>;
28+
29+
/// Errors returned by methods in this crate.
30+
#[derive(Debug, thiserror::Error)]
31+
pub enum Error {
32+
/// An error propagated from the [`spin_core`] crate.
33+
#[error(transparent)]
34+
CoreError(anyhow::Error),
35+
/// An error from a [`DynamicHostComponent`].
36+
#[error("host component error: {0:#}")]
37+
HostComponentError(#[source] anyhow::Error),
38+
/// An error from a [`Loader`] implementation.
39+
#[error(transparent)]
40+
LoaderError(anyhow::Error),
41+
/// An error indicating missing or unexpected metadata.
42+
#[error("metadata error: {0}")]
43+
MetadataError(String),
44+
/// An error indicating failed JSON (de)serialization.
45+
#[error("json error: {0}")]
46+
JsonError(#[from] serde_json::Error),
47+
/// A validation error that can be presented directly to the user.
48+
#[error(transparent)]
49+
ValidationError(anyhow::Error),
50+
}
File renamed without changes.

0 commit comments

Comments
 (0)