@@ -7,32 +7,55 @@ use bootc_utils::CommandRunExt;
77use fn_error_context:: context;
88use ostree_ext:: container:: { ImageReference , Transport } ;
99
10- use crate :: imgstorage :: Storage ;
10+ use crate :: cli :: ImageListType ;
1111
1212/// The name of the image we push to containers-storage if nothing is specified.
1313const IMAGE_DEFAULT : & str = "localhost/bootc" ;
1414
15- #[ context( "Listing images" ) ]
16- pub ( crate ) async fn list_entrypoint ( ) -> Result < ( ) > {
17- let sysroot = crate :: cli:: get_storage ( ) . await ?;
18- let repo = & sysroot. repo ( ) ;
19-
20- let images = ostree_ext:: container:: store:: list_images ( repo) . context ( "Querying images" ) ?;
21-
22- println ! ( "# Host images" ) ;
15+ #[ context( "Listing host images" ) ]
16+ pub ( crate ) fn list_host_images ( sysroot : & crate :: store:: Storage ) -> Result < ( ) > {
17+ let repo = sysroot. repo ( ) ;
18+ let images = ostree_ext:: container:: store:: list_images ( & repo) . context ( "Querying images" ) ?;
2319 for image in images {
2420 println ! ( "{image}" ) ;
2521 }
26- println ! ( ) ;
2722
28- println ! ( "# Logically bound images" ) ;
23+ Ok ( ( ) )
24+ }
25+
26+ #[ context( "Listing logical images" ) ]
27+ pub ( crate ) fn list_logical_images ( sysroot : & crate :: store:: Storage ) -> Result < ( ) > {
2928 let mut listcmd = sysroot. get_ensure_imgstore ( ) ?. new_image_cmd ( ) ?;
3029 listcmd. arg ( "list" ) ;
3130 listcmd. run ( ) ?;
3231
3332 Ok ( ( ) )
3433}
3534
35+ #[ context( "Listing images" ) ]
36+ pub ( crate ) async fn list_entrypoint ( list_type : ImageListType ) -> Result < ( ) > {
37+ let sysroot: crate :: store:: Storage = crate :: cli:: get_storage ( ) . await ?;
38+
39+ match list_type {
40+ ImageListType :: All => {
41+ println ! ( "# Host images" ) ;
42+ list_host_images ( & sysroot) ?;
43+ println ! ( ) ;
44+
45+ println ! ( "# Logically bound images" ) ;
46+ list_logical_images ( & sysroot) ?;
47+ }
48+ ImageListType :: Host => {
49+ list_host_images ( & sysroot) ?;
50+ }
51+ ImageListType :: Logical => {
52+ list_logical_images ( & sysroot) ?;
53+ }
54+ }
55+
56+ Ok ( ( ) )
57+ }
58+
3659/// Implementation of `bootc image push-to-storage`.
3760#[ context( "Pushing image" ) ]
3861pub ( crate ) async fn push_entrypoint ( source : Option < & str > , target : Option < & str > ) -> Result < ( ) > {
@@ -79,7 +102,7 @@ pub(crate) async fn push_entrypoint(source: Option<&str>, target: Option<&str>)
79102/// Thin wrapper for invoking `podman image <X>` but set up for our internal
80103/// image store (as distinct from /var/lib/containers default).
81104pub ( crate ) async fn imgcmd_entrypoint (
82- storage : & Storage ,
105+ storage : & crate :: imgstorage :: Storage ,
83106 arg : & str ,
84107 args : & [ std:: ffi:: OsString ] ,
85108) -> std:: result:: Result < ( ) , anyhow:: Error > {
0 commit comments