Skip to content

Commit

Permalink
wip oci status
Browse files Browse the repository at this point in the history
  • Loading branch information
jbtrystram committed Dec 19, 2024
1 parent 7000352 commit 7c601c7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/rpm_ostree/cli_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ pub fn parse_booted(status: &Status) -> Result<Release> {
}

fn fedora_coreos_stream_from_deployment(deploy: &Deployment) -> Result<String> {
if deploy.base_metadata.stream.is_none() {
println!("no stream, maybe it's OCI let's try to deserialize");
}

if deploy.container_image_reference.is_some()

let stream = deploy
.base_metadata
.stream
.as_ref()
.ok_or_else(|| anyhow!("Missing `fedora-coreos.stream` in commit metadata"))?;
ensure!(!stream.is_empty(), "empty stream value");
Ok(stream.to_string())
}

fn fedora_coreos_stream_from_oci_manifest(deploy: &Deployment) -> Result<String> {
let stream = deploy
.base_metadata
.stream
Expand Down Expand Up @@ -274,4 +290,12 @@ mod tests {
let stream = fedora_coreos_stream_from_deployment(&booted).unwrap();
assert_eq!(stream, "testing-devel");
}

#[test]
fn mock_booted_oci_updates_stream() {
let status = mock_status("tests/fixtures/rpm-ostree-oci-status.json").unwrap();
let booted = booted_status(&status).unwrap();
let stream = fedora_coreos_stream_from_deployment(&booted).unwrap();
assert_eq!(stream, "stable");
}
}
2 changes: 1 addition & 1 deletion tests/fixtures/rpm-ostree-oci-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"transaction" : null,
"cached-update" : null,
"update-driver" : null
}
}

0 comments on commit 7c601c7

Please sign in to comment.