Skip to content

Commit 7ed2068

Browse files
committed
Rename imgstorage/Storage -> CStorage
Previously we had two different `Storage` structs, this ensures that the main one is primary and `CStorage` is secondary. This should be less confusing. Signed-off-by: Colin Walters <[email protected]>
1 parent 7167381 commit 7ed2068

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

crates/lib/src/boundimage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use fn_error_context::context;
1313
use ostree_ext::containers_image_proxy;
1414
use ostree_ext::ostree::Deployment;
1515

16-
use crate::imgstorage::PullMode;
16+
use crate::imgstorage::{CStorage, PullMode};
1717
use crate::store::Storage;
1818

1919
/// The path in a root for bound images; this directory should only contain
@@ -158,7 +158,7 @@ pub(crate) async fn pull_images(
158158

159159
#[context("Pulling bound images")]
160160
pub(crate) async fn pull_images_impl(
161-
imgstore: &crate::imgstorage::Storage,
161+
imgstore: &CStorage,
162162
bound_images: Vec<crate::boundimage::BoundImage>,
163163
) -> Result<()> {
164164
let n = bound_images.len();

crates/lib/src/image.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use serde::Serialize;
1414
use crate::{
1515
boundimage::query_bound_images,
1616
cli::{ImageListFormat, ImageListType},
17-
imgstorage::ensure_floating_c_storage_initialized,
17+
imgstorage::{ensure_floating_c_storage_initialized, CStorage},
1818
};
1919

2020
/// The name of the image we push to containers-storage if nothing is specified.
@@ -172,7 +172,7 @@ pub(crate) async fn push_entrypoint(source: Option<&str>, target: Option<&str>)
172172
/// Thin wrapper for invoking `podman image <X>` but set up for our internal
173173
/// image store (as distinct from /var/lib/containers default).
174174
pub(crate) async fn imgcmd_entrypoint(
175-
storage: &crate::imgstorage::Storage,
175+
storage: &CStorage,
176176
arg: &str,
177177
args: &[std::ffi::OsString],
178178
) -> std::result::Result<(), anyhow::Error> {

crates/lib/src/imgstorage.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
//! # bootc-managed container storage
1+
//! # bootc-managed instance of containers-storage:
22
//!
3-
//! The default storage for this project uses ostree, canonically storing all of its state in
4-
//! `/sysroot/ostree`.
3+
//! The backend for podman and other tools is known as `container-storage:`,
4+
//! with a canonical instance that lives in `/var/lib/containers`.
55
//!
6-
//! This containers-storage: which canonically lives in `/sysroot/ostree/bootc`.
6+
//! This is a `containers-storage:` instance` which is owned by bootc and
7+
//! is stored at `/sysroot/ostree/bootc`.
8+
//!
9+
//! At the current time, this is only used for Logically Bound Images.
710
811
use std::collections::HashSet;
912
use std::io::Seek;
@@ -43,7 +46,9 @@ pub(crate) const SUBPATH: &str = "storage";
4346
/// The path to the "runroot" with transient runtime state; this is
4447
/// relative to the /run directory
4548
const RUNROOT: &str = "bootc/storage";
46-
pub(crate) struct Storage {
49+
50+
/// A bootc-owned instance of `containers-storage:`.
51+
pub(crate) struct CStorage {
4752
/// The root directory
4853
sysroot: Dir,
4954
/// The location of container storage
@@ -147,7 +152,7 @@ pub(crate) fn ensure_floating_c_storage_initialized() {
147152
}
148153
}
149154

150-
impl Storage {
155+
impl CStorage {
151156
/// Create a `podman image` Command instance prepared to operate on our alternative
152157
/// root.
153158
pub(crate) fn new_image_cmd(&self) -> Result<Command> {
@@ -380,5 +385,5 @@ impl Storage {
380385
#[cfg(test)]
381386
mod tests {
382387
use super::*;
383-
static_assertions::assert_not_impl_any!(Storage: Sync);
388+
static_assertions::assert_not_impl_any!(CStorage: Sync);
384389
}

crates/lib/src/install/completion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use ostree_ext::{gio, ostree};
1414
use rustix::fs::Mode;
1515
use rustix::fs::OFlags;
1616

17+
use crate::imgstorage::CStorage;
1718
use crate::utils::deployment_fd;
1819

1920
use super::config;
@@ -297,8 +298,7 @@ pub(crate) async fn impl_completion(
297298

298299
// When we're run through ostree, we only lazily initialize the podman storage to avoid
299300
// having a hard dependency on it.
300-
let imgstorage =
301-
&crate::imgstorage::Storage::create(&sysroot_dir, &rundir, sepolicy.as_ref())?;
301+
let imgstorage = &CStorage::create(&sysroot_dir, &rundir, sepolicy.as_ref())?;
302302
crate::boundimage::pull_images_impl(imgstorage, bound_images)
303303
.await
304304
.context("pulling bound images")?;

crates/lib/src/store/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use ostree_ext::ostree;
3030
use ostree_ext::sysroot::SysrootLock;
3131
use rustix::fs::Mode;
3232

33+
use crate::imgstorage::CStorage;
3334
use crate::lsm;
3435
use crate::spec::ImageStatus;
3536
use crate::utils::deployment_fd;
@@ -60,7 +61,7 @@ pub(crate) struct Storage {
6061
/// The composefs storage
6162
composefs: OnceCell<Arc<ComposefsRepository>>,
6263
/// The containers-image storage used foR LBIs
63-
imgstore: OnceCell<crate::imgstorage::Storage>,
64+
imgstore: OnceCell<CStorage>,
6465

6566
/// Our runtime state
6667
run: Dir,
@@ -113,7 +114,7 @@ impl Storage {
113114
}
114115

115116
/// Access the image storage; will automatically initialize it if necessary.
116-
pub(crate) fn get_ensure_imgstore(&self) -> Result<&crate::imgstorage::Storage> {
117+
pub(crate) fn get_ensure_imgstore(&self) -> Result<&CStorage> {
117118
if let Some(imgstore) = self.imgstore.get() {
118119
return Ok(imgstore);
119120
}
@@ -136,8 +137,7 @@ impl Storage {
136137

137138
tracing::trace!("sepolicy in get_ensure_imgstore: {sepolicy:?}");
138139

139-
let imgstore =
140-
crate::imgstorage::Storage::create(&sysroot_dir, &self.run, sepolicy.as_ref())?;
140+
let imgstore = CStorage::create(&sysroot_dir, &self.run, sepolicy.as_ref())?;
141141
Ok(self.imgstore.get_or_init(|| imgstore))
142142
}
143143

0 commit comments

Comments
 (0)