@@ -8,13 +8,12 @@ use ostree_container::OstreeImageReference;
8
8
use ostree_ext:: container as ostree_container;
9
9
use ostree_ext:: keyfileext:: KeyFileExt ;
10
10
use ostree_ext:: oci_spec;
11
- use ostree_ext:: oci_spec:: image:: ImageConfiguration ;
12
11
use ostree_ext:: ostree;
13
- use ostree_ext:: sysroot:: SysrootLock ;
14
12
15
13
use crate :: cli:: OutputFormat ;
16
- use crate :: spec:: { BootEntry , BootOrder , Host , HostSpec , HostStatus , HostType , ImageStatus } ;
14
+ use crate :: spec:: { BootEntry , BootOrder , Host , HostSpec , HostStatus , HostType } ;
17
15
use crate :: spec:: { ImageReference , ImageSignature } ;
16
+ use crate :: store:: { CachedImageStatus , ContainerImageStore , Storage } ;
18
17
19
18
impl From < ostree_container:: SignatureSource > for ImageSignature {
20
19
fn from ( sig : ostree_container:: SignatureSource ) -> Self {
@@ -115,65 +114,46 @@ pub(crate) fn labels_of_config(
115
114
config. config ( ) . as_ref ( ) . and_then ( |c| c. labels ( ) . as_ref ( ) )
116
115
}
117
116
118
- /// Convert between a subset of ostree-ext metadata and the exposed spec API.
119
- pub ( crate ) fn create_imagestatus (
120
- image : ImageReference ,
121
- manifest_digest : & str ,
122
- config : & ImageConfiguration ,
123
- ) -> ImageStatus {
124
- let labels = labels_of_config ( config) ;
125
- let timestamp = labels
126
- . and_then ( |l| {
127
- l. get ( oci_spec:: image:: ANNOTATION_CREATED )
128
- . map ( |s| s. as_str ( ) )
129
- } )
130
- . and_then ( try_deserialize_timestamp) ;
131
-
132
- let version = ostree_container:: version_for_config ( config) . map ( ToOwned :: to_owned) ;
133
- ImageStatus {
134
- image,
135
- version,
136
- timestamp,
137
- image_digest : manifest_digest. to_owned ( ) ,
138
- }
139
- }
140
-
141
117
/// Given an OSTree deployment, parse out metadata into our spec.
142
118
#[ context( "Reading deployment metadata" ) ]
143
119
fn boot_entry_from_deployment (
144
- sysroot : & SysrootLock ,
120
+ sysroot : & Storage ,
145
121
deployment : & ostree:: Deployment ,
146
122
) -> Result < BootEntry > {
147
- let repo = & sysroot. repo ( ) ;
148
- let ( image, cached_update, incompatible) = if let Some ( origin) = deployment. origin ( ) . as_ref ( ) {
123
+ let (
124
+ store,
125
+ CachedImageStatus {
126
+ image,
127
+ cached_update,
128
+ } ,
129
+ incompatible,
130
+ ) = if let Some ( origin) = deployment. origin ( ) . as_ref ( ) {
149
131
let incompatible = crate :: utils:: origin_has_rpmostree_stuff ( origin) ;
150
- let ( image , cached ) = if incompatible {
132
+ let ( store , cached_imagestatus ) = if incompatible {
151
133
// If there are local changes, we can't represent it as a bootc compatible image.
152
- ( None , None )
134
+ ( None , CachedImageStatus :: default ( ) )
153
135
} else if let Some ( image) = get_image_origin ( origin) ? {
154
- let image = ImageReference :: from ( image) ;
155
- let csum = deployment. csum ( ) ;
156
- let imgstate = ostree_container:: store:: query_image_commit ( repo, & csum) ?;
157
- let cached = imgstate. cached_update . map ( |cached| {
158
- create_imagestatus ( image. clone ( ) , & cached. manifest_digest , & cached. config )
159
- } ) ;
160
- let imagestatus =
161
- create_imagestatus ( image, & imgstate. manifest_digest , & imgstate. configuration ) ;
162
- // We found a container-image based deployment
163
- ( Some ( imagestatus) , cached)
136
+ let store = deployment. store ( ) ?;
137
+ let store = store. as_ref ( ) . unwrap_or ( & sysroot. store ) ;
138
+ let spec = Some ( store. spec ( ) ) ;
139
+ let status = store. imagestatus ( sysroot, deployment, image) ?;
140
+
141
+ ( spec, status)
164
142
} else {
165
143
// The deployment isn't using a container image
166
- ( None , None )
144
+ ( None , CachedImageStatus :: default ( ) )
167
145
} ;
168
- ( image , cached , incompatible)
146
+ ( store , cached_imagestatus , incompatible)
169
147
} else {
170
148
// The deployment has no origin at all (this generally shouldn't happen)
171
- ( None , None , false )
149
+ ( None , CachedImageStatus :: default ( ) , false )
172
150
} ;
151
+
173
152
let r = BootEntry {
174
153
image,
175
154
cached_update,
176
155
incompatible,
156
+ store,
177
157
pinned : deployment. is_pinned ( ) ,
178
158
ostree : Some ( crate :: spec:: BootEntryOstree {
179
159
checksum : deployment. csum ( ) . into ( ) ,
@@ -203,7 +183,7 @@ impl BootEntry {
203
183
204
184
/// A variant of [`get_status`] that requires a booted deployment.
205
185
pub ( crate ) fn get_status_require_booted (
206
- sysroot : & SysrootLock ,
186
+ sysroot : & Storage ,
207
187
) -> Result < ( ostree:: Deployment , Deployments , Host ) > {
208
188
let booted_deployment = sysroot. require_booted_deployment ( ) ?;
209
189
let ( deployments, host) = get_status ( sysroot, Some ( & booted_deployment) ) ?;
@@ -214,7 +194,7 @@ pub(crate) fn get_status_require_booted(
214
194
/// a more native Rust structure.
215
195
#[ context( "Computing status" ) ]
216
196
pub ( crate ) fn get_status (
217
- sysroot : & SysrootLock ,
197
+ sysroot : & Storage ,
218
198
booted_deployment : Option < & ostree:: Deployment > ,
219
199
) -> Result < ( Deployments , Host ) > {
220
200
let stateroot = booted_deployment. as_ref ( ) . map ( |d| d. osname ( ) ) ;
@@ -311,7 +291,7 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
311
291
let host = if !Utf8Path :: new ( "/run/ostree-booted" ) . try_exists ( ) ? {
312
292
Default :: default ( )
313
293
} else {
314
- let sysroot = super :: cli:: get_locked_sysroot ( ) . await ?;
294
+ let sysroot = super :: cli:: get_storage ( ) . await ?;
315
295
let booted_deployment = sysroot. booted_deployment ( ) ;
316
296
let ( _deployments, host) = get_status ( & sysroot, booted_deployment. as_ref ( ) ) ?;
317
297
host
0 commit comments