Everything optional except 'image-type' now. Also removed a couple fields.

When a RealmFS image is not sealed it has a very simple header and
doesn't use most of the metainfo fields.
This commit is contained in:
Bruce Leidl 2019-01-29 13:53:22 -05:00
parent d23e488aaa
commit e7e75061a1

View File

@ -297,24 +297,35 @@ pub struct MetaInfo {
struct MetaInfoToml {
#[serde(rename = "image-type")]
image_type: String,
#[serde(default)]
channel: String,
#[serde(rename = "kernel-version")]
kernel_version: Option<String>,
#[serde(rename = "kernel-id")]
kernel_id: Option<String>,
#[serde(rename = "realmfs-name")]
realmfs_name: Option<String>,
#[serde(default)]
version: u32,
#[serde(default)]
timestamp: String,
#[serde(rename = "base-version")]
base_version: Option<u32>,
date: Option<String>,
gitrev: Option<String>,
#[serde(default)]
nblocks: u32,
#[serde(default)]
shasum: String,
#[serde(rename = "verity-salt")]
#[serde(default, rename = "verity-salt")]
verity_salt: String,
#[serde(rename = "verity-root")]
#[serde(default, rename = "verity-root")]
verity_root: String,
}
@ -363,14 +374,6 @@ impl MetaInfo {
&self.toml().timestamp
}
pub fn date(&self) -> Option<&str> {
self.toml().date.as_ref().map(|s| s.as_str())
}
pub fn gitrev(&self) -> Option<&str> {
self.toml().gitrev.as_ref().map(|s| s.as_str())
}
pub fn nblocks(&self) -> usize {
self.toml().nblocks as usize
}