@@ -7,32 +7,56 @@ 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+ // TODO: Get the storage from the container image, not the booted storage
38+ let sysroot: crate :: store:: Storage = crate :: cli:: get_storage ( ) . await ?;
39+
40+ match list_type {
41+ ImageListType :: All => {
42+ println ! ( "# Host images" ) ;
43+ list_host_images ( & sysroot) ?;
44+ println ! ( ) ;
45+
46+ println ! ( "# Logically bound images" ) ;
47+ list_logical_images ( & sysroot) ?;
48+ }
49+ ImageListType :: Host => {
50+ list_host_images ( & sysroot) ?;
51+ }
52+ ImageListType :: Logical => {
53+ list_logical_images ( & sysroot) ?;
54+ }
55+ }
56+
57+ Ok ( ( ) )
58+ }
59+
3660/// Implementation of `bootc image push-to-storage`.
3761#[ context( "Pushing image" ) ]
3862pub ( crate ) async fn push_entrypoint ( source : Option < & str > , target : Option < & str > ) -> Result < ( ) > {
@@ -79,7 +103,7 @@ pub(crate) async fn push_entrypoint(source: Option<&str>, target: Option<&str>)
79103/// Thin wrapper for invoking `podman image <X>` but set up for our internal
80104/// image store (as distinct from /var/lib/containers default).
81105pub ( crate ) async fn imgcmd_entrypoint (
82- storage : & Storage ,
106+ storage : & crate :: imgstorage :: Storage ,
83107 arg : & str ,
84108 args : & [ std:: ffi:: OsString ] ,
85109) -> std:: result:: Result < ( ) , anyhow:: Error > {
0 commit comments