Skip to content

Commit

Permalink
Make logrotate_fs a generator (#1066)
Browse files Browse the repository at this point in the history
### What does this PR do?

This commit migrates logrotate_fs to be a generator and not a stand-alone binary. While I think it is interesting to consider logrotate_fs as a user defined generator that's more of a rig that needs to be developed than I would like to for this project.
  • Loading branch information
blt authored Oct 29, 2024
1 parent d33ceea commit 913c99b
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 233 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ COPY . /app
RUN cargo build --release --locked --bin lading

FROM docker.io/debian:bullseye-20240701-slim
RUN apt-get update && apt-get install -y libfuse3-dev=3.10.3-2 && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/lading /usr/bin/lading

# smoke test
Expand Down
13 changes: 12 additions & 1 deletion lading/src/generator/file_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//!

pub mod logrotate;
pub mod model;
pub mod logrotate_fs;
pub mod traditional;

use std::str;
Expand All @@ -31,6 +31,9 @@ pub enum Error {
/// Wrapper around [`logrotate::Error`].
#[error(transparent)]
Logrotate(#[from] logrotate::Error),
/// Wrapper around [`logrotate_fs::Error`].
#[error(transparent)]
LogrotateFs(#[from] logrotate_fs::Error),
}

/// Configuration of [`FileGen`]
Expand All @@ -42,6 +45,8 @@ pub enum Config {
Traditional(traditional::Config),
/// See [`logrotate::Config`].
Logrotate(logrotate::Config),
/// See [`logrotate_fs::Config`].
LogrotateFs(logrotate_fs::Config),
}

#[derive(Debug)]
Expand All @@ -54,6 +59,8 @@ pub enum FileGen {
Traditional(traditional::Server),
/// See [`logrotate::Server`] for details.
Logrotate(logrotate::Server),
/// See [`logrotate_fs::Server`] for details.
LogrotateFs(logrotate_fs::Server),
}

impl FileGen {
Expand All @@ -78,6 +85,9 @@ impl FileGen {
Self::Traditional(traditional::Server::new(general, c, shutdown)?)
}
Config::Logrotate(c) => Self::Logrotate(logrotate::Server::new(general, c, shutdown)?),
Config::LogrotateFs(c) => {
Self::LogrotateFs(logrotate_fs::Server::new(general, c, shutdown)?)
}
};
Ok(srv)
}
Expand All @@ -98,6 +108,7 @@ impl FileGen {
match self {
Self::Traditional(inner) => inner.spin().await?,
Self::Logrotate(inner) => inner.spin().await?,
Self::LogrotateFs(inner) => inner.spin().await?,
};

Ok(())
Expand Down
Loading

0 comments on commit 913c99b

Please sign in to comment.