@@ -30,6 +30,7 @@ use crate::commit::container_commit;
3030use crate :: container:: store:: { ExportToOCIOpts , ImportProgress , LayerProgress , PreparedImport } ;
3131use crate :: container:: { self as ostree_container, ManifestDiff } ;
3232use crate :: container:: { Config , ImageReference , OstreeImageReference } ;
33+ use crate :: json:: JsonOrderedSerialize ;
3334use crate :: objectsource:: ObjectSourceMeta ;
3435use crate :: sysroot:: SysrootLock ;
3536use ostree_container:: store:: { ImageImporter , PrepareResult } ;
@@ -880,7 +881,9 @@ async fn container_store(
880881 if let Some ( check) = check. as_deref ( ) {
881882 let rootfs = Dir :: open_ambient_dir ( "/" , cap_std:: ambient_authority ( ) ) ?;
882883 rootfs. atomic_replace_with ( check. as_str ( ) . trim_start_matches ( '/' ) , |w| {
883- serde_json:: to_writer ( w, & prep. manifest ) . context ( "Serializing manifest" )
884+ prep. manifest
885+ . to_json_ordered_writer ( w)
886+ . context ( "Serializing manifest" )
884887 } ) ?;
885888 // In check mode, we're done
886889 return Ok ( ( ) ) ;
@@ -1007,10 +1010,11 @@ fn container_remount_sysroot(sysroot: &Utf8Path) -> Result<()> {
10071010#[ context( "Serializing to output file" ) ]
10081011fn handle_serialize_to_file < T : serde:: Serialize > ( path : Option < & Utf8Path > , obj : T ) -> Result < ( ) > {
10091012 if let Some ( path) = path {
1010- let mut out = std:: fs:: File :: create ( path)
1013+ let out = std:: fs:: File :: create ( path)
10111014 . map ( BufWriter :: new)
10121015 . with_context ( || anyhow:: anyhow!( "Opening {path} for writing" ) ) ?;
1013- serde_json:: to_writer ( & mut out, & obj) . context ( "Serializing output" ) ?;
1016+ obj. to_json_ordered_writer ( out)
1017+ . context ( "Serializing output" ) ?;
10141018 }
10151019 Ok ( ( ) )
10161020}
@@ -1134,13 +1138,11 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
11341138 let image = crate :: container:: store:: query_image ( & repo, & imgref) ?
11351139 . ok_or_else ( || anyhow:: anyhow!( "No such image" ) ) ?;
11361140 let stdout = std:: io:: stdout ( ) . lock ( ) ;
1137- let mut stdout = std:: io:: BufWriter :: new ( stdout) ;
11381141 if config {
1139- serde_json :: to_writer ( & mut stdout , & image. configuration ) ?;
1142+ image. configuration . to_json_ordered_writer ( stdout ) ?;
11401143 } else {
1141- serde_json :: to_writer ( & mut stdout , & image. manifest ) ?;
1144+ image. manifest . to_json_ordered_writer ( stdout ) ?;
11421145 }
1143- stdout. flush ( ) ?;
11441146 Ok ( ( ) )
11451147 }
11461148 ContainerImageOpts :: ClearCachedUpdate { repo, imgref } => {
0 commit comments