From 18bd2d9c5fada9b4a747bb6b0092a77aa3f805e7 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 9 Nov 2024 08:16:24 +0100 Subject: [PATCH] chores: moved dive to bin directory --- src/{main.rs => bin/dive.rs} | 20 +++++--------------- src/embedded_image.rs | 2 +- src/lib.rs | 10 ++++++++++ src/pid_lookup.rs | 2 +- src/shared_mount.rs | 3 ++- 5 files changed, 19 insertions(+), 18 deletions(-) rename src/{main.rs => bin/dive.rs} (96%) create mode 100644 src/lib.rs diff --git a/src/main.rs b/src/bin/dive.rs similarity index 96% rename from src/main.rs rename to src/bin/dive.rs index 5e319a1..c5e2a3c 100644 --- a/src/main.rs +++ b/src/bin/dive.rs @@ -15,21 +15,11 @@ use rustix::{ runtime::{fork, Fork}, }; -mod base_image; -mod namespaces; -mod overlay; -mod pid_file; -mod pid_lookup; -mod shared_mount; - -#[cfg(feature = "embedded_image")] -mod embedded_image; - -use base_image::*; -use namespaces::*; -use overlay::*; -use pid_lookup::*; -use shared_mount::*; +use dive::base_image::*; +use dive::namespaces::*; +use dive::overlay::*; +use dive::pid_lookup::*; +use dive::shared_mount::*; const APP_NAME: &str = "dive"; const IMG_DIR: &str = "base-img"; diff --git a/src/embedded_image.rs b/src/embedded_image.rs index aa5b834..73cb401 100644 --- a/src/embedded_image.rs +++ b/src/embedded_image.rs @@ -4,7 +4,7 @@ use anyhow::Result; use image_builder::progress_bar; use liblzma::read::XzDecoder; -use crate::install_base_image_from_reader; +use crate::base_image::install_base_image_from_reader; pub fn install_base_image

(dest: P) -> Result<()> where diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..f820f7b --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,10 @@ +pub mod base_image; +pub mod namespaces; +pub mod overlay; +pub mod pid_lookup; +pub mod shared_mount; + +#[cfg(feature = "embedded_image")] +mod embedded_image; + +mod pid_file; diff --git a/src/pid_lookup.rs b/src/pid_lookup.rs index 035a9a8..bc84fa0 100644 --- a/src/pid_lookup.rs +++ b/src/pid_lookup.rs @@ -103,7 +103,7 @@ const _RUNTIMES: &[ContainerRuntime] = &[ }, ]; -pub(crate) fn pid_lookup(value: &str) -> Option { +pub fn pid_lookup(value: &str) -> Option { if let Ok(pid) = value.parse::() { return Some(pid); }; diff --git a/src/shared_mount.rs b/src/shared_mount.rs index 3656c0e..852dc26 100644 --- a/src/shared_mount.rs +++ b/src/shared_mount.rs @@ -17,7 +17,8 @@ use rustix::{ }, }; -use crate::{pid_file::PidFile, OverlayBuilder, OverlayMount}; +use crate::overlay::{OverlayBuilder, OverlayMount}; +use crate::pid_file::PidFile; pub struct SharedMount { _pid_file: PidFile,