refactor(#1474): group journalctl read args into a journalquery struct
This commit is contained in:
parent
98660d134a
commit
f751c4495f
7 changed files with 77 additions and 116 deletions
|
|
@ -52,6 +52,40 @@ impl JournalOutput {
|
|||
}
|
||||
}
|
||||
|
||||
/// journalctl knobs for `ReadContainerJournal`. Grouped into one value so
|
||||
/// the read-journal call chain (`priv_client::read_container_journal` →
|
||||
/// hive-priv's executor) and its several hive-c0re callers pass a single
|
||||
/// struct instead of eight positional args that travelled together 1:1.
|
||||
/// `Default` is the common case (last N lines, short format, no filters);
|
||||
/// callers fill `lines` and override only the knobs they need via
|
||||
/// `..Default::default()`.
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct JournalQuery {
|
||||
/// `-n <lines>`.
|
||||
pub lines: u32,
|
||||
/// `-b` — restrict to the current boot.
|
||||
#[serde(default)]
|
||||
pub boot: bool,
|
||||
/// `--output=<...>`.
|
||||
#[serde(default)]
|
||||
pub output: JournalOutput,
|
||||
/// `-u <unit>`.
|
||||
#[serde(default)]
|
||||
pub unit: Option<String>,
|
||||
/// `-p <priority>`.
|
||||
#[serde(default)]
|
||||
pub priority: Option<String>,
|
||||
/// `--grep=<regex>`.
|
||||
#[serde(default)]
|
||||
pub grep: Option<String>,
|
||||
/// `--since=<ts>`.
|
||||
#[serde(default)]
|
||||
pub since: Option<String>,
|
||||
/// `--until=<ts>`.
|
||||
#[serde(default)]
|
||||
pub until: Option<String>,
|
||||
}
|
||||
|
||||
/// One bind-mount entry for `WriteNspawnFlags`.
|
||||
/// hive-priv constructs `--bind=<host_path>:<container_path>` (or `--bind-ro=`)
|
||||
/// and validates both paths before writing the conf file.
|
||||
|
|
@ -132,29 +166,8 @@ pub enum PrivRequest {
|
|||
ReadContainerJournal {
|
||||
/// System container name (`h-<agent>` or a sibling service).
|
||||
container: String,
|
||||
/// `-n <lines>`.
|
||||
lines: u32,
|
||||
/// `-b` — restrict to the current boot.
|
||||
#[serde(default)]
|
||||
boot: bool,
|
||||
/// `--output=<...>`.
|
||||
#[serde(default)]
|
||||
output: JournalOutput,
|
||||
/// `-u <unit>`.
|
||||
#[serde(default)]
|
||||
unit: Option<String>,
|
||||
/// `-p <priority>`.
|
||||
#[serde(default)]
|
||||
priority: Option<String>,
|
||||
/// `--grep=<regex>`.
|
||||
#[serde(default)]
|
||||
grep: Option<String>,
|
||||
/// `--since=<ts>`.
|
||||
#[serde(default)]
|
||||
since: Option<String>,
|
||||
/// `--until=<ts>`.
|
||||
#[serde(default)]
|
||||
until: Option<String>,
|
||||
/// journalctl knobs (see [`JournalQuery`]).
|
||||
query: JournalQuery,
|
||||
},
|
||||
|
||||
// --- Config file writes ---
|
||||
|
|
|
|||
Loading…
Reference in a new issue