[control] Phase 2 control plane: routes repo via git, journaled apply with trial/watch/revert, undo and restore, push with retry, share links, API tokens, REST API with OpenAPI, --dev

This commit is contained in:
2026-11-07 18:17:06 +01:00
parent 56209cc595
commit aa0f66b5ac
20 changed files with 7165 additions and 13 deletions
+61
View File
@@ -0,0 +1,61 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Error log on stderr (journald under systemd). Control never logs request headers, bodies,
//! query strings, tokens, passwords or share links: request lines are logged as method and
//! route only, by the API layer.
use std::io::Write;
use log::{Level, LevelFilter, Log, Metadata, Record};
struct Stderr {
own: LevelFilter,
}
impl Log for Stderr {
fn enabled(&self, m: &Metadata<'_>) -> bool {
let limit = if m.target().starts_with("ianitor") {
self.own
} else {
self.own.min(LevelFilter::Info)
};
m.level() <= limit
}
fn log(&self, r: &Record<'_>) {
if self.enabled(r.metadata()) {
let lvl = match r.level() {
Level::Error => "ERROR",
Level::Warn => "WARN",
Level::Info => "INFO",
Level::Debug => "DEBUG",
Level::Trace => "TRACE",
};
let _ = writeln!(
std::io::stderr().lock(),
"{lvl} {}: {}",
r.target(),
r.args()
);
}
}
fn flush(&self) {
let _ = std::io::stderr().flush();
}
}
pub fn init(level: Option<&str>) {
let own = match level.map(str::to_ascii_lowercase).as_deref() {
Some("error") => LevelFilter::Error,
Some("warn") => LevelFilter::Warn,
Some("debug") => LevelFilter::Debug,
Some("trace") => LevelFilter::Trace,
_ => LevelFilter::Info,
};
if log::set_boxed_logger(Box::new(Stderr { own })).is_ok() {
log::set_max_level(own);
}
}