Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump ostree-ext to 0.15.1 and use proper digests where possible #804

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,16 +609,17 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
}
} else {
let fetched = crate::deploy::pull(repo, imgref, None, opts.quiet).await?;
let staged_digest = staged_image.as_ref().map(|s| s.image_digest.as_str());
let fetched_digest = fetched.manifest_digest.as_str();
let staged_digest = staged_image.map(|s| s.digest().expect("valid digest in status"));
let fetched_digest = &fetched.manifest_digest;
tracing::debug!("staged: {staged_digest:?}");
tracing::debug!("fetched: {fetched_digest}");
let staged_unchanged = staged_digest
.as_ref()
.map(|d| d == fetched_digest)
.unwrap_or_default();
let booted_unchanged = booted_image
.as_ref()
.map(|img| img.manifest_digest.as_str() == fetched_digest)
.map(|img| &img.manifest_digest == fetched_digest)
.unwrap_or_default();
if staged_unchanged {
println!("Staged update present, not changed.");
Expand Down
9 changes: 6 additions & 3 deletions lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ostree::{gio, glib};
use ostree_container::OstreeImageReference;
use ostree_ext::container as ostree_container;
use ostree_ext::container::store::{ImportProgress, PrepareResult};
use ostree_ext::oci_spec::image::Descriptor;
use ostree_ext::oci_spec::image::{Descriptor, Digest};
use ostree_ext::ostree::Deployment;
use ostree_ext::ostree::{self, Sysroot};
use ostree_ext::sysroot::SysrootLock;
Expand All @@ -38,7 +38,7 @@ pub(crate) struct RequiredHostSpec<'a> {

/// State of a locally fetched image
pub(crate) struct ImageState {
pub(crate) manifest_digest: String,
pub(crate) manifest_digest: Digest,
pub(crate) version: Option<String>,
pub(crate) ostree_commit: String,
}
Expand Down Expand Up @@ -481,7 +481,10 @@ pub(crate) async fn rollback(sysroot: &Storage) -> Result<()> {
&msg,
[
("MESSAGE_ID", ROLLBACK_JOURNAL_ID),
("BOOTC_MANIFEST_DIGEST", &rollback_image.manifest_digest),
(
"BOOTC_MANIFEST_DIGEST",
&rollback_image.manifest_digest.to_string(),
),
]
.into_iter(),
)?;
Expand Down
8 changes: 8 additions & 0 deletions lib/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::fmt::Display;

use ostree_ext::container::OstreeImageReference;
use ostree_ext::oci_spec::image::Digest;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -219,6 +220,13 @@ impl Display for ImageReference {
}
}

impl ImageStatus {
pub(crate) fn digest(&self) -> anyhow::Result<Digest> {
use std::str::FromStr;
Ok(Digest::from_str(&self.image_digest)?)
}
}

#[cfg(test)]
mod tests {
use std::str::FromStr;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/store/ostree_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{Context, Result};

use ostree_ext::container as ostree_container;
use ostree_ext::oci_spec;
use ostree_ext::oci_spec::image::ImageConfiguration;
use ostree_ext::oci_spec::image::{Digest, ImageConfiguration};
use ostree_ext::ostree;
use ostree_ext::sysroot::SysrootLock;

Expand Down Expand Up @@ -42,7 +42,7 @@ impl super::ContainerImageStoreImpl for OstreeContainerStore {
/// Convert between a subset of ostree-ext metadata and the exposed spec API.
fn create_imagestatus(
image: ImageReference,
manifest_digest: &str,
manifest_digest: &Digest,
config: &ImageConfiguration,
) -> ImageStatus {
let labels = labels_of_config(config);
Expand All @@ -58,7 +58,7 @@ fn create_imagestatus(
image,
version,
timestamp,
image_digest: manifest_digest.to_owned(),
image_digest: manifest_digest.to_string(),
}
}

Expand Down