Skip to content

Commit

Permalink
Don't output sigverify+transport for default
Browse files Browse the repository at this point in the history
Same motivation as ostreedev/ostree-rs-ext#604

Because fetching from a registry with the default sigverify is
the 90% case default, when we see this (and are formatting for
human consumption), use the "alternate" formatting to just
display the image name.

This makes the ostree stuff *much* less in the user's face
in the default path.
  • Loading branch information
cgwalters committed Feb 13, 2024
1 parent c19d87f commit b97ee12
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ pub(crate) async fn pull(
quiet: bool,
) -> Result<Box<ImageState>> {
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,
Expand All @@ -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);
}
Expand Down
18 changes: 16 additions & 2 deletions lib/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down Expand Up @@ -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);
}
}

0 comments on commit b97ee12

Please sign in to comment.