Skip to content

Commit 47fbba0

Browse files
committed
Address Manifest V2 review feedback
Signed-off-by: Lann Martin <[email protected]>
1 parent 15b8bfd commit 47fbba0

File tree

10 files changed

+99
-21
lines changed

10 files changed

+99
-21
lines changed

crates/loader/src/http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use anyhow::{ensure, Context, Result};
44
use sha2::Digest;
55
use tokio::io::AsyncWriteExt;
66

7-
/// Download content from `url` while will be verified to match `digest` and
7+
/// Downloads content from `url` which will be verified to match `digest` and
88
/// then moved to `dest`.
99
pub async fn verified_download(url: &str, digest: &str, dest: &Path) -> Result<()> {
1010
tracing::debug!("Downloading content from {url:?}");

crates/loader/src/local.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl LocalLoader {
124124
let source = self
125125
.load_component_source(component.source.clone())
126126
.await
127-
.with_context(|| format!("Failed to load Wasm source {:?}", component.source))?;
127+
.with_context(|| format!("Failed to load Wasm source {}", component.source))?;
128128

129129
let env = component.environment.into_iter().collect();
130130

crates/loader/tests/ui/invalid-digest.err

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ Failed to load Spin app from "<test-dir>/invalid-digest.toml"
22

33
Caused by:
44
0: Failed to load component `web`
5-
1: Failed to load Wasm source Remote { url: "https://example.com/wasm.wasm.wasm", digest: "not-a-digest" }
5+
1: Failed to load Wasm source "https://example.com/wasm.wasm.wasm" with digest "not-a-digest"
66
2: invalid `digest` "not-a-digest"; must start with 'sha256:'

crates/manifest/src/schema/common.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::fmt::Display;
2+
13
use serde::{Deserialize, Serialize};
24

35
/// Variable definition
@@ -30,7 +32,16 @@ pub enum ComponentSource {
3032
},
3133
}
3234

33-
/// Component source
35+
impl Display for ComponentSource {
36+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37+
match self {
38+
ComponentSource::Local(path) => write!(f, "{path:?}"),
39+
ComponentSource::Remote { url, digest } => write!(f, "{url:?} with digest {digest:?}"),
40+
}
41+
}
42+
}
43+
44+
/// WASI files mount
3445
#[derive(Clone, Debug, Serialize, Deserialize)]
3546
#[serde(deny_unknown_fields, untagged)]
3647
pub enum WasiFilesMount {

crates/oci/src/client.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ impl Client {
195195
for entry in WalkDir::new(source) {
196196
let entry = entry?;
197197
if entry.file_type().is_file() {
198+
// Can unwrap because we got to 'entry' from walking 'source'
198199
let rel_path = entry.path().strip_prefix(source).unwrap();
199200
tracing::trace!("Adding asset {rel_path:?} to component files list");
200201
// Add content/path to the locked component files list
@@ -234,6 +235,7 @@ impl Client {
234235
for entry in WalkDir::new(source) {
235236
let entry = entry?;
236237
if entry.file_type().is_file() {
238+
// Can unwrap because we got to 'entry' from walking 'source'
237239
let rel_path = entry.path().strip_prefix(source).unwrap();
238240
tracing::trace!("Adding new layer for asset {rel_path:?}");
239241
// Construct and push layer, adding its digest to the locked component files Vec
@@ -640,7 +642,7 @@ mod test {
640642
let metadata = Default::default();
641643
let variables = Default::default();
642644
let locked = LockedApp {
643-
spin_lock_version: spin_app::locked::FixedVersion,
645+
spin_lock_version: Default::default(),
644646
components,
645647
triggers,
646648
metadata,

crates/outbound-http/src/allowed_http_hosts.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ impl AllowedHttpHost {
7676

7777
// Parses a list of allowed HTTP hosts
7878
pub fn parse_allowed_http_hosts(list: &[impl AsRef<str>]) -> Result<AllowedHttpHosts> {
79-
if list.is_empty() {
80-
return Ok(AllowedHttpHosts::AllowSpecific(vec![]));
81-
}
8279
if list.iter().any(|domain| domain.as_ref() == ALLOW_ALL_HOSTS) {
8380
Ok(AllowedHttpHosts::AllowAll)
8481
} else {

crates/ui-testing/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl UiTestsRunner {
4040
let tests = std::mem::take(&mut self.tests);
4141
let conclusion = libtest_mimic::run(&args, tests);
4242
if conclusion.has_failed() {
43-
eprintln!("Snapshot files can be automatically updated by re-running with BLESS=1");
43+
eprintln!("Snapshot files can be automatically updated by re-running with BLESS=1\n");
4444
}
4545
conclusion.exit_if_failed();
4646
Ok(())

examples/spin-timer/Cargo.lock

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

src/commands/new.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,10 @@ impl FromStr for ParameterValue {
211211
/// This function reads a file and parses it as TOML, then
212212
/// returns the resulting hashmap of key-value pairs.
213213
async fn values_from_file(path: impl AsRef<Path>) -> Result<HashMap<String, String>> {
214-
// Get the absolute path of the file we're reading.
215214
let path = path.as_ref();
216215

217216
// Open the file.
218-
let text = tokio::fs::read_to_string(&path)
217+
let text = tokio::fs::read_to_string(path)
219218
.await
220219
.with_context(|| format!("Failed to read text from values file {}", path.display()))?;
221220

src/commands/up.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ impl Display for AppSource {
467467
AppSource::None => write!(f, "<no source>"),
468468
AppSource::File(path) => write!(f, "local app {path:?}"),
469469
AppSource::OciRegistry(reference) => write!(f, "remote app {reference:?}"),
470-
AppSource::Unresolvable(s) => write!(f, "unknown app source {s:?}"),
470+
AppSource::Unresolvable(s) => write!(f, "unknown app source: {s:?}"),
471471
}
472472
}
473473
}

0 commit comments

Comments
 (0)