@@ -31,6 +31,7 @@ use ostree::glib;
31
31
32
32
use std:: borrow:: Cow ;
33
33
use std:: collections:: HashMap ;
34
+ use std:: fmt:: Debug ;
34
35
use std:: ops:: Deref ;
35
36
use std:: str:: FromStr ;
36
37
@@ -277,7 +278,14 @@ impl std::fmt::Display for OstreeImageReference {
277
278
( SignatureSource :: ContainerPolicyAllowInsecure , imgref)
278
279
if imgref. transport == Transport :: Registry =>
279
280
{
280
- write ! ( f, "ostree-unverified-registry:{}" , self . imgref. name)
281
+ // Because allow-insecure is the effective default, allow formatting
282
+ // without it. Note this formatting is asymmetric and cannot be
283
+ // re-parsed.
284
+ if f. alternate ( ) {
285
+ write ! ( f, "{}" , self . imgref)
286
+ } else {
287
+ write ! ( f, "ostree-unverified-registry:{}" , self . imgref. name)
288
+ }
281
289
}
282
290
( sigverify, imgref) => {
283
291
write ! ( f, "{}:{}" , sigverify, imgref)
@@ -584,10 +592,8 @@ mod tests {
584
592
assert_eq ! ( ir. sigverify, SignatureSource :: ContainerPolicy ) ;
585
593
assert_eq ! ( ir. imgref. transport, Transport :: Registry ) ;
586
594
assert_eq ! ( ir. imgref. name, "quay.io/exampleos/blah" ) ;
587
- assert_eq ! (
588
- ir. to_string( ) ,
589
- "ostree-image-signed:docker://quay.io/exampleos/blah"
590
- ) ;
595
+ assert_eq ! ( ir. to_string( ) , ir_s) ;
596
+ assert_eq ! ( format!( "{:#}" , & ir) , ir_s) ;
591
597
592
598
let ir_s = "ostree-unverified-image:docker://quay.io/exampleos/blah" ;
593
599
let ir: OstreeImageReference = ir_s. try_into ( ) . unwrap ( ) ;
@@ -602,6 +608,7 @@ mod tests {
602
608
OstreeImageReference :: try_from ( "ostree-unverified-registry:quay.io/exampleos/blah" )
603
609
. unwrap ( ) ;
604
610
assert_eq ! ( & ir_shorthand, & ir) ;
611
+ assert_eq ! ( format!( "{:#}" , & ir) , "docker://quay.io/exampleos/blah" ) ;
605
612
}
606
613
607
614
#[ test]
0 commit comments