Skip to content

Commit

Permalink
Merge pull request #187 from cgwalters/errcontext-status
Browse files Browse the repository at this point in the history
  • Loading branch information
jlebon committed Nov 7, 2023
2 parents 162088a + 05e0717 commit 4b3ad8e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::VecDeque;
use crate::spec::{BootEntry, Host, HostSpec, HostStatus, ImageStatus};
use crate::spec::{ImageReference, ImageSignature};
use anyhow::{Context, Result};
use fn_error_context::context;
use ostree::glib;
use ostree_container::OstreeImageReference;
use ostree_ext::container as ostree_container;
Expand Down Expand Up @@ -104,6 +105,7 @@ pub(crate) fn labels_of_config(
config.config().as_ref().and_then(|c| c.labels().as_ref())
}

#[context("Reading deployment metadata")]
fn boot_entry_from_deployment(
sysroot: &SysrootLock,
deployment: &ostree::Deployment,
Expand Down Expand Up @@ -183,6 +185,7 @@ pub(crate) fn get_status_require_booted(

/// Gather the ostree deployment objects, but also extract metadata from them into
/// a more native Rust structure.
#[context("Computing status")]
pub(crate) fn get_status(
sysroot: &SysrootLock,
booted_deployment: Option<&ostree::Deployment>,
Expand Down Expand Up @@ -217,16 +220,19 @@ pub(crate) fn get_status(
.staged
.as_ref()
.map(|d| boot_entry_from_deployment(sysroot, d))
.transpose()?;
.transpose()
.context("Staged deployment")?;
let booted = booted_deployment
.as_ref()
.map(|d| boot_entry_from_deployment(sysroot, d))
.transpose()?;
.transpose()
.context("Booted deployment")?;
let rollback = deployments
.rollback
.as_ref()
.map(|d| boot_entry_from_deployment(sysroot, d))
.transpose()?;
.transpose()
.context("Rollback deployment")?;
let spec = staged
.as_ref()
.or(booted.as_ref())
Expand Down

0 comments on commit 4b3ad8e

Please sign in to comment.