File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use ostree_ext::oci_spec::image::Digest;
7
7
use schemars:: JsonSchema ;
8
8
use serde:: { Deserialize , Serialize } ;
9
9
10
- use crate :: k8sapitypes;
10
+ use crate :: { k8sapitypes, status :: Slot } ;
11
11
12
12
const API_VERSION : & str = "org.containers.bootc/v1" ;
13
13
const KIND : & str = "BootcHost" ;
@@ -178,6 +178,24 @@ impl Host {
178
178
status : Default :: default ( ) ,
179
179
}
180
180
}
181
+
182
+ /// Filter out the requested slot
183
+ pub fn filter_to_slot ( & mut self , slot : Slot ) {
184
+ match slot {
185
+ Slot :: Staged => {
186
+ self . status . booted = None ;
187
+ self . status . rollback = None ;
188
+ }
189
+ Slot :: Booted => {
190
+ self . status . staged = None ;
191
+ self . status . rollback = None ;
192
+ }
193
+ Slot :: Rollback => {
194
+ self . status . staged = None ;
195
+ self . status . booted = None ;
196
+ }
197
+ }
198
+ }
181
199
}
182
200
183
201
impl Default for Host {
Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
293
293
0 | 1 => { }
294
294
o => anyhow:: bail!( "Unsupported format version: {o}" ) ,
295
295
} ;
296
- let host = if !ostree_booted ( ) ? {
296
+ let mut host = if !ostree_booted ( ) ? {
297
297
Default :: default ( )
298
298
} else {
299
299
let sysroot = super :: cli:: get_storage ( ) . await ?;
@@ -302,6 +302,12 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
302
302
host
303
303
} ;
304
304
305
+ // We could support querying the staged or rollback deployments
306
+ // here too, but it's not a common use case at the moment.
307
+ if opts. booted {
308
+ host. filter_to_slot ( Slot :: Booted ) ;
309
+ }
310
+
305
311
// If we're in JSON mode, then convert the ostree data into Rust-native
306
312
// structures that can be serialized.
307
313
// Filter to just the serializable status structures.
@@ -326,7 +332,7 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
326
332
}
327
333
328
334
#[ derive( Debug ) ]
329
- enum Slot {
335
+ pub enum Slot {
330
336
Staged ,
331
337
Booted ,
332
338
Rollback ,
You can’t perform that action at this time.
0 commit comments