Skip to content

Commit 8c09af7

Browse files
committed
status: Don't error out if not booted
For now, just print out nothing. This helps a future integration testing scenario. Signed-off-by: Colin Walters <[email protected]>
1 parent 522f8e6 commit 8c09af7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/src/status.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ impl DeploymentStatus {
8282
/// a more native Rust structure.
8383
fn get_deployments(
8484
sysroot: &SysrootLock,
85-
booted_deployment: &ostree::Deployment,
86-
booted: bool,
85+
booted_deployment: Option<&ostree::Deployment>,
86+
booted_only: bool,
8787
) -> Result<Vec<(ostree::Deployment, DeploymentStatus)>> {
88+
let deployment_is_booted = |d: &ostree::Deployment| -> bool {
89+
booted_deployment.as_ref().map_or(false, |b| d.equal(b))
90+
};
8891
sysroot
8992
.deployments()
9093
.into_iter()
91-
.filter(|deployment| !booted || deployment.equal(booted_deployment))
94+
.filter(|deployment| !booted_only || deployment_is_booted(deployment))
9295
.map(|deployment| -> Result<_> {
93-
let booted = deployment.equal(booted_deployment);
96+
let booted = deployment_is_booted(&deployment);
9497
let status = DeploymentStatus::from_deployment(&deployment, booted)?;
9598
Ok((deployment, status))
9699
})
@@ -101,9 +104,9 @@ fn get_deployments(
101104
pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
102105
let sysroot = super::cli::get_locked_sysroot().await?;
103106
let repo = &sysroot.repo().unwrap();
104-
let booted_deployment = &sysroot.require_booted_deployment()?;
107+
let booted_deployment = sysroot.booted_deployment();
105108

106-
let deployments = get_deployments(&sysroot, booted_deployment, opts.booted)?;
109+
let deployments = get_deployments(&sysroot, booted_deployment.as_ref(), opts.booted)?;
107110
// If we're in JSON mode, then convert the ostree data into Rust-native
108111
// structures that can be serialized.
109112
if opts.json {

0 commit comments

Comments
 (0)