@@ -495,6 +495,32 @@ impl FromStr for MountSpec {
495
495
}
496
496
}
497
497
498
+ impl InstallAleph {
499
+ #[ context( "Creating aleph data" ) ]
500
+ pub ( crate ) fn new (
501
+ src_imageref : & ostree_container:: OstreeImageReference ,
502
+ imgstate : & ostree_container:: store:: LayeredImageState ,
503
+ selinux_state : & SELinuxFinalState ,
504
+ ) -> Result < Self > {
505
+ let uname = rustix:: system:: uname ( ) ;
506
+ let labels = crate :: status:: labels_of_config ( & imgstate. configuration ) ;
507
+ let timestamp = labels
508
+ . and_then ( |l| {
509
+ l. get ( oci_spec:: image:: ANNOTATION_CREATED )
510
+ . map ( |s| s. as_str ( ) )
511
+ } )
512
+ . and_then ( crate :: status:: try_deserialize_timestamp) ;
513
+ let r = InstallAleph {
514
+ image : src_imageref. imgref . name . clone ( ) ,
515
+ version : imgstate. version ( ) . as_ref ( ) . map ( |s| s. to_string ( ) ) ,
516
+ timestamp,
517
+ kernel : uname. release ( ) . to_str ( ) ?. to_string ( ) ,
518
+ selinux : selinux_state. to_aleph ( ) . to_string ( ) ,
519
+ } ;
520
+ Ok ( r)
521
+ }
522
+ }
523
+
498
524
impl SourceInfo {
499
525
// Inspect container information and convert it to an ostree image reference
500
526
// that pulls from containers-storage.
@@ -842,23 +868,7 @@ async fn install_container(
842
868
osconfig:: inject_root_ssh_authorized_keys ( & root, sepolicy, contents) ?;
843
869
}
844
870
845
- let uname = rustix:: system:: uname ( ) ;
846
-
847
- let labels = crate :: status:: labels_of_config ( & imgstate. configuration ) ;
848
- let timestamp = labels
849
- . and_then ( |l| {
850
- l. get ( oci_spec:: image:: ANNOTATION_CREATED )
851
- . map ( |s| s. as_str ( ) )
852
- } )
853
- . and_then ( crate :: status:: try_deserialize_timestamp) ;
854
- let aleph = InstallAleph {
855
- image : src_imageref. imgref . name . clone ( ) ,
856
- version : imgstate. version ( ) . as_ref ( ) . map ( |s| s. to_string ( ) ) ,
857
- timestamp,
858
- kernel : uname. release ( ) . to_str ( ) ?. to_string ( ) ,
859
- selinux : state. selinux_state . to_aleph ( ) . to_string ( ) ,
860
- } ;
861
-
871
+ let aleph = InstallAleph :: new ( & src_imageref, & imgstate, & state. selinux_state ) ?;
862
872
Ok ( ( deployment, aleph) )
863
873
}
864
874
0 commit comments