@@ -30,6 +30,7 @@ use crate::commit::container_commit;
30
30
use crate :: container:: store:: { ExportToOCIOpts , ImportProgress , LayerProgress , PreparedImport } ;
31
31
use crate :: container:: { self as ostree_container, ManifestDiff } ;
32
32
use crate :: container:: { Config , ImageReference , OstreeImageReference } ;
33
+ use crate :: json:: JsonOrderedSerialize ;
33
34
use crate :: objectsource:: ObjectSourceMeta ;
34
35
use crate :: sysroot:: SysrootLock ;
35
36
use ostree_container:: store:: { ImageImporter , PrepareResult } ;
@@ -880,7 +881,9 @@ async fn container_store(
880
881
if let Some ( check) = check. as_deref ( ) {
881
882
let rootfs = Dir :: open_ambient_dir ( "/" , cap_std:: ambient_authority ( ) ) ?;
882
883
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" )
884
887
} ) ?;
885
888
// In check mode, we're done
886
889
return Ok ( ( ) ) ;
@@ -1007,10 +1010,11 @@ fn container_remount_sysroot(sysroot: &Utf8Path) -> Result<()> {
1007
1010
#[ context( "Serializing to output file" ) ]
1008
1011
fn handle_serialize_to_file < T : serde:: Serialize > ( path : Option < & Utf8Path > , obj : T ) -> Result < ( ) > {
1009
1012
if let Some ( path) = path {
1010
- let mut out = std:: fs:: File :: create ( path)
1013
+ let out = std:: fs:: File :: create ( path)
1011
1014
. map ( BufWriter :: new)
1012
1015
. 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" ) ?;
1014
1018
}
1015
1019
Ok ( ( ) )
1016
1020
}
@@ -1136,9 +1140,9 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
1136
1140
let stdout = std:: io:: stdout ( ) . lock ( ) ;
1137
1141
let mut stdout = std:: io:: BufWriter :: new ( stdout) ;
1138
1142
if config {
1139
- serde_json :: to_writer ( & mut stdout, & image . configuration ) ?;
1143
+ image . configuration . to_json_ordered_writer ( & mut stdout) ?;
1140
1144
} else {
1141
- serde_json :: to_writer ( & mut stdout, & image . manifest ) ?;
1145
+ image . manifest . to_json_ordered_writer ( & mut stdout) ?;
1142
1146
}
1143
1147
stdout. flush ( ) ?;
1144
1148
Ok ( ( ) )
0 commit comments