Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
make version field mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
antheas committed Aug 30, 2024
1 parent cb33dad commit 3ea0f76
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ async fn container_import(
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct RawMeta {
/// The metadata format version. Should be set to 1.
pub version: Option<u32>,
pub version: u32,
/// The image creation timestamp. Format is YYYY-MM-DDTHH:MM:SSZ.
/// Should be synced with the label io.container.image.created.
pub created: Option<String>,
Expand Down Expand Up @@ -764,10 +764,13 @@ async fn container_export(
let raw: RawMeta = serde_json::from_reader(buf?)?;

// Check future variables are set correctly
if let Some(version) = raw.version {
if version != 1 {
return Err(anyhow::anyhow!("Unsupported metadata version: {}", version));
}
let supported_version = 1;
if raw.version != supported_version {
return Err(anyhow::anyhow!(
"Unsupported metadata version: {}. Currently supported: {}",
raw.version,
supported_version
));
}
if let Some(ordered) = raw.ordered {
if ordered {
Expand Down

0 comments on commit 3ea0f76

Please sign in to comment.