@@ -7,32 +7,55 @@ use bootc_utils::CommandRunExt;
7
7
use fn_error_context:: context;
8
8
use ostree_ext:: container:: { ImageReference , Transport } ;
9
9
10
- use crate :: imgstorage :: Storage ;
10
+ use crate :: cli :: ImageListType ;
11
11
12
12
/// The name of the image we push to containers-storage if nothing is specified.
13
13
const IMAGE_DEFAULT : & str = "localhost/bootc" ;
14
14
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" ) ?;
23
19
for image in images {
24
20
println ! ( "{image}" ) ;
25
21
}
26
- println ! ( ) ;
27
22
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 < ( ) > {
29
28
let mut listcmd = sysroot. get_ensure_imgstore ( ) ?. new_image_cmd ( ) ?;
30
29
listcmd. arg ( "list" ) ;
31
30
listcmd. run ( ) ?;
32
31
33
32
Ok ( ( ) )
34
33
}
35
34
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
+
36
59
/// Implementation of `bootc image push-to-storage`.
37
60
#[ context( "Pushing image" ) ]
38
61
pub ( 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>)
79
102
/// Thin wrapper for invoking `podman image <X>` but set up for our internal
80
103
/// image store (as distinct from /var/lib/containers default).
81
104
pub ( crate ) async fn imgcmd_entrypoint (
82
- storage : & Storage ,
105
+ storage : & crate :: imgstorage :: Storage ,
83
106
arg : & str ,
84
107
args : & [ std:: ffi:: OsString ] ,
85
108
) -> std:: result:: Result < ( ) , anyhow:: Error > {
0 commit comments