diff --git a/lib/src/cli.rs b/lib/src/cli.rs index 77154fcb7..7d0fbea62 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -338,11 +338,11 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> { let mut imp = crate::deploy::new_importer(repo, &imgref).await?; match imp.prepare().await? { PrepareResult::AlreadyPresent(_) => { - println!("No changes in: {}", imgref); + println!("No changes in: {imgref:#}"); } PrepareResult::Ready(r) => { crate::deploy::check_bootc_label(&r.config); - println!("Update available for: {}", imgref); + println!("Update available for: {imgref:#}"); if let Some(version) = r.version() { println!(" Version: {version}"); } diff --git a/lib/src/deploy.rs b/lib/src/deploy.rs index d47efbc31..90c5e40aa 100644 --- a/lib/src/deploy.rs +++ b/lib/src/deploy.rs @@ -119,11 +119,11 @@ pub(crate) async fn pull( quiet: bool, ) -> Result> { let repo = &sysroot.repo(); - let imgref = &OstreeImageReference::from(imgref.clone()); - let mut imp = new_importer(repo, imgref).await?; + let ostree_imgref = &OstreeImageReference::from(imgref.clone()); + let mut imp = new_importer(repo, ostree_imgref).await?; let prep = match imp.prepare().await? { PrepareResult::AlreadyPresent(c) => { - println!("No changes in {} => {}", imgref, c.manifest_digest); + println!("No changes in {imgref:#} => {}", c.manifest_digest); return Ok(Box::new((*c).into())); } PrepareResult::Ready(p) => p, @@ -146,7 +146,7 @@ pub(crate) async fn pull( } let import = import?; if let Some(msg) = - ostree_container::store::image_filtered_content_warning(repo, &imgref.imgref)? + ostree_container::store::image_filtered_content_warning(repo, &ostree_imgref.imgref)? { crate::journal::journal_print(libsystemd::logging::Priority::Notice, &msg); } diff --git a/lib/src/spec.rs b/lib/src/spec.rs index 4d9a08aee..6de963908 100644 --- a/lib/src/spec.rs +++ b/lib/src/spec.rs @@ -154,8 +154,13 @@ impl Default for Host { impl Display for ImageReference { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let ostree_imgref = OstreeImageReference::from(self.clone()); - ostree_imgref.fmt(f) + // For the default of fetching from a remote registry, just output the image name + if f.alternate() && self.signature.is_none() && self.transport == "registry" { + self.image.fmt(f) + } else { + let ostree_imgref = OstreeImageReference::from(self.clone()); + ostree_imgref.fmt(f) + } } } @@ -203,5 +208,14 @@ mod tests { let s = ImageReference::from(s); let displayed = format!("{s}"); assert_eq!(displayed.as_str(), src); + // Alternative display should be short form + assert_eq!(format!("{s:#}"), "quay.io/example/foo:sometag"); + + let src = "ostree-remote-image:fedora:docker://quay.io/example/foo:sometag"; + let s = OstreeImageReference::from_str(src).unwrap(); + let s = ImageReference::from(s); + let displayed = format!("{s}"); + assert_eq!(displayed.as_str(), src); + assert_eq!(format!("{s:#}"), src); } }