Skip to content

Commit 89aacb7

Browse files
committed
Switch a few Task users to direct Command
I never intended the `Task` abstraction to be "the one way to run subprocesses in bootc"...let's stop using it where: - We're using `.quiet()` by default so we're not printing the description anyways, which is the *main* thing Task does - We want to parse JSON, where we have a nice new helper Signed-off-by: Colin Walters <[email protected]>
1 parent 3e89f8a commit 89aacb7

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

lib/src/mount.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
//! Helpers for interacting with mountpoints
22
3-
use anyhow::{anyhow, Context, Result};
3+
use std::process::Command;
4+
5+
use anyhow::{anyhow, Result};
46
use camino::Utf8Path;
57
use fn_error_context::context;
68
use serde::Deserialize;
79

8-
use crate::task::Task;
10+
use crate::{cmdutils::CommandRunExt, task::Task};
911

1012
#[derive(Deserialize, Debug)]
1113
#[serde(rename_all = "kebab-case")]
@@ -26,8 +28,7 @@ pub(crate) struct Findmnt {
2628
}
2729

2830
fn run_findmnt(args: &[&str], path: &str) -> Result<Filesystem> {
29-
let desc = format!("Inspecting {path}");
30-
let o = Task::new(desc, "findmnt")
31+
let o: Findmnt = Command::new("findmnt")
3132
.args([
3233
"-J",
3334
"-v",
@@ -36,9 +37,7 @@ fn run_findmnt(args: &[&str], path: &str) -> Result<Filesystem> {
3637
])
3738
.args(args)
3839
.arg(path)
39-
.quiet()
40-
.read()?;
41-
let o: Findmnt = serde_json::from_str(&o).context("Parsing findmnt output")?;
40+
.run_and_parse_json()?;
4241
o.filesystems
4342
.into_iter()
4443
.next()

lib/src/podman.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use camino::Utf8Path;
33
use cap_std_ext::cap_std::fs::Dir;
44
use serde::Deserialize;
55

6-
use crate::task::Task;
7-
86
/// Where we look inside our container to find our own image
97
/// for use with `bootc install`.
108
pub(crate) const CONTAINER_STORAGE: &str = "/var/lib/containers";
@@ -26,12 +24,10 @@ pub(crate) struct ImageListEntry {
2624
/// Given an image ID, return its manifest digest
2725
#[cfg(feature = "install")]
2826
pub(crate) fn imageid_to_digest(imgid: &str) -> Result<String> {
29-
use crate::install::run_in_host_mountns;
30-
let out = Task::new_cmd("podman inspect", run_in_host_mountns("podman"))
27+
use crate::cmdutils::CommandRunExt;
28+
let o: Vec<Inspect> = crate::install::run_in_host_mountns("podman")
3129
.args(["inspect", imgid])
32-
.quiet()
33-
.read()?;
34-
let o: Vec<Inspect> = serde_json::from_str(&out)?;
30+
.run_and_parse_json()?;
3531
let i = o
3632
.into_iter()
3733
.next()

0 commit comments

Comments
 (0)