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;
77use schemars:: JsonSchema ;
88use serde:: { Deserialize , Serialize } ;
99
10- use crate :: k8sapitypes;
10+ use crate :: { k8sapitypes, status :: Slot } ;
1111
1212const API_VERSION : & str = "org.containers.bootc/v1" ;
1313const KIND : & str = "BootcHost" ;
@@ -178,6 +178,24 @@ impl Host {
178178 status : Default :: default ( ) ,
179179 }
180180 }
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+ }
181199}
182200
183201impl 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<()> {
293293 0 | 1 => { }
294294 o => anyhow:: bail!( "Unsupported format version: {o}" ) ,
295295 } ;
296- let host = if !ostree_booted ( ) ? {
296+ let mut host = if !ostree_booted ( ) ? {
297297 Default :: default ( )
298298 } else {
299299 let sysroot = super :: cli:: get_storage ( ) . await ?;
@@ -302,6 +302,12 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
302302 host
303303 } ;
304304
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+
305311 // If we're in JSON mode, then convert the ostree data into Rust-native
306312 // structures that can be serialized.
307313 // Filter to just the serializable status structures.
@@ -326,7 +332,7 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
326332}
327333
328334#[ derive( Debug ) ]
329- enum Slot {
335+ pub enum Slot {
330336 Staged ,
331337 Booted ,
332338 Rollback ,
You can’t perform that action at this time.
0 commit comments