Skip to content

Commit 34e104d

Browse files
authored
Merge pull request #804 from jeckersb/ostree-rs-bump
Bump ostree-ext to 0.15.1 and use proper digests where possible
2 parents c5f80c9 + ad7af3f commit 34e104d

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/cli.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,16 +609,17 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
609609
}
610610
} else {
611611
let fetched = crate::deploy::pull(repo, imgref, None, opts.quiet).await?;
612-
let staged_digest = staged_image.as_ref().map(|s| s.image_digest.as_str());
613-
let fetched_digest = fetched.manifest_digest.as_str();
612+
let staged_digest = staged_image.map(|s| s.digest().expect("valid digest in status"));
613+
let fetched_digest = &fetched.manifest_digest;
614614
tracing::debug!("staged: {staged_digest:?}");
615615
tracing::debug!("fetched: {fetched_digest}");
616616
let staged_unchanged = staged_digest
617+
.as_ref()
617618
.map(|d| d == fetched_digest)
618619
.unwrap_or_default();
619620
let booted_unchanged = booted_image
620621
.as_ref()
621-
.map(|img| img.manifest_digest.as_str() == fetched_digest)
622+
.map(|img| &img.manifest_digest == fetched_digest)
622623
.unwrap_or_default();
623624
if staged_unchanged {
624625
println!("Staged update present, not changed.");

lib/src/deploy.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use ostree::{gio, glib};
1515
use ostree_container::OstreeImageReference;
1616
use ostree_ext::container as ostree_container;
1717
use ostree_ext::container::store::{ImportProgress, PrepareResult};
18-
use ostree_ext::oci_spec::image::Descriptor;
18+
use ostree_ext::oci_spec::image::{Descriptor, Digest};
1919
use ostree_ext::ostree::Deployment;
2020
use ostree_ext::ostree::{self, Sysroot};
2121
use ostree_ext::sysroot::SysrootLock;
@@ -38,7 +38,7 @@ pub(crate) struct RequiredHostSpec<'a> {
3838

3939
/// State of a locally fetched image
4040
pub(crate) struct ImageState {
41-
pub(crate) manifest_digest: String,
41+
pub(crate) manifest_digest: Digest,
4242
pub(crate) version: Option<String>,
4343
pub(crate) ostree_commit: String,
4444
}
@@ -481,7 +481,10 @@ pub(crate) async fn rollback(sysroot: &Storage) -> Result<()> {
481481
&msg,
482482
[
483483
("MESSAGE_ID", ROLLBACK_JOURNAL_ID),
484-
("BOOTC_MANIFEST_DIGEST", &rollback_image.manifest_digest),
484+
(
485+
"BOOTC_MANIFEST_DIGEST",
486+
&rollback_image.manifest_digest.to_string(),
487+
),
485488
]
486489
.into_iter(),
487490
)?;

lib/src/spec.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::fmt::Display;
44

55
use ostree_ext::container::OstreeImageReference;
6+
use ostree_ext::oci_spec::image::Digest;
67
use schemars::JsonSchema;
78
use serde::{Deserialize, Serialize};
89

@@ -219,6 +220,13 @@ impl Display for ImageReference {
219220
}
220221
}
221222

223+
impl ImageStatus {
224+
pub(crate) fn digest(&self) -> anyhow::Result<Digest> {
225+
use std::str::FromStr;
226+
Ok(Digest::from_str(&self.image_digest)?)
227+
}
228+
}
229+
222230
#[cfg(test)]
223231
mod tests {
224232
use std::str::FromStr;

lib/src/store/ostree_container.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::{Context, Result};
22

33
use ostree_ext::container as ostree_container;
44
use ostree_ext::oci_spec;
5-
use ostree_ext::oci_spec::image::ImageConfiguration;
5+
use ostree_ext::oci_spec::image::{Digest, ImageConfiguration};
66
use ostree_ext::ostree;
77
use ostree_ext::sysroot::SysrootLock;
88

@@ -42,7 +42,7 @@ impl super::ContainerImageStoreImpl for OstreeContainerStore {
4242
/// Convert between a subset of ostree-ext metadata and the exposed spec API.
4343
fn create_imagestatus(
4444
image: ImageReference,
45-
manifest_digest: &str,
45+
manifest_digest: &Digest,
4646
config: &ImageConfiguration,
4747
) -> ImageStatus {
4848
let labels = labels_of_config(config);
@@ -58,7 +58,7 @@ fn create_imagestatus(
5858
image,
5959
version,
6060
timestamp,
61-
image_digest: manifest_digest.to_owned(),
61+
image_digest: manifest_digest.to_string(),
6262
}
6363
}
6464

0 commit comments

Comments
 (0)