mirror of
https://github.com/mii443/wasmer.git
synced 2025-09-04 00:19:24 +00:00
Switched load_package_tree's over to using the filesystem annotations
This commit is contained in:
@ -188,7 +188,7 @@ pub struct PackageInfo {
|
||||
impl PackageInfo {
|
||||
pub fn from_manifest(manifest: &Manifest) -> Result<Self, Error> {
|
||||
let WapmAnnotations { name, version, .. } = manifest
|
||||
.package_annotation("wapm")?
|
||||
.wapm()?
|
||||
.context("Unable to find the \"wapm\" annotations")?;
|
||||
|
||||
let dependencies = manifest
|
||||
@ -210,7 +210,7 @@ impl PackageInfo {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let filesystem = filesystem_mapping_from_manifest(manifest);
|
||||
let filesystem = filesystem_mapping_from_manifest(manifest)?;
|
||||
|
||||
Ok(PackageInfo {
|
||||
name,
|
||||
@ -230,15 +230,40 @@ impl PackageInfo {
|
||||
}
|
||||
}
|
||||
|
||||
fn filesystem_mapping_from_manifest(_manifest: &Manifest) -> Vec<FileSystemMapping> {
|
||||
// FIXME(Michael-F-Bryan): wapm2pirita never added filesystem mappings to the manifest
|
||||
// That means we need to
|
||||
// - Figure out whether filesystem mappings belong to the whole package or
|
||||
// if each command has their own set of mappings
|
||||
// - Update wapm-targz-to-pirita to copy the [fs] table across
|
||||
// - Re-generate all packages on WAPM
|
||||
// - Update this function to copy metadata into our internal datastructures
|
||||
Vec::new()
|
||||
fn filesystem_mapping_from_manifest(
|
||||
manifest: &Manifest,
|
||||
) -> Result<Vec<FileSystemMapping>, serde_cbor::Error> {
|
||||
match manifest.filesystem()? {
|
||||
Some(webc::metadata::annotations::FileSystemMappings(mappings)) => {
|
||||
let mappings = mappings
|
||||
.into_iter()
|
||||
.map(|mapping| FileSystemMapping {
|
||||
volume_name: mapping.volume_name,
|
||||
mount_path: mapping.mount_path,
|
||||
dependency_name: mapping.from,
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(mappings)
|
||||
}
|
||||
None => {
|
||||
// A "fs" annotation hasn't been attached to this package. This was
|
||||
// the case when *.webc files were generated by wapm2pirita version
|
||||
// 1.0.29 and earlier.
|
||||
//
|
||||
// To maintain compatibility with those older packages, we'll say
|
||||
// that the "atom" volume from the current package is mounted to "/"
|
||||
// and contains all files in the package.
|
||||
tracing::debug!(
|
||||
"No \"fs\" package annotations found. Mounting the \"atom\" volume to \"/\" for compatibility."
|
||||
);
|
||||
Ok(vec![FileSystemMapping {
|
||||
volume_name: "atom".to_string(),
|
||||
mount_path: "/".to_string(),
|
||||
dependency_name: None,
|
||||
}])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
Reference in New Issue
Block a user