refactor: rename plugin features with type prefix for consistency
- Plugin features now use type_ prefix (meta_magic, filter_grep, etc.) - Added meta_all_musl and filter_all_musl for MUSL-compatible builds - grep filter plugin made optional via filter_grep feature flag - Removed regex crate from grep-related code, uses strip_prefix instead - Updated CHANGELOG.md with breaking change documentation
This commit is contained in:
14
CHANGELOG.md
14
CHANGELOG.md
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- New `filter_grep` feature to optionally include the grep filter plugin (regex-based line filtering). Disabling this feature removes the `regex` crate and its ~800 KiB dependency stack from the binary.
|
||||||
|
- New `meta_all_musl` feature for all MUSL-compatible meta plugins (excludes `meta_magic` which requires libmagic)
|
||||||
|
- New `filter_all_musl` feature for all MUSL-compatible filter plugins
|
||||||
- Database index on `items(ts)` column for faster ORDER BY sorting
|
- Database index on `items(ts)` column for faster ORDER BY sorting
|
||||||
- Server API `ItemInfo` now includes `file_size` — actual filesystem-reported size of the item data file
|
- Server API `ItemInfo` now includes `file_size` — actual filesystem-reported size of the item data file
|
||||||
|
|
||||||
@@ -23,6 +26,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Removed `once_cell` crate (replaced with `std::sync::LazyLock` from Rust 1.80)
|
- Removed `once_cell` crate (replaced with `std::sync::LazyLock` from Rust 1.80)
|
||||||
- Removed `lazy_static` crate (replaced with `std::sync::LazyLock`)
|
- Removed `lazy_static` crate (replaced with `std::sync::LazyLock`)
|
||||||
|
|
||||||
|
### Breaking
|
||||||
|
|
||||||
|
- Plugin feature flags renamed with type prefix for consistency:
|
||||||
|
- `magic` → `meta_magic`
|
||||||
|
- `infer` → `meta_infer`
|
||||||
|
- `tree_magic_mini` → `meta_tree_magic_mini`
|
||||||
|
- `tokens` → `meta_tokens`
|
||||||
|
- `grep` → `filter_grep`
|
||||||
|
- `all-meta-plugins` → `meta_all`
|
||||||
|
- `all-filter-plugins` → `filter_all`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- CLI help text typo: "metatdata" → "metadata" in `--get` and `--info` descriptions
|
- CLI help text typo: "metatdata" → "metadata" in `--get` and `--info` descriptions
|
||||||
|
|||||||
32
Cargo.toml
32
Cargo.toml
@@ -46,7 +46,7 @@ tree_magic_mini = { version = "3.2", optional = true }
|
|||||||
nix = { version = "0.30", features = ["fs", "process"] }
|
nix = { version = "0.30", features = ["fs", "process"] }
|
||||||
comfy-table = "7.2"
|
comfy-table = "7.2"
|
||||||
pwhash = "1.0"
|
pwhash = "1.0"
|
||||||
regex = "1.10"
|
regex = { version = "1.10", optional = true }
|
||||||
ringbuf = "0.4"
|
ringbuf = "0.4"
|
||||||
rusqlite = { version = "0.37", features = ["bundled", "array", "chrono"] }
|
rusqlite = { version = "0.37", features = ["bundled", "array", "chrono"] }
|
||||||
rusqlite_migration = "2.3"
|
rusqlite_migration = "2.3"
|
||||||
@@ -85,14 +85,15 @@ tiktoken-rs = { version = "0.9", optional = true }
|
|||||||
tempfile = "3.3"
|
tempfile = "3.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Default features include core compression engines and swagger UI
|
# Default features include core compression engines plugins that support MUSL
|
||||||
default = [
|
default = [
|
||||||
"client",
|
"client",
|
||||||
"gzip",
|
"gzip",
|
||||||
"infer",
|
"filter_grep",
|
||||||
|
"meta_infer",
|
||||||
"lz4",
|
"lz4",
|
||||||
"tokens",
|
"meta_tokens",
|
||||||
"tree_magic_mini",
|
"meta_tree_magic_mini",
|
||||||
"zstd"
|
"zstd"
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -106,14 +107,18 @@ bzip2 = []
|
|||||||
xz = []
|
xz = []
|
||||||
zstd = ["dep:zstd"]
|
zstd = ["dep:zstd"]
|
||||||
|
|
||||||
# Plugin features (meta and filter)
|
# Meta plugin features
|
||||||
all-meta-plugins = ["dep:magic", "dep:infer", "dep:tree_magic_mini"]
|
meta_magic = ["dep:magic"]
|
||||||
all-filter-plugins = []
|
meta_infer = ["dep:infer"]
|
||||||
|
meta_tree_magic_mini = ["dep:tree_magic_mini"]
|
||||||
|
meta_tokens = ["dep:tiktoken-rs"]
|
||||||
|
meta_all = ["meta_magic", "meta_infer", "meta_tree_magic_mini", "meta_tokens"]
|
||||||
|
meta_all_musl = ["meta_infer", "meta_tree_magic_mini", "meta_tokens"]
|
||||||
|
|
||||||
# Individual plugin features
|
# Filter plugin features
|
||||||
magic = ["dep:magic"]
|
filter_grep = ["dep:regex"]
|
||||||
infer = ["dep:infer"]
|
filter_all = ["filter_grep"]
|
||||||
tree_magic_mini = ["dep:tree_magic_mini"]
|
filter_all_musl = ["filter_grep"]
|
||||||
|
|
||||||
# Swagger UI feature
|
# Swagger UI feature
|
||||||
swagger = ["dep:utoipa-swagger-ui"]
|
swagger = ["dep:utoipa-swagger-ui"]
|
||||||
@@ -121,8 +126,5 @@ swagger = ["dep:utoipa-swagger-ui"]
|
|||||||
# Client feature (HTTP client for remote server)
|
# Client feature (HTTP client for remote server)
|
||||||
client = ["dep:ureq", "dep:os_pipe"]
|
client = ["dep:ureq", "dep:os_pipe"]
|
||||||
|
|
||||||
# Token counting feature (LLM token support via tiktoken)
|
|
||||||
tokens = ["dep:tiktoken-rs"]
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.9"
|
rand = "0.9"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use std::io::{Read, Result, Write};
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use strum::EnumString;
|
use strum::EnumString;
|
||||||
|
|
||||||
|
#[cfg(feature = "filter_grep")]
|
||||||
pub mod grep;
|
pub mod grep;
|
||||||
/// Filter plugin module for processing input streams.
|
/// Filter plugin module for processing input streams.
|
||||||
///
|
///
|
||||||
@@ -16,7 +17,7 @@ pub mod grep;
|
|||||||
/// ```
|
/// ```
|
||||||
/// # use std::io::{Read, Write};
|
/// # use std::io::{Read, Write};
|
||||||
/// # use keep::filter_plugin::parse_filter_string;
|
/// # use keep::filter_plugin::parse_filter_string;
|
||||||
/// let mut chain = parse_filter_string("head_lines(10)|grep(pattern=error)")?;
|
/// let mut chain = parse_filter_string("head_lines(10)|tail_lines(5)")?;
|
||||||
/// # let mut reader: &mut dyn Read = &mut std::io::empty();
|
/// # let mut reader: &mut dyn Read = &mut std::io::empty();
|
||||||
/// # let mut writer: Vec<u8> = Vec::new();
|
/// # let mut writer: Vec<u8> = Vec::new();
|
||||||
/// # chain.filter(&mut reader, &mut writer)?;
|
/// # chain.filter(&mut reader, &mut writer)?;
|
||||||
@@ -26,12 +27,13 @@ pub mod head;
|
|||||||
pub mod skip;
|
pub mod skip;
|
||||||
pub mod strip_ansi;
|
pub mod strip_ansi;
|
||||||
pub mod tail;
|
pub mod tail;
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
pub mod tokens;
|
pub mod tokens;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
#[cfg(feature = "filter_grep")]
|
||||||
pub use grep::GrepFilter;
|
pub use grep::GrepFilter;
|
||||||
pub use head::{HeadBytesFilter, HeadLinesFilter};
|
pub use head::{HeadBytesFilter, HeadLinesFilter};
|
||||||
pub use skip::{SkipBytesFilter, SkipLinesFilter};
|
pub use skip::{SkipBytesFilter, SkipLinesFilter};
|
||||||
@@ -199,13 +201,14 @@ pub enum FilterType {
|
|||||||
TailLines,
|
TailLines,
|
||||||
SkipBytes,
|
SkipBytes,
|
||||||
SkipLines,
|
SkipLines,
|
||||||
|
#[cfg(feature = "filter_grep")]
|
||||||
Grep,
|
Grep,
|
||||||
StripAnsi,
|
StripAnsi,
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
HeadTokens,
|
HeadTokens,
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
SkipTokens,
|
SkipTokens,
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
TailTokens,
|
TailTokens,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,9 +359,8 @@ impl FilterChain {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use keep::filter_plugin::{FilterChain, GrepFilter};
|
/// # use keep::filter_plugin::FilterChain;
|
||||||
/// let mut chain = FilterChain::new();
|
/// let mut chain = FilterChain::new();
|
||||||
/// chain.add_plugin(Box::new(GrepFilter::new("error".to_string()).unwrap()));
|
|
||||||
/// ```
|
/// ```
|
||||||
pub fn add_plugin(&mut self, plugin: Box<dyn FilterPlugin>) {
|
pub fn add_plugin(&mut self, plugin: Box<dyn FilterPlugin>) {
|
||||||
self.plugins.push(plugin);
|
self.plugins.push(plugin);
|
||||||
@@ -535,6 +537,7 @@ fn create_filter_with_options(
|
|||||||
// Get the default options for this filter type by creating a temporary instance
|
// Get the default options for this filter type by creating a temporary instance
|
||||||
// To do this, we need to create a default instance of the appropriate filter
|
// To do this, we need to create a default instance of the appropriate filter
|
||||||
let option_defs = match filter_type {
|
let option_defs = match filter_type {
|
||||||
|
#[cfg(feature = "filter_grep")]
|
||||||
FilterType::Grep => grep::GrepFilter::new("".to_string())?.options(),
|
FilterType::Grep => grep::GrepFilter::new("".to_string())?.options(),
|
||||||
FilterType::HeadBytes => head::HeadBytesFilter::new(0).options(),
|
FilterType::HeadBytes => head::HeadBytesFilter::new(0).options(),
|
||||||
FilterType::HeadLines => head::HeadLinesFilter::new(0).options(),
|
FilterType::HeadLines => head::HeadLinesFilter::new(0).options(),
|
||||||
@@ -543,11 +546,11 @@ fn create_filter_with_options(
|
|||||||
FilterType::SkipBytes => skip::SkipBytesFilter::new(0).options(),
|
FilterType::SkipBytes => skip::SkipBytesFilter::new(0).options(),
|
||||||
FilterType::SkipLines => skip::SkipLinesFilter::new(0).options(),
|
FilterType::SkipLines => skip::SkipLinesFilter::new(0).options(),
|
||||||
FilterType::StripAnsi => strip_ansi::StripAnsiFilter::new().options(),
|
FilterType::StripAnsi => strip_ansi::StripAnsiFilter::new().options(),
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
FilterType::HeadTokens => tokens::HeadTokensFilter::new(0).options(),
|
FilterType::HeadTokens => tokens::HeadTokensFilter::new(0).options(),
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
FilterType::SkipTokens => tokens::SkipTokensFilter::new(0).options(),
|
FilterType::SkipTokens => tokens::SkipTokensFilter::new(0).options(),
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
FilterType::TailTokens => tokens::TailTokensFilter::new(0).options(),
|
FilterType::TailTokens => tokens::TailTokensFilter::new(0).options(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -617,6 +620,7 @@ fn create_specific_filter(
|
|||||||
options: &HashMap<String, serde_json::Value>,
|
options: &HashMap<String, serde_json::Value>,
|
||||||
) -> Result<Box<dyn FilterPlugin>> {
|
) -> Result<Box<dyn FilterPlugin>> {
|
||||||
match filter_type {
|
match filter_type {
|
||||||
|
#[cfg(feature = "filter_grep")]
|
||||||
FilterType::Grep => {
|
FilterType::Grep => {
|
||||||
let pattern = options
|
let pattern = options
|
||||||
.get("pattern")
|
.get("pattern")
|
||||||
@@ -717,7 +721,7 @@ fn create_specific_filter(
|
|||||||
}
|
}
|
||||||
Ok(Box::new(strip_ansi::StripAnsiFilter::new()))
|
Ok(Box::new(strip_ansi::StripAnsiFilter::new()))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
FilterType::HeadTokens => {
|
FilterType::HeadTokens => {
|
||||||
let count = options
|
let count = options
|
||||||
.get("count")
|
.get("count")
|
||||||
@@ -735,7 +739,7 @@ fn create_specific_filter(
|
|||||||
f.encoding = encoding;
|
f.encoding = encoding;
|
||||||
Ok(Box::new(f))
|
Ok(Box::new(f))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
FilterType::SkipTokens => {
|
FilterType::SkipTokens => {
|
||||||
let count = options
|
let count = options
|
||||||
.get("count")
|
.get("count")
|
||||||
@@ -753,7 +757,7 @@ fn create_specific_filter(
|
|||||||
f.encoding = encoding;
|
f.encoding = encoding;
|
||||||
Ok(Box::new(f))
|
Ok(Box::new(f))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
FilterType::TailTokens => {
|
FilterType::TailTokens => {
|
||||||
let count = options
|
let count = options
|
||||||
.get("count")
|
.get("count")
|
||||||
@@ -774,7 +778,7 @@ fn create_specific_filter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
fn parse_encoding_option(
|
fn parse_encoding_option(
|
||||||
options: &std::collections::HashMap<String, serde_json::Value>,
|
options: &std::collections::HashMap<String, serde_json::Value>,
|
||||||
) -> (crate::tokenizer::TokenEncoding, crate::tokenizer::Tokenizer) {
|
) -> (crate::tokenizer::TokenEncoding, crate::tokenizer::Tokenizer) {
|
||||||
|
|||||||
17
src/lib.rs
17
src/lib.rs
@@ -45,7 +45,7 @@ pub mod services;
|
|||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
pub mod client;
|
pub mod client;
|
||||||
|
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
pub mod tokenizer;
|
pub mod tokenizer;
|
||||||
|
|
||||||
// Re-export Args struct for library usage
|
// Re-export Args struct for library usage
|
||||||
@@ -56,9 +56,12 @@ pub use services::CoreError;
|
|||||||
|
|
||||||
// Import all filter plugins to ensure they register themselves
|
// Import all filter plugins to ensure they register themselves
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use filter_plugin::{grep, head, skip, strip_ansi, tail};
|
#[cfg(feature = "filter_grep")]
|
||||||
|
use filter_plugin::grep;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use filter_plugin::{head, skip, strip_ansi, tail};
|
||||||
|
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use filter_plugin::tokens as token_filters;
|
use filter_plugin::tokens as token_filters;
|
||||||
|
|
||||||
@@ -66,19 +69,19 @@ use crate::meta_plugin::{
|
|||||||
cwd, digest, env, exec, hostname, keep_pid, read_rate, read_time, shell, shell_pid, user,
|
cwd, digest, env, exec, hostname, keep_pid, read_rate, read_time, shell, shell_pid, user,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "magic")]
|
#[cfg(feature = "meta_magic")]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::meta_plugin::magic_file;
|
use crate::meta_plugin::magic_file;
|
||||||
|
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::meta_plugin::tokens;
|
use crate::meta_plugin::tokens;
|
||||||
|
|
||||||
#[cfg(feature = "infer")]
|
#[cfg(feature = "meta_infer")]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::meta_plugin::infer_plugin;
|
use crate::meta_plugin::infer_plugin;
|
||||||
|
|
||||||
#[cfg(feature = "tree_magic_mini")]
|
#[cfg(feature = "meta_tree_magic_mini")]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::meta_plugin::tree_magic_mini;
|
use crate::meta_plugin::tree_magic_mini;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#[cfg(feature = "magic")]
|
#[cfg(feature = "meta_magic")]
|
||||||
use magic::{Cookie, CookieFlags};
|
use magic::{Cookie, CookieFlags};
|
||||||
#[cfg(not(feature = "magic"))]
|
#[cfg(not(feature = "meta_magic"))]
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
@@ -16,12 +16,12 @@ use crate::meta_plugin::{
|
|||||||
// separate cookies can be used from different threads concurrently without
|
// separate cookies can be used from different threads concurrently without
|
||||||
// synchronization. Using thread_local! avoids unsafe impl Send since the
|
// synchronization. Using thread_local! avoids unsafe impl Send since the
|
||||||
// storage is inherently !Send.
|
// storage is inherently !Send.
|
||||||
#[cfg(feature = "magic")]
|
#[cfg(feature = "meta_magic")]
|
||||||
thread_local! {
|
thread_local! {
|
||||||
static MAGIC_COOKIE: std::cell::RefCell<Option<Cookie>> = const { std::cell::RefCell::new(None) };
|
static MAGIC_COOKIE: std::cell::RefCell<Option<Cookie>> = const { std::cell::RefCell::new(None) };
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "magic")]
|
#[cfg(feature = "meta_magic")]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MagicFileMetaPluginImpl {
|
pub struct MagicFileMetaPluginImpl {
|
||||||
buffer: Vec<u8>,
|
buffer: Vec<u8>,
|
||||||
@@ -30,7 +30,7 @@ pub struct MagicFileMetaPluginImpl {
|
|||||||
base: BaseMetaPlugin,
|
base: BaseMetaPlugin,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "magic")]
|
#[cfg(feature = "meta_magic")]
|
||||||
impl MagicFileMetaPluginImpl {
|
impl MagicFileMetaPluginImpl {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||||
@@ -113,7 +113,7 @@ impl MagicFileMetaPluginImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "magic")]
|
#[cfg(feature = "meta_magic")]
|
||||||
impl MetaPlugin for MagicFileMetaPluginImpl {
|
impl MetaPlugin for MagicFileMetaPluginImpl {
|
||||||
fn is_finalized(&self) -> bool {
|
fn is_finalized(&self) -> bool {
|
||||||
self.is_finalized
|
self.is_finalized
|
||||||
@@ -222,10 +222,10 @@ impl MetaPlugin for MagicFileMetaPluginImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "magic")]
|
#[cfg(feature = "meta_magic")]
|
||||||
pub use MagicFileMetaPluginImpl as MagicFileMetaPlugin;
|
pub use MagicFileMetaPluginImpl as MagicFileMetaPlugin;
|
||||||
|
|
||||||
#[cfg(not(feature = "magic"))]
|
#[cfg(not(feature = "meta_magic"))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FallbackMagicFileMetaPlugin {
|
pub struct FallbackMagicFileMetaPlugin {
|
||||||
buffer: Vec<u8>,
|
buffer: Vec<u8>,
|
||||||
@@ -234,7 +234,7 @@ pub struct FallbackMagicFileMetaPlugin {
|
|||||||
base: BaseMetaPlugin,
|
base: BaseMetaPlugin,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "magic"))]
|
#[cfg(not(feature = "meta_magic"))]
|
||||||
impl FallbackMagicFileMetaPlugin {
|
impl FallbackMagicFileMetaPlugin {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||||
@@ -336,7 +336,7 @@ impl FallbackMagicFileMetaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "magic"))]
|
#[cfg(not(feature = "meta_magic"))]
|
||||||
impl MetaPlugin for FallbackMagicFileMetaPlugin {
|
impl MetaPlugin for FallbackMagicFileMetaPlugin {
|
||||||
fn is_finalized(&self) -> bool {
|
fn is_finalized(&self) -> bool {
|
||||||
self.is_finalized
|
self.is_finalized
|
||||||
@@ -441,7 +441,7 @@ impl MetaPlugin for FallbackMagicFileMetaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "magic"))]
|
#[cfg(not(feature = "meta_magic"))]
|
||||||
pub use FallbackMagicFileMetaPlugin as MagicFileMetaPlugin;
|
pub use FallbackMagicFileMetaPlugin as MagicFileMetaPlugin;
|
||||||
|
|
||||||
use crate::meta_plugin::register_meta_plugin;
|
use crate::meta_plugin::register_meta_plugin;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ pub mod digest;
|
|||||||
pub mod env;
|
pub mod env;
|
||||||
pub mod exec;
|
pub mod exec;
|
||||||
pub mod hostname;
|
pub mod hostname;
|
||||||
#[cfg(feature = "infer")]
|
#[cfg(feature = "meta_infer")]
|
||||||
pub mod infer_plugin;
|
pub mod infer_plugin;
|
||||||
pub mod keep_pid;
|
pub mod keep_pid;
|
||||||
pub mod magic_file;
|
pub mod magic_file;
|
||||||
@@ -17,32 +17,32 @@ pub mod read_time;
|
|||||||
pub mod shell;
|
pub mod shell;
|
||||||
pub mod shell_pid;
|
pub mod shell_pid;
|
||||||
pub mod text;
|
pub mod text;
|
||||||
#[cfg(feature = "tokens")]
|
#[cfg(feature = "meta_tokens")]
|
||||||
pub mod tokens;
|
pub mod tokens;
|
||||||
#[cfg(feature = "tree_magic_mini")]
|
#[cfg(feature = "meta_tree_magic_mini")]
|
||||||
pub mod tree_magic_mini;
|
pub mod tree_magic_mini;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
pub use digest::DigestMetaPlugin;
|
pub use digest::DigestMetaPlugin;
|
||||||
pub use exec::MetaPluginExec;
|
pub use exec::MetaPluginExec;
|
||||||
#[cfg(feature = "magic")]
|
#[cfg(feature = "meta_magic")]
|
||||||
pub use magic_file::MagicFileMetaPlugin;
|
pub use magic_file::MagicFileMetaPlugin;
|
||||||
// pub use text::TextMetaPlugin; // Removed duplicate
|
// pub use text::TextMetaPlugin; // Removed duplicate
|
||||||
pub use cwd::CwdMetaPlugin;
|
pub use cwd::CwdMetaPlugin;
|
||||||
pub use env::EnvMetaPlugin;
|
pub use env::EnvMetaPlugin;
|
||||||
pub use hostname::HostnameMetaPlugin;
|
pub use hostname::HostnameMetaPlugin;
|
||||||
#[cfg(feature = "infer")]
|
#[cfg(feature = "meta_infer")]
|
||||||
pub use infer_plugin::InferMetaPlugin;
|
pub use infer_plugin::InferMetaPlugin;
|
||||||
pub use keep_pid::KeepPidMetaPlugin;
|
pub use keep_pid::KeepPidMetaPlugin;
|
||||||
pub use read_rate::ReadRateMetaPlugin;
|
pub use read_rate::ReadRateMetaPlugin;
|
||||||
pub use read_time::ReadTimeMetaPlugin;
|
pub use read_time::ReadTimeMetaPlugin;
|
||||||
pub use shell::ShellMetaPlugin;
|
pub use shell::ShellMetaPlugin;
|
||||||
pub use shell_pid::ShellPidMetaPlugin;
|
pub use shell_pid::ShellPidMetaPlugin;
|
||||||
#[cfg(feature = "tree_magic_mini")]
|
#[cfg(feature = "meta_tree_magic_mini")]
|
||||||
pub use tree_magic_mini::TreeMagicMiniMetaPlugin;
|
pub use tree_magic_mini::TreeMagicMiniMetaPlugin;
|
||||||
pub use user::UserMetaPlugin;
|
pub use user::UserMetaPlugin;
|
||||||
|
|
||||||
#[cfg(not(feature = "magic"))]
|
#[cfg(not(feature = "meta_magic"))]
|
||||||
pub use magic_file::FallbackMagicFileMetaPlugin as MagicFileMetaPlugin;
|
pub use magic_file::FallbackMagicFileMetaPlugin as MagicFileMetaPlugin;
|
||||||
|
|
||||||
type PluginConstructor = fn(
|
type PluginConstructor = fn(
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ use clap::Command;
|
|||||||
use clap::error::ErrorKind;
|
use clap::error::ErrorKind;
|
||||||
use comfy_table::{Attribute, Cell, ContentArrangement, Table};
|
use comfy_table::{Attribute, Cell, ContentArrangement, Table};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use regex::Regex;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
@@ -56,23 +55,18 @@ pub enum OutputFormat {
|
|||||||
Yaml,
|
Yaml,
|
||||||
}
|
}
|
||||||
|
|
||||||
static KEEP_META_RE: std::sync::LazyLock<Regex> =
|
|
||||||
std::sync::LazyLock::new(|| Regex::new(r"^KEEP_META_(.+)$").unwrap());
|
|
||||||
|
|
||||||
pub const IMPORT_FORMAT_ERROR: &str =
|
pub const IMPORT_FORMAT_ERROR: &str =
|
||||||
"Unsupported import format: {} (expected .keep.tar or .meta.yml)";
|
"Unsupported import format: {} (expected .keep.tar or .meta.yml)";
|
||||||
|
|
||||||
pub fn get_meta_from_env() -> HashMap<String, String> {
|
pub fn get_meta_from_env() -> HashMap<String, String> {
|
||||||
debug!("COMMON: Getting meta from KEEP_META_*");
|
debug!("COMMON: Getting meta from KEEP_META_*");
|
||||||
let mut meta_env: HashMap<String, String> = HashMap::new();
|
let mut meta_env: HashMap<String, String> = HashMap::new();
|
||||||
|
const PREFIX: &str = "KEEP_META_";
|
||||||
for (key, value) in env::vars() {
|
for (key, value) in env::vars() {
|
||||||
if let Some(meta_name_caps) = KEEP_META_RE.captures(key.as_str()) {
|
if let Some(name) = key.strip_prefix(PREFIX) {
|
||||||
let name = meta_name_caps.get(1).map(|m| m.as_str().to_string());
|
if !name.is_empty() && name != "PLUGINS" {
|
||||||
if let Some(name) = name {
|
debug!("COMMON: Found meta: {}={}", name, value);
|
||||||
if name != "PLUGINS" {
|
meta_env.insert(name.to_string(), value);
|
||||||
debug!("COMMON: Found meta: {}={}", name, value);
|
|
||||||
meta_env.insert(name, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -532,6 +532,7 @@ pub struct TagsQuery {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// use keep::modes::server::common::ListItemsQuery;
|
/// use keep::modes::server::common::ListItemsQuery;
|
||||||
/// let query = ListItemsQuery {
|
/// let query = ListItemsQuery {
|
||||||
|
/// ids: None,
|
||||||
/// tags: Some("important".to_string()),
|
/// tags: Some("important".to_string()),
|
||||||
/// order: Some("newest".to_string()),
|
/// order: Some("newest".to_string()),
|
||||||
/// start: Some(0),
|
/// start: Some(0),
|
||||||
|
|||||||
@@ -179,12 +179,12 @@ async fn run_server(
|
|||||||
let addr: SocketAddr = bind_address.parse()?;
|
let addr: SocketAddr = bind_address.parse()?;
|
||||||
|
|
||||||
// Warn if authentication is enabled without TLS
|
// Warn if authentication is enabled without TLS
|
||||||
if config.password.is_some() || config.password_hash.is_some() || config.jwt_secret.is_some() {
|
if (config.password.is_some() || config.password_hash.is_some() || config.jwt_secret.is_some())
|
||||||
if config.cert_file.is_none() || config.key_file.is_none() {
|
&& (config.cert_file.is_none() || config.key_file.is_none())
|
||||||
log::warn!(
|
{
|
||||||
"SECURITY: Authentication enabled but TLS is not configured. Credentials will be transmitted in plain text!"
|
log::warn!(
|
||||||
);
|
"SECURITY: Authentication enabled but TLS is not configured. Credentials will be transmitted in plain text!"
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the app into a service
|
// Build the app into a service
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod digest_tests;
|
pub mod digest_tests;
|
||||||
|
|
||||||
#[cfg(feature = "infer")]
|
#[cfg(feature = "meta_infer")]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod infer_tests;
|
pub mod infer_tests;
|
||||||
|
|
||||||
#[cfg(feature = "tree_magic_mini")]
|
#[cfg(feature = "meta_tree_magic_mini")]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod tree_magic_mini_tests;
|
pub mod tree_magic_mini_tests;
|
||||||
|
|||||||
Reference in New Issue
Block a user