@@ -8,7 +8,7 @@ use anyhow::Result;
88use ostree_ext:: container:: Transport ;
99use ostree_ext:: oci_spec:: distribution:: Reference ;
1010use ostree_ext:: oci_spec:: image:: Digest ;
11- use ostree_ext:: { container:: OstreeImageReference , oci_spec} ;
11+ use ostree_ext:: { container:: OstreeImageReference , oci_spec, ostree :: DeploymentUnlockedState } ;
1212use schemars:: JsonSchema ;
1313use serde:: { Deserialize , Serialize } ;
1414
@@ -274,6 +274,83 @@ pub enum HostType {
274274 BootcHost ,
275275}
276276
277+ /// Details of an overlay filesystem: read-only or read/write, persistent or transient.
278+ #[ derive( Serialize , Deserialize , Copy , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
279+ #[ serde( rename_all = "camelCase" ) ]
280+ pub struct FilesystemOverlay {
281+ /// Whether the overlay is read-only or read/write
282+ pub access_mode : FilesystemOverlayAccessMode ,
283+ /// Whether the overlay will persist across reboots
284+ pub persistence : FilesystemOverlayPersistence ,
285+ }
286+
287+ /// The permissions mode of a /usr overlay
288+ #[ derive( Serialize , Deserialize , Copy , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
289+ #[ serde( rename_all = "camelCase" ) ]
290+ pub enum FilesystemOverlayAccessMode {
291+ /// The overlay is mounted read-only
292+ ReadOnly ,
293+ /// The overlay is mounted read/write
294+ ReadWrite ,
295+ }
296+
297+ impl Display for FilesystemOverlayAccessMode {
298+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
299+ match self {
300+ FilesystemOverlayAccessMode :: ReadOnly => write ! ( f, "read-only" ) ,
301+ FilesystemOverlayAccessMode :: ReadWrite => write ! ( f, "read/write" ) ,
302+ }
303+ }
304+ }
305+
306+ /// The persistence mode of a /usr overlay
307+ #[ derive( Serialize , Deserialize , Copy , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
308+ #[ serde( rename_all = "camelCase" ) ]
309+ pub enum FilesystemOverlayPersistence {
310+ /// Changes are temporary and will be lost on reboot
311+ Transient ,
312+ /// Changes persist across reboots
313+ Persistent ,
314+ }
315+
316+ impl Display for FilesystemOverlayPersistence {
317+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
318+ match self {
319+ FilesystemOverlayPersistence :: Transient => write ! ( f, "transient" ) ,
320+ FilesystemOverlayPersistence :: Persistent => write ! ( f, "persistent" ) ,
321+ }
322+ }
323+ }
324+
325+ pub ( crate ) fn deployment_unlocked_state_to_usr_overlay (
326+ state : DeploymentUnlockedState ,
327+ ) -> Option < FilesystemOverlay > {
328+ use FilesystemOverlayAccessMode :: * ;
329+ use FilesystemOverlayPersistence :: * ;
330+ match state {
331+ DeploymentUnlockedState :: None => None ,
332+ DeploymentUnlockedState :: Development => Some ( FilesystemOverlay {
333+ access_mode : ReadWrite ,
334+ persistence : Transient ,
335+ } ) ,
336+ DeploymentUnlockedState :: Hotfix => Some ( FilesystemOverlay {
337+ access_mode : ReadWrite ,
338+ persistence : Persistent ,
339+ } ) ,
340+ DeploymentUnlockedState :: Transient => Some ( FilesystemOverlay {
341+ access_mode : ReadOnly ,
342+ persistence : Transient ,
343+ } ) ,
344+ _ => None ,
345+ }
346+ }
347+
348+ impl Display for FilesystemOverlay {
349+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
350+ write ! ( f, "{}, {}" , self . persistence, self . access_mode)
351+ }
352+ }
353+
277354/// The status of the host system
278355#[ derive( Debug , Clone , Serialize , Default , Deserialize , PartialEq , Eq , JsonSchema ) ]
279356#[ serde( rename_all = "camelCase" ) ]
@@ -295,6 +372,9 @@ pub struct HostStatus {
295372 /// The detected type of system
296373 #[ serde( rename = "type" ) ]
297374 pub ty : Option < HostType > ,
375+
376+ /// The state of the overlay mounted on /usr
377+ pub usr_overlay : Option < FilesystemOverlay > ,
298378}
299379
300380pub ( crate ) struct DeploymentEntry < ' a > {
0 commit comments