mirror of
https://github.com/fluencelabs/marine.git
synced 2024-12-12 06:45:32 +00:00
Support build time in module manifests (#71)
This commit is contained in:
parent
6d4ef8200b
commit
2aa3caee83
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -711,6 +711,7 @@ name = "fce-module-info-parser"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
"fluence-sdk-main 0.5.0",
|
||||
"semver 0.11.0",
|
||||
"serde",
|
||||
@ -1148,7 +1149,7 @@ checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"wasi 0.10.2+wasi-snapshot-preview1",
|
||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2715,11 +2716,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.43"
|
||||
version = "0.1.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
|
||||
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
@ -3096,9 +3098,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
version = "0.10.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
|
@ -16,6 +16,7 @@ fluence-sdk-main = "0.5.0"
|
||||
wasmer-core = { package = "wasmer-runtime-core-fl", version = "0.17.0" }
|
||||
|
||||
anyhow = "1.0.31"
|
||||
chrono = "0.4.19"
|
||||
walrus = "0.18.0"
|
||||
semver = "0.11.0"
|
||||
|
||||
|
@ -47,4 +47,8 @@ pub enum ManifestError {
|
||||
/// Manifest contains some trailing characters.
|
||||
#[error("embedded manifest is corrupted: there are some trailing characters")]
|
||||
ManifestRemainderNotEmpty,
|
||||
|
||||
/// Error occurred while parsing embedded build time.
|
||||
#[error("build time can't be parsed: {0}")]
|
||||
DateTimeParseError(#[from] chrono::ParseError),
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ pub struct ModuleManifest {
|
||||
pub version: semver::Version,
|
||||
pub description: String,
|
||||
pub repository: String,
|
||||
pub build_time: chrono::DateTime<chrono::FixedOffset>,
|
||||
}
|
||||
|
||||
use super::ManifestError;
|
||||
@ -39,16 +40,20 @@ impl TryFrom<&[u8]> for ModuleManifest {
|
||||
let (version, next_offset) = try_extract_field_as_version(value, next_offset, "version")?;
|
||||
let (description, next_offset) = try_extract_field_as_string(value, next_offset, "description")?;
|
||||
let (repository, next_offset) = try_extract_field_as_string(value, next_offset, "repository")?;
|
||||
let (build_time, next_offset) = try_extract_field_as_string(value, next_offset, "build time")?;
|
||||
|
||||
if next_offset != value.len() {
|
||||
return Err(ManifestError::ManifestRemainderNotEmpty)
|
||||
}
|
||||
|
||||
let build_time = chrono::DateTime::parse_from_rfc3339(&build_time)?;
|
||||
|
||||
let manifest = ModuleManifest {
|
||||
authors,
|
||||
version,
|
||||
description,
|
||||
repository,
|
||||
build_time
|
||||
};
|
||||
|
||||
Ok(manifest)
|
||||
@ -140,6 +145,7 @@ impl fmt::Display for ModuleManifest {
|
||||
writeln!(f, "authors: {}", self.authors)?;
|
||||
writeln!(f, "version: {}", self.version)?;
|
||||
writeln!(f, "description: {}", self.description)?;
|
||||
write!(f, "repository: {}", self.repository)
|
||||
writeln!(f, "repository: {}", self.repository)?;
|
||||
write!(f, "build time: {} UTC", self.build_time)
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ fn test_reading_simple_config() {
|
||||
let version = semver::Version::from_str("0.1.0").unwrap();
|
||||
let description = "description".to_string();
|
||||
let repository = "repository".to_string();
|
||||
let build_time = chrono::Utc::now();
|
||||
|
||||
let mut array = ByteEncoder::new();
|
||||
|
||||
@ -78,6 +79,7 @@ fn test_reading_simple_config() {
|
||||
array.add_utf8_field(&version.to_string());
|
||||
array.add_utf8_field(&description);
|
||||
array.add_utf8_field(&repository);
|
||||
array.add_utf8_field(&build_time.to_rfc3339());
|
||||
|
||||
let actual: ModuleManifest = array
|
||||
.as_bytes()
|
||||
@ -89,6 +91,7 @@ fn test_reading_simple_config() {
|
||||
version,
|
||||
description,
|
||||
repository,
|
||||
build_time: build_time.into(),
|
||||
};
|
||||
|
||||
assert_eq!(actual, expected);
|
||||
|
Loading…
Reference in New Issue
Block a user