Skip to content

Commit d7c3f9f

Browse files
committed
Split off an internal "bootc-utils" crate
In general the codebase is starting to get to the size where some internal crates make sense. Let's start with the inevitable catchall "utils" crate which starts off just holding our helper traits for subprocesses. Signed-off-by: Colin Walters <[email protected]>
1 parent 2aa8c6a commit d7c3f9f

File tree

12 files changed

+56
-12
lines changed

12 files changed

+56
-12
lines changed

Cargo.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ include = ["/src", "LICENSE-APACHE", "LICENSE-MIT"]
1717
anstream = "0.6.13"
1818
anstyle = "1.0.6"
1919
anyhow = { workspace = true }
20+
bootc-utils = { path = "../utils" }
2021
camino = { workspace = true, features = ["serde1"] }
2122
ostree-ext = { version = "0.14.0" }
2223
chrono = { workspace = true, features = ["serde"] }

lib/src/blockdev.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use fn_error_context::context;
1010
use regex::Regex;
1111
use serde::Deserialize;
1212

13-
use crate::cmdutils::CommandRunExt;
1413
use crate::install::run_in_host_mountns;
1514
use crate::task::Task;
15+
use bootc_utils::CommandRunExt;
1616

1717
#[derive(Debug, Deserialize)]
1818
struct DevicesOutput {

lib/src/image.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
//! APIs for operating on container images in the bootc storage.
44
55
use anyhow::{Context, Result};
6+
use bootc_utils::CommandRunExt;
67
use fn_error_context::context;
78
use ostree_ext::container::{ImageReference, Transport};
89

9-
use crate::{cmdutils::CommandRunExt, imgstorage::Storage};
10+
use crate::imgstorage::Storage;
1011

1112
/// The name of the image we push to containers-storage if nothing is specified.
1213
const IMAGE_DEFAULT: &str = "localhost/bootc";

lib/src/imgstorage.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::process::{Command, Stdio};
1212
use std::sync::Arc;
1313

1414
use anyhow::{Context, Result};
15+
use bootc_utils::{AsyncCommandRunExt, CommandRunExt, ExitStatusExt};
1516
use camino::Utf8Path;
1617
use cap_std_ext::cap_std;
1718
use cap_std_ext::cap_std::fs::Dir;
@@ -22,8 +23,6 @@ use fn_error_context::context;
2223
use std::os::fd::OwnedFd;
2324
use tokio::process::Command as AsyncCommand;
2425

25-
use crate::cmdutils::{AsyncCommandRunExt, CommandRunExt, ExitStatusExt};
26-
2726
// Pass only 100 args at a time just to avoid potentially overflowing argument
2827
// vectors; not that this should happen in reality, but just in case.
2928
const SUBCMD_ARGV_CHUNKING: usize = 100;

lib/src/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use std::time::Duration;
2222

2323
use anyhow::Ok;
2424
use anyhow::{anyhow, Context, Result};
25+
use bootc_utils::CommandRunExt;
2526
use camino::Utf8Path;
2627
use camino::Utf8PathBuf;
2728
use cap_std::fs::{Dir, MetadataExt};
@@ -43,7 +44,6 @@ use rustix::fs::{FileTypeExt, MetadataExt as _};
4344
use serde::{Deserialize, Serialize};
4445

4546
use self::baseline::InstallBlockDeviceOpts;
46-
use crate::cmdutils::CommandRunExt;
4747
use crate::containerenv::ContainerExecutionInfo;
4848
use crate::mount::Filesystem;
4949
use crate::spec::ImageReference;

lib/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
mod boundimage;
1212
pub mod cli;
13-
mod cmdutils;
1413
pub(crate) mod deploy;
1514
pub(crate) mod generator;
1615
mod image;

lib/src/mount.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
use std::process::Command;
44

55
use anyhow::{anyhow, Result};
6+
use bootc_utils::CommandRunExt;
67
use camino::Utf8Path;
78
use fn_error_context::context;
89
use serde::Deserialize;
910

10-
use crate::{cmdutils::CommandRunExt, task::Task};
11+
use crate::task::Task;
1112

1213
#[derive(Deserialize, Debug)]
1314
#[serde(rename_all = "kebab-case")]

lib/src/podman.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(crate) struct ImageListEntry {
2424
/// Given an image ID, return its manifest digest
2525
#[cfg(feature = "install")]
2626
pub(crate) fn imageid_to_digest(imgid: &str) -> Result<String> {
27-
use crate::cmdutils::CommandRunExt;
27+
use bootc_utils::CommandRunExt;
2828
let o: Vec<Inspect> = crate::install::run_in_host_mountns("podman")
2929
.args(["inspect", imgid])
3030
.run_and_parse_json()?;

utils/Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "bootc-utils"
3+
publish = false
4+
version = "0.0.0"
5+
edition = "2021"
6+
license = "MIT OR Apache-2.0"
7+
repository = "https://github.com/containers/bootc"
8+
9+
[dependencies]
10+
anyhow = { workspace = true }
11+
serde = { workspace = true, features = ["derive"] }
12+
serde_json = { workspace = true }
13+
tempfile = { workspace = true }
14+
tracing = { workspace = true }
15+
tokio = { workspace = true, features = ["process"] }
16+
17+
[dev-dependencies]
18+
similar-asserts = { version = "1.5.0" }
19+
static_assertions = "1.1.0"
20+
21+
[lints]
22+
workspace = true

0 commit comments

Comments
 (0)