@@ -7,32 +7,56 @@ 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
+ // 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
+
36
60
/// Implementation of `bootc image push-to-storage`.
37
61
#[ context( "Pushing image" ) ]
38
62
pub ( 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>)
79
103
/// Thin wrapper for invoking `podman image <X>` but set up for our internal
80
104
/// image store (as distinct from /var/lib/containers default).
81
105
pub ( crate ) async fn imgcmd_entrypoint (
82
- storage : & Storage ,
106
+ storage : & crate :: imgstorage :: Storage ,
83
107
arg : & str ,
84
108
args : & [ std:: ffi:: OsString ] ,
85
109
) -> std:: result:: Result < ( ) , anyhow:: Error > {
0 commit comments