Skip to content

Commit f4dcf5d

Browse files
committed
Upgrade everything else to manifest V2
Signed-off-by: Lann Martin <[email protected]>
1 parent dd58cb9 commit f4dcf5d

File tree

29 files changed

+350
-276
lines changed

29 files changed

+350
-276
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ authors = ["Fermyon Engineering <[email protected]>"]
1212
edition = "2021"
1313

1414
[dependencies]
15-
anyhow = "1.0"
15+
anyhow = { workspace = true }
1616
async-trait = "0.1"
1717
bytes = "1.1"
1818
chrono = "0.4"
@@ -78,6 +78,7 @@ subprocess = "0.2.9"
7878
openssl = { version = "0.10" }
7979

8080
[dev-dependencies]
81+
anyhow = { workspace = true, features = ["backtrace"] }
8182
hex = "0.4.3"
8283
hyper = { workspace = true }
8384
sha2 = "0.10.1"
@@ -107,6 +108,7 @@ llm-cublas = ["llm", "spin-trigger-http/llm-cublas"]
107108
members = ["crates/*", "sdk/rust", "sdk/rust/macro"]
108109

109110
[workspace.dependencies]
111+
anyhow = "1.0.75"
110112
tracing = { version = "0.1", features = ["log"] }
111113
wasmtime-wasi = { git = "https://github.com/bytecodealliance/wasmtime", rev = "c796ce7376a57a40605f03e74bd78cefcc9acf3a", features = [
112114
"tokio",

crates/app/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub use metadata::MetadataKey;
2828
pub const APP_NAME_KEY: MetadataKey = MetadataKey::new("name");
2929
/// MetadataKey for extracting the application version.
3030
pub const APP_VERSION_KEY: MetadataKey = MetadataKey::new("version");
31+
/// MetadataKey for extracting the application description.
32+
pub const APP_DESCRIPTION_KEY: MetadataKey = MetadataKey::new("description");
3133
/// MetadataKey for extracting the OCI image digest.
3234
pub const OCI_IMAGE_DIGEST_KEY: MetadataKey = MetadataKey::new("oci_image_digest");
3335

crates/app/src/locked.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,6 @@ impl<const V: usize> From<FixedVersion<V>> for usize {
161161
}
162162
}
163163

164-
impl<const V: usize> From<FixedVersion<V>> for String {
165-
fn from(_: FixedVersion<V>) -> String {
166-
V.to_string()
167-
}
168-
}
169-
170164
impl<const V: usize> TryFrom<usize> for FixedVersion<V> {
171165
type Error = String;
172166

@@ -178,17 +172,6 @@ impl<const V: usize> TryFrom<usize> for FixedVersion<V> {
178172
}
179173
}
180174

181-
impl<const V: usize> TryFrom<String> for FixedVersion<V> {
182-
type Error = String;
183-
184-
fn try_from(value: String) -> Result<Self, Self::Error> {
185-
let value: usize = value
186-
.parse()
187-
.map_err(|err| format!("invalid version: {}", err))?;
188-
value.try_into()
189-
}
190-
}
191-
192175
mod serde_base64 {
193176
use std::borrow::Cow;
194177

crates/app/src/values.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,21 @@ impl ValuesMapBuilder {
1616
Self::default()
1717
}
1818

19+
/// Returns a ValuesMapBuilder populated from the given map-serializable
20+
/// value.
21+
pub fn try_from<S: Serialize>(s: S) -> serde_json::Result<Self> {
22+
let value = serde_json::to_value(s)?;
23+
let map = serde_json::from_value(value)?;
24+
Ok(Self(map))
25+
}
26+
1927
/// Inserts a string value into the map.
2028
pub fn string(&mut self, key: impl Into<String>, value: impl Into<String>) -> &mut Self {
21-
self.entry(key, value.into())
29+
let value = value.into();
30+
if value.is_empty() {
31+
return self;
32+
}
33+
self.entry(key, value)
2234
}
2335

2436
/// Inserts a string value into the map only if the given Option is Some.
@@ -39,7 +51,11 @@ impl ValuesMapBuilder {
3951
key: impl Into<String>,
4052
iter: impl IntoIterator<Item = T>,
4153
) -> &mut Self {
42-
self.entry(key, iter.into_iter().map(|s| s.into()).collect::<Vec<_>>())
54+
let entries = iter.into_iter().map(|s| s.into()).collect::<Vec<_>>();
55+
if entries.is_empty() {
56+
return self;
57+
}
58+
self.entry(key, entries)
4359
}
4460

4561
/// Inserts an entry into the map using the value's `impl Into<Value>`.
@@ -55,7 +71,9 @@ impl ValuesMapBuilder {
5571
value: impl Serialize,
5672
) -> serde_json::Result<&mut Self> {
5773
let value = serde_json::to_value(value)?;
58-
self.0.insert(key.into(), value);
74+
if !value.is_null() {
75+
self.0.insert(key.into(), value);
76+
}
5977
Ok(self)
6078
}
6179

crates/build/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ edition = { workspace = true }
88
anyhow = "1.0.57"
99
futures = "0.3.21"
1010
serde = { version = "1.0", features = [ "derive" ] }
11-
spin-loader = { path = "../loader" }
11+
spin-common = { path = "../common" }
12+
spin-manifest = { path = "../manifest" }
1213
terminal = { path = "../terminal" }
1314
subprocess = "0.2.8"
1415
tokio = { version = "1.23", features = [ "full" ] }

crates/build/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
mod manifest;
66

77
use anyhow::{anyhow, bail, Context, Result};
8-
use spin_loader::local::parent_dir;
8+
use spin_common::paths::parent_dir;
99
use std::{
1010
collections::HashSet,
1111
path::{Path, PathBuf},

crates/build/src/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use serde::{Deserialize, Serialize};
2-
use spin_loader::local::config::FixedStringVersion;
2+
use spin_manifest::schema::FixedStringVersion;
33
use std::path::PathBuf;
44

55
#[derive(Clone, Debug, Deserialize)]

crates/common/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@ edition = { workspace = true }
88
anyhow = "1.0"
99
dirs = "4.0"
1010
sha2 = "0.10"
11-
tokio = { version = "1", features = ["rt", "time"] }
12-
13-
[dev-dependencies]
14-
tempfile = "3.5"
11+
tempfile = "3.5"
12+
tokio = { version = "1", features = ["rt", "time"] }

0 commit comments

Comments
 (0)